Skip to content

Commit

Permalink
Date/datetime timezone related fixes (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-moser authored Jun 24, 2024
1 parent 7408938 commit 7969182
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion public/js/pimcore/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion public/js/pimcore/object/tags/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion public/js/pimcore/object/tags/datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
3 changes: 2 additions & 1 deletion translations/admin.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"'
invalid_option: 'Invalid Option field [ {field} ]: Please choose a valid option for select / multiselect field [ {field} ]. Current value: "{option}"'
respect_timezone: 'Respect timezone'

0 comments on commit 7969182

Please sign in to comment.