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

isDST() of Africa/El_Aaiun returns incorrect value despite UTC offset difference #968

Closed
ghost opened this issue Jan 5, 2022 · 6 comments

Comments

@ghost
Copy link

ghost commented Jan 5, 2022

Moment-timezone version which you use:

Version: 0.5.34

Note: many issues are resolved if you just upgrade to the latest version

Issue description:

UTC offset of Africa/El_Aaiun on 15 May 2021 returns 0 minutes
UTC offset of Africa/El_Aaiun on today (5 Jan 2022) returns 60 minutes
but both instances of moment return false for isDST()

The correct value should be:
15 May 2021 one return false
5 Jan 2022 one return true

@ghost
Copy link
Author

ghost commented Jan 5, 2022

Africa/Casablanca shares the same issue, should be related to the WEST (Western European Summer Time) vs WET (Western European Time)

@gilmoreorless
Copy link
Member

This looks like a bug caused by the naïve way that the core Moment calculates the DST value. It compares offsets between dates in January and June (see moment/moment#3311 (comment)). But this fails to account for the countries that adjust their UTC offset for only a month or so, based on Ramadan.

It should be possible to get Moment Timezone to override this calculation based on the data files, but I think this would still be buggy in the current format. The data files don't save all the raw values from the initial IANA time zone database source, just the calculated final offsets. This means some information is lost during compilation of the data files.

This scenario is especially complicated for zones like Africa/Casablanca. According to the way their government specifies its time zone, Morocco is officially on UTC+01:00 all year round, except for the month of Ramadan where it's UTC+00:00. This effectively makes Ramadan the "daylight saving" period, so isDST() should return true only for that month, which is inverted from how most other time zones work.

@ghost
Copy link
Author

ghost commented Jan 25, 2022

It seems that Europe/Dublin is officially having GMT as its winter time (-1 hour) and it is treated as non-DST while its standard time (IST) is treated as DST. Does it make sense to have similar logic applied to Africa/Casablanca as well?
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#DUBLIN
https://www.timeanddate.com/time/zone/morocco/casablanca
https://www.timeanddate.com/time/zone/ireland/dublin
No sure if these pages can serve as legit sources

@gilmoreorless
Copy link
Member

That's right, Namibia (Africa/Windhoek) has the same thing going on. Officially their standard time is 1 hour ahead of their alternative time / DST. Moment doesn't handle Namibia or Ireland correctly, as it just assumes that the time that's ahead is "DST". I think it hasn't been raised as a bug for Ireland because the current behaviour actually matches most people's intuition about how DST works.

@ghost
Copy link
Author

ghost commented Jan 26, 2022

I think alternative time and DST should be treated as different concepts. And it seems like the consensus is that DST is the time that's observably ahead.
Also due to the fact that nobody's raising the Ireland naming thing as a bug, maybe instead of redefining the idea of DST to "alternative time", we can just go with the current logic and just update the DST value implementation to handle DST cases outside of Jan and June.

https://en.wikipedia.org/wiki/Daylight_saving_time#Procedure

In most countries that observe seasonal daylight saving time, the clock observed in winter is legally named "standard time"[41] in accordance with the standardization of time zones to agree with the local mean time near the center of each region.[42] An exception exists in Ireland, where its winter clock has the same offset (UTC±00:00) and legal name as that in Britain (Greenwich Mean Time)—but while its summer clock also has the same offset as Britain's (UTC+01:00), its legal name is Irish Standard Time[43][44] as opposed to British Summer Time.[45]

While most countries that change clocks for daylight saving time observe standard time in winter and DST in summer, Morocco observes (since 2019) daylight saving time every month but Ramadan. During the holy month (the date of which is determined by the lunar calendar and thus moves annually with regard to the Gregorian calendar), the country's civil clocks observe Western European Time (UTC+00:00, which geographically overlaps most of the nation). At the close of this month, its clocks are turned forward to Western European Summer Time (UTC+01:00), where they remain until the return of the holy month the following year.[46][47][48]

@ichernev
Copy link
Contributor

@andyhokl other than documenting that isDST is a hack, I don't see much else possible. You could add some code on your end to handle these specific timezones, esp if you have enough users in such "special" areas. Another option is to add dst information from IANA, but I'm not sure it's worth it.

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

2 participants