-
Notifications
You must be signed in to change notification settings - Fork 721
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
"Etc/UTC" is treated differently than 'UTC'. #1358
Comments
Great catch, thank you very much for the report. I've reviewed the IETF documentation and agree that this is a Luxon bug (and also I agree with your analysis about the root cause). 'Etc/UTC' is supposed to be exactly identical to 'UTC', so simply adding I'll publish a PR with the above described patch and a matching unit test tonight, probably, and I'll look around for any other related bugs while I'm at it. |
@dobon yeah, I think I'd take that. It would also help perf on that zone, because we wouldn't have to ask Intl to compute offsets for us. |
Unfortunately this stuff seems highly inconsistent... According to the tz database list on Wikipedia, there are tons of names for UTC. First there are the obvious ones, like UTC, Etc/UTC. But then there is also "Etc/Greenwich" or "Greenwich", which is supposed to be equivalent. V8 does not treat them all the same. "Etc/Greenwich" produces "Greenwich Mean Time", but "Etc/GMT" produces "Coordinated Universal Time". |
I don't think it's that complicated. Ignoring that GMT and UTC are technically different, as the original post outlines, anything that is supposed to map to UTC should behave the same as if the UTC offset were directly used. const utcAliases = new Set([
'UTC',
'Etc/UTC // keep going
])
if (utcAliases.has(something) === true) {
// do stuff
} |
Yes, that part is trivial. But where do we draw the line? Currently, Luxon already treats My gut says go with the most commonly used options, i.e. |
I wouldn't base anything on what a browser does or doesn't do. I'd follow the already linked spec https://www.ietf.org/timezones/data/etcetera |
What about https://www.ietf.org/timezones/data/backward then? It lists many more aliases for UTC. Should all of these be checked as well? That might get into the territory of being significant for bundle size. |
I'm not sure I can offer an opinion on that as I am not familiar with Luxon's commitment level for support of the tzdata spec and such backward compatibility. It would make sense to me to include some sort of hash that prevents issues such as this one in the future, though. I filed this issue because a contributor was trying to update some code to replace |
toISO still behaves correctly in either case. Both |
Yes, they are both accurate. The issue is that they are inconsistent for the same "zone". |
What issues does that cause, though? In terms of ISO format, |
I think the original report shows what issues it causes. |
There are no problems listed in the original report, only facts are stated and your desire for the output to be different. |
@diesieben07 we generally think of Z as implying UTC. Compare to, say, London time when the offset happens to be 0. So when possible we try to format UTC dates with a Z in order to convey that extra piece of information about the zone. In practice there are limits to what we can reasonably do, of course. |
Shouldn't that then mean that |
I think of GMT as an (outdated) alias for UTC as well. I'm certainly open to being wrong about this, but I don't see a meaningful difference between them in theory or in usage. |
It's not though. GMT was used as the basis of time around the world just like UTC is today, but it uses a totally different source of time than UTC does (astronomy vs an atomic clock). Edit: So, after some more reading and thinking, my opinion is that we should change this check to check for |
Hello, noticed that this issue still persisting and we kinda have a real problem with it on Avo. We're using Flatpickr and we want to allow our users to force a timezone to a date & time field. Lets say the user is on CET timezone and he want to force UTC, when using
How can I convert a date to UTC and get the offset output as |
Describe the bug
Consider (runkit playground -- https://runkit.com/63b9e8148ba93c0008d85c98/63b9e81423d01f0008ee1a6d):
The output will be:
It seems reasonable to expect that both representations of the UTC offset would result in the same string. That is,
console.log(dt.setZone('Etc/UTC').toISO())
should output2022-01-07T21:00:00.000Z
.The issue seems to stem from the following line:
luxon/src/impl/zoneUtil.js
Line 23 in c12e5dc
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: