-
Notifications
You must be signed in to change notification settings - Fork 2
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
Should identifiers that resolve to UTC always be canonicalized? #21
Comments
2 seems best for the reasons indicated. |
Just to be clear, this is separate from the special treatment of |
@ptomato If I'm understanding your question correctly, I think the answer is "yes, it's separate", but I'll explain more below to make sure. This proposal makes canonicalization mostly invisible to ECMAScript programs, because we'll stop canonicalizing user-supplied time zone IDs. However, if ECMAScript supplies the ID, then they'll still be canonicalized. There are two places where this happens:
In these two AOs, only However, this special case only deals with canonicalization of IDs that come from ECMAScript itself. If the user supplies an ID like My hope is that during Stage 3, we can get implementation and user feedback to make sure that this change in behavior doesn't cause any major problems. And if it does, we can revert some of the change, e.g. to always canonicalize UTC-resolving IDs. But I agree with Jordan that it probably makes sense to start with the most consistent behavior which is (2) above: don't canonicalize any user-supplied IDs. Does this answer your question? |
The core proposition of this proposal is that ECMAScript shouldn't change user-inputted identifiers. If the user provides Asia/Calcutta, then they should get Asia/Calcutta back. Ditto for Asia/Kolkata.
But should this rule also apply to time zone identifiers that resolve to UTC? There's 14 aliases for UTC. Most are obscure, but Etc/UTC (and perhaps Etc/GMT) will probably show up frequently, especially in inputs from other systems that follow IANA's practice of making "Etc/UTC", not "UTC" the canonical identifier for this Zone.
Here's a few reasons I'd expect users to check whether a time zone is UTC:
I think we have these options:
=== 'UTC'
is a frequently-used pattern in existing code and (unlike location-based zones) we never have to worry about it being broken in future TZDB releases.===
to compare any IDs, including UTC.TimeZone.p.isUTC
to check to see whether an identifier or time zone object is UTC. It'stz.isUTC()
would be shorthand fortz.equals('UTC')
, which doesn't save much ergonomically, but would be much more discoverable in IDE auto-complete and in docs.My current preference is for option (2) because it's simplest and most consistent, and then we can always add (3) later if too many users are still getting tripped up by using
=== 'UTC'
.But I wanted to get others' feedback too.
Here's the identifiers that resolve to
'UTC'
in ECMAScript:The text was updated successfully, but these errors were encountered: