Metro-UI-CSS icon indicating copy to clipboard operation
Metro-UI-CSS copied to clipboard

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

Open Harry-33 opened this issue 2 years ago • 1 comments
trafficstars

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 avatar Feb 09 '23 14:02 Harry-33

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

Harry-33 avatar Feb 15 '23 11:02 Harry-33