Metro-UI-CSS
Metro-UI-CSS copied to clipboard
Calendar showing false day of week for dates when timezone is negative
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:
- Open Demo page: https://metroui.org.ua/calendar.html --> you will see everything is correct (if timezone is UTC or UTC+)
- Change timezone to UTC- (e.g. for Central Time UTC-06:00)
- 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:
old metro version:

Does anyone knows a workaround for that?
Thx in advance!
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