From ef64b359a6881e1797058e2a75522c91b322e5e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20H=C3=A4rter?= Date: Thu, 18 Jul 2024 14:27:04 +0200 Subject: [PATCH] Issue #3483: Enabled AJAX update to deal with date time offsets. --- var/httpd/htdocs/js/Core.AJAX.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/var/httpd/htdocs/js/Core.AJAX.js b/var/httpd/htdocs/js/Core.AJAX.js index 7b434f50d..9a9948288 100644 --- a/var/httpd/htdocs/js/Core.AJAX.js +++ b/var/httpd/htdocs/js/Core.AJAX.js @@ -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; }