Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Harry-33 opened this issue Feb 9, 2023 · 1 comment
Open

Comments

@Harry-33
Copy link

Harry-33 commented Feb 9, 2023

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant