olton / Metro-UI-CSS

Impressive component library for expressive web development! Build responsive projects on the web with the first front-end component library in Metro Style. And now there are even more opportunities every day!
http://metroui.org.ua/
MIT License
7.04k stars 1.96k forks source link

Calendar showing false day of week for dates when timezone is negative #1893

Open Harry-33 opened 1 year ago

Harry-33 commented 1 year ago

Hi, there is an issue with the calendar module in MetroUI when running in environments with negative time zone (UTC-01:00 to -XX).

You can see it also on the demo page: 1) Open Demo page: https://metroui.org.ua/calendar.html --> you will see everything is correct (if timezone is UTC or UTC+) 2) Change timezone to UTC- (e.g. for Central Time UTC-06:00) 3) Open demo page again: https://metroui.org.ua/calendar.html You will note that the days in the calendar are off by one day. Interestingly old versions of MetroUI (e.g. V3) didn't have the issue: (Note: Today is Thursday - the 9th of February 2023) current metro version: image old metro version: image

Does anyone knows a workaround for that?

Thx in advance!

Harry-33 commented 1 year ago

Found a workaround for that - if someone also encounters this issue: (metro.js - starting at line 83:) instead of: Datetime = function(){ var args = [].slice.call(arguments); this.value = new (Function.prototype.bind.apply(Date, [this].concat(args) ) ); this.locale = "en"; this.weekStart = global['DATETIME_LOCALES']["en"].weekStart; this.utcMode = true; this.mutable = true; do the following: var args = [].slice.call(arguments); this.value = new (Function.prototype.bind.apply(Date, [this].concat(args) ) ); this.locale = "en"; this.weekStart = global['DATETIME_LOCALES']["en"].weekStart; this.utcMode = true; //default value if(new Date().getTimezoneOffset() > 0) //gettimezoneoffset { this.utcMode = true;(workaround?) } else { this.utcMode = false; } this.mutable = true; Harry