From 796918235b0c78dcee3efc4ef3c2d1aedd1a1d63 Mon Sep 17 00:00:00 2001 From: markus-moser Date: Mon, 24 Jun 2024 17:06:14 +0200 Subject: [PATCH] Date/datetime timezone related fixes (#583) --- public/js/pimcore/functions.js | 2 +- public/js/pimcore/object/tags/date.js | 2 +- public/js/pimcore/object/tags/datetime.js | 2 +- translations/admin.en.yaml | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/public/js/pimcore/functions.js b/public/js/pimcore/functions.js index 1637d65594..c501472fe7 100644 --- a/public/js/pimcore/functions.js +++ b/public/js/pimcore/functions.js @@ -1801,7 +1801,7 @@ function getUserTimezone() { function dateToServerTimezone(date) { let utcDate = new Date(date.toLocaleString('en-US', { - timeZone: pimcore.settings.timezone ?? 'UTC' + timeZone: pimcore.settings.timezone ? pimcore.settings.timezone : 'UTC' })); let diff = date.getTime() - utcDate.getTime(); diff --git a/public/js/pimcore/object/tags/date.js b/public/js/pimcore/object/tags/date.js index a690560532..9bedc93dec 100644 --- a/public/js/pimcore/object/tags/date.js +++ b/public/js/pimcore/object/tags/date.js @@ -69,7 +69,7 @@ pimcore.object.tags.date = Class.create(pimcore.object.tags.abstract, { }, getGridColumnFilter:function (field) { - return {type:'date', dataIndex:field.key, dateFormat: field.layout.columnType === "date" ? 'm/d/Y' : "c"}; + return {type:'date', dataIndex:field.key, dateFormat: field.layout.columnType === "date" ? 'Y-m-d' : "c"}; }, getLayoutEdit:function () { diff --git a/public/js/pimcore/object/tags/datetime.js b/public/js/pimcore/object/tags/datetime.js index ec3f8eb1b9..c263c2d85a 100644 --- a/public/js/pimcore/object/tags/datetime.js +++ b/public/js/pimcore/object/tags/datetime.js @@ -69,7 +69,7 @@ pimcore.object.tags.datetime = Class.create(pimcore.object.tags.abstract, { }, getGridColumnFilter:function (field) { - return {type:'date', dataIndex:field.key, dateFormat: 'c'}; + return {type:'date', dataIndex:field.key, dateFormat: field.layout.respectTimezone !== false ? "c" : "Y-m-d"}; }, getLayoutEdit:function () { diff --git a/translations/admin.en.yaml b/translations/admin.en.yaml index 95b613b035..2758fde929 100644 --- a/translations/admin.en.yaml +++ b/translations/admin.en.yaml @@ -1019,4 +1019,5 @@ male: Male female: Female pdf_js_unsafe: This PDF file contains JavaScript. If you want to view it, please download and open it in your local PDF viewer. pdf_scan_in_progress: 'Preview not available: PDF is being scanned. This may take a while.' -invalid_option: 'Invalid Option field [ {field} ]: Please choose a valid option for select / multiselect field [ {field} ]. Current value: "{option}"' \ No newline at end of file +invalid_option: 'Invalid Option field [ {field} ]: Please choose a valid option for select / multiselect field [ {field} ]. Current value: "{option}"' +respect_timezone: 'Respect timezone' \ No newline at end of file