Skip to content

Commit

Permalink
Issue #3483: Enabled AJAX update to deal with date time offsets.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhaerter authored and bschmalhofer committed Jul 24, 2024
1 parent 53088f8 commit ef64b35
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion var/httpd/htdocs/js/Core.AJAX.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,31 @@ Core.AJAX = (function (TargetNS) {

// date time
if ( $Element.hasClass('DynamicFieldDate') ) {
Core.UI.InputFields.SetDate($Element, DataValue);

// empty value, set current date and used unchecked
if ( !DataValue ) {
Core.UI.InputFields.SetDate($Element);
}

// unknown, expected to be valid date
else if ( isNaN(DataValue) ) {
Core.UI.InputFields.SetDate($Element, DataValue);
}

// integer value, which represents an offset
else {

// get timestamp of current date
var CurrentDate = new Date();
var Timestamp = CurrentDate.valueOf();

// add or subtract offset
// NOTE Timestamp is in milliseconds and offset in seconds, therefor we have to multiply offset by 1000
Timestamp += ( parseInt(DataValue) * 1000 );

// Date constructor is able to deal with timestamps, no need to pass a date string
Core.UI.InputFields.SetDate($Element, Timestamp);
}
return;
}

Expand Down

0 comments on commit ef64b35

Please sign in to comment.