-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Make LocalTZA take 't' and 'isUTC' and drop DSTA(t). #778
Conversation
@bterlson, @ediosyncratic, @littledan : could you take a look? I like this better than #771. Thanks. |
I'm very glad that there is an attempt to normalize this in the spec. However I must say that the proposed standard is exactly backwards of what should be done (IMHO):
This makes little sense. 1:30 UTC-5 is indeed the "standard" time, but it is the second of the two occurrences. Time moves in a forward-only direction. A person watching their clock would not see the first 1:30, and say to themselves "oh wait, not this one, I think I'll wait a bit for another". They would act on the first occurrence - the "daylight" time occurrence. Then logically when the second one came around, they would not act again because they already had done so.
This is also backwards. 2:30 UTC-4 does not exist in the US Eastern time zone. Through math, it would be normalized to 1:30 UTC-5. This is moving the wall time backward an hour. A sane person in the local time zone would not do this. They would not see that their regular time is 2:30 but remember to run an hour earlier because of the DST change they had not done yet! Instead, they would at 2:00 advance their clocks to 3:00, then they would do the scheduled activity either right then, or at 3:30. The latter is preferred, because if you had tasks at 2:05, 2:10, 2:15, 2:20, etc.. you would not do them ALL at the same time at 3:00. Another way to think about this is: if a local time is non-existent then the local clock did not move forward. Therefore, track the local time in place, and advance the clock forward by the amount of the gap. To summarize, the text should be changed to:
and
These are the ONLY sensical options. Moving backwards is nonsensical. Time doesn't move backwards. Note that this is exactly what Java 8 does in it's new time API, and is also what most production job scheduling systems will do. It's also what we do in moment.js (when we have control over it with moment-timezone), and it's what NodaTime is switching to in its upcoming 2.0 release. I strongly suggest that ECMAScript follow suit. Also - keep in mind that |
FYI, I just checked in current versions of Chrome, IE, Edge, and Node.js, and they all follow my suggested implementation. I also checked FireFox, and it follows the alternative implementation - the one that was originally suggested and that I am against. I've checked this a few times over the years, and noticed that some browsers have flip-flopped on this point. It should indeed be standardized - but towards the way that Chrome, IE, Edge and Node.js are currently implementing it. |
Agree with Matt here, but have to add a couple semantics. It is properly This is some of the best work in date/time out there, so their choices are good to model after. |
One other thing of note - this is correct in not tracking a separate adjustment for daylight saving time. The 'normal' way (if there is one - it it as least the way I know and have seen) to convert between UTC and local time in a timezone is to use a table that contains transition points for a time zone in UTC, and the new offset at that point, to determine what the correct offset is for a given point on the global timeline. This system will work for both DST, and for changes to a country's standard offset, as happened in several places in Russia in 2016. |
Thanks a lot for the review/feedback. A couple of points to clarify:
With the tz set to America/New_York, Firefox does the following:
v8 does the opposite, indeed.
Because of the 4th point below, I thought it'd be better to consider adding an option to control the behavior around time zone offset transition, but that is left for the future because it requires changing the public API signature.
Anyway, I'm perfectly fine with the default behavior as suggested by @mj1856 because having read his argument, I'm kinda persuaded that the behavior he wants seems to make sense (from the pov of a person going through the transition looking at a clock) and I don't have any preference. My primary goal is to get rid of the ambiguity. I'll revise the PR and ask you to take another look. Thanks again. [1] ICU Calendar API has skipped wall time option (https://goo.gl/h0bP26) and [2] Python proposal to handle skipped/repeated time: |
Sure. I wish I'd not have to worry about converting t_local (t value calculated from y,M,d, h, m, s in local time) to t_UTC. That is, I wish I'd not have to deal with LocalTZA(t, isUTC = false)). Unfortunately, the way Date constructor taking 'y,M,d,h,m,s' is spec'd (y,M,d,h.m,s are supposed to be interpreted in the local time), I cannot avoid it. See #725. |
FWIW, most APIs I've seen in other languages just pick one or the other, and don't offer much control. Java 8, JodaTime, and NodaTime being the exception. When I have had this discussion with library/platform authors 1 on 1, of those that chose the 1:30 UTC-5 option (in above context), they have often told me something like, "well, we weren't sure what to do, so we just went with the 'standard' time option". Of course, there are the arguments I made earlier, and also as Maggie pointed out with Russia - that not every transition is due to DST. I've heard a lot of use cases around this, and scheduling a daily event seems to be the one that catches on it most frequently - and in that scenario there really is no option but to pick the first ambiguous instance and shift invalid times forward. That does push both of them into the "daylight" period, but so be it. The only scenario I've ever personally encountered that might want the second of two instances is when a business such as a bar or movie theater might close at 1:30 AM, but for whatever reason wants to remain open until the second occurrence. Even then - they are already thinking about this edge case and they can adjust for it manually if needed (since both 1:30's are valid). I've never encountered any use case where moving an invalid time from the spring-forward gap backwards an hour is desired. Not saying they don't exist - they're just not something I've seen. |
I"m aware that the date constructor is specd for local time. I think I didn't phrase it well, but fundamentally all I am trying to convey is that the DST transition amount itself is temporal. Some countries do DST for a few years, then stop doing it, then start again. Lord Howe Island Australia does a 30 minute DST transition NOW, but I would be entirely unsurprised if they changed to one hour later. I'm not sure how this is handled right now, but I may not be reading close enough. |
Addressed the review comments. Can you take another look, @mj1856 and @maggiepint ? Thanks ! |
@mj1856: "I've never encountered any use case where moving an invalid time from the spring-forward gap backwards an hour is desired." Suppose you have a flight early the morning after a transition and a moderately long journey to get to the airport. Subtract travel time, needed to reach airport, from required arrival time. If that lands you in the missing hour, you need to move backwards a further hour to get when to set off in good time to catch your flight. Similar scenario with a fall-back can be a reason to want the second time round. (Where I live, in CEST, the missing-or-repeated hour is 2 to 3; I believe there are places where it's 3 to 4. Catching an early flight can indeed involve getting up that early.) "The only scenario I've ever personally encountered that might want the second of two instances is when a business such as a bar or movie theater might close at 1:30 AM, but for whatever reason wants to remain open until the second occurrence. Even then - they are already thinking about this edge case and they can adjust for it manually if needed (since both 1:30's are valid)." They're going to be paying their staff for another hour's work (possibly at elevated rates; after all, it is Sunday) and they may well have to get local licensing magistrates (or similar authorities) to approve their staying open an hour longer than normal; yup, they're going to know they're doing this. I'm not a fan of making an existing numeric global variable, LocalTZA, into a function taking two parameters. Surely that's going to require a lot of folk to change code; this cannot be good. Web pages updated to work with the new spec shall break for users of older browsers; web pages still compatible with old browsers shall break in newer browsers. The earlier spec, adding a new function that Does The Right Thing, looked better to me - albeit I never got round to reviewing it in detail (I've been busy, sorry). I'll give this one a look next. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the meaning of old names would break existing code; furthermore, names with "adjustment" in them, actually meaning "offset", are worth retiring in favour of better names.
spec.html
Outdated
<p>An implementation of ECMAScript is expected to determine the local time zone adjustment with respect to UTC using the best available information on time zones.</p> | ||
<p>When _isUTC_ is true, <dfn>LocalTZA( _t_, true )</dfn> is the offset of the local time zone from UTC measured in milliseconds at time represented by time value _t_ (UTC). When it is added to _t_ (UTC), it yields the local time.</p> | ||
<p>When _isUTC_ is false, <dfn>LocalTZA( _t_, false )</dfn> is the offset of the local time zone from UTC measured in milliseconds at local time represented by time value <dfn><emu-eqn>_t_<sub>local</sub> = _t_</emu-eqn></dfn>. When it is subtracted from the local time <emu-eqn>_t_<sub>local</sub>, it yields the corresponding UTC.</p> | ||
<p>When <emu-eqn>_t_<sub>local</sub></emu-eqn> represents local time repeating multiple times at a negative time zone transition (e.g. when the daylight saving time ends or the time zone adjustment is increased) or skipped local time at a positive time zone transitions (e.g. when the daylight saving time starts or the time zone adjustment is decreased), <emu-eqn>_t_<sub>local</sub></emu-eqn> must be interpreted with the time zone adjustment before the transition.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"must be interpreted with the time zone adjustment before the transition." So a spring forward's gap gets read in standard time, resulting in a UTC that corresponds to an actual local time an hour later than indicated; and a fall back's repeated hour gets read in daylight-saving time, which means using the first pass through the repeated hour.
As long as I've decoded that right, it sounds good :-)
spec.html
Outdated
@@ -25936,44 +25936,44 @@ | |||
|
|||
<!-- es6num="20.3.1.7" --> | |||
<emu-clause id="sec-local-time-zone-adjustment"> | |||
<h1>Local Time Zone Adjustment</h1> | |||
<p>An implementation of ECMAScript is expected to determine the local time zone adjustment. The local time zone adjustment is a value <dfn>LocalTZA</dfn> measured in milliseconds which when added to UTC represents the local <em>standard</em> time. Daylight saving time is <em>not</em> reflected by LocalTZA.</p> | |||
<h1>LocalTimeZoneAdjustment ( _t_, _isUTC_ )</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've changed the section heading into a function name, but then talked about a function with a different name, LocalTZA(,); I suspect some confusion.
Also: I'd generally replace "adjustment" with "offset" - we're talking about local time's offset relative to UTC.
A time-zone adjustment is a transition, be it DST-related or one-off, at which this offset changes.
We do indeed add or subtract this offset to "adjust" a time between UTC and local time, but using "adjust" in this context is a source of potential confusion, as it may mean either kind of adjustment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do prefer 'offset' to 'adjustment', too. That's what I did in my earlier PR. However, the sign of Date.prototype.getTimezoneOffset is exactly the opposite of what's more common. That is, getTimeZoneOffset() returns a negative value for east of the primary meridian and a positive value for west of the primary meridian.
And, I want 'offset' to have the same sign in both places, but I find it rather confusing when I use a 'positive' offset change for fall backward or a 'negative' offset change for spring forward. It's still a possibility, but I chose otherwise by sticking to the existing term, 'Local Timezone Adjustment'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the meaning of old names would break existing code; furthermore, names with "adjustment" in them, actually meaning "offset", are worth retiring in favour of better names.
Well, LocalTZA is not a part of the public API. It's an internal abstract operation. Moreover, the existing code needs to be changed anyway. Spidermonkey and JSC did the exact opposite of what's specified here around a timezone offset change. v8 is broken in timezones where historic offset is different from the present tz offset, etc.
spec.html
Outdated
<h1>LocalTimeZoneAdjustment ( _t_, _isUTC_ )</h1> | ||
<p>An implementation of ECMAScript is expected to determine the local time zone adjustment with respect to UTC using the best available information on time zones.</p> | ||
<p>When _isUTC_ is true, <dfn>LocalTZA( _t_, true )</dfn> is the offset of the local time zone from UTC measured in milliseconds at time represented by time value _t_ (UTC). When it is added to _t_ (UTC), it yields the local time.</p> | ||
<p>When _isUTC_ is false, <dfn>LocalTZA( _t_, false )</dfn> is the offset of the local time zone from UTC measured in milliseconds at local time represented by time value <dfn><emu-eqn>_t_<sub>local</sub> = _t_</emu-eqn></dfn>. When it is subtracted from the local time <emu-eqn>_t_<sub>local</sub>, it yields the corresponding UTC.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If taking a "time" parameter that's a local time, there should be a boolean flag to disambiguate transitions - both how to sanitize an invalid time and which valid time to use when local time represents two identically. That's only used for three hours of each year, so it's more of a hint than anything else (we'll ignore it otherwise).
Your earlier idea of separate methods then gives: TZOffsetUTC(t) and TZOffsetLocal(t, hint) as the methods to use. The former is entirely sufficient to implement the latter [*]. We can also implement the old LocalTZA and DaylightSavingTA() in terms of it; take the min of TZOffsetUTC(now +i*year/3) for i in (-2, -1, 0, 1, 2) as LocalTZA and redefine DaylightSavingTA(t) = TZOffsetUTC(t) - LocalTZA.. The old API uses "adjustment", the new uses the more apt "offset" to signal the improvement.
[*] See lines 412--444 of src/corelib/tools/qtimezoneprivate.cpp in https://codereview.qt-project.org#/c/162414/26//ALL,unified along with documentation above it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a option to control the way to handle repeated and skipped time is beyond this PR. Note that my first commit message leaves it up to a consideration in the future, but I removed that responding to the review comment.
Anyway, in the future, it can be still considered.
This PR wants to minimize the change and get rid of the existing ambiguity by specifying the default behavior. Adding a option in the public API (note that this PR does not change the signature of any public API) is not in the scope of this PR.
That's only used for three hours of each year, so it's more of a hint than anything else (we'll ignore it otherwise).
Is it true that it's only used for three hours of each year. As you noted and I also noted before, there are other cases where this issue of repeated or skipped time is important (namely, timezone rules changes as happened to Europe/Moscow, Pacific/Apia, etc.
spec.html
Outdated
<emu-note> | ||
<p>It is recommended that implementations use the time zone information of the IANA Time Zone Database <a href="http://www.iana.org/time-zones/">http://www.iana.org/time-zones/</a>.</p> | ||
<p>1:30 AM on November 5, 2017 in America/New_York is repeated twice (fall backward), but it must be interpreted as 1:30 AM UTC-04 instead of 1:30 AM UTC-05. LocalTZA(TimeClip(MakeDate(MakeDay(2017, 10, 5), MakeTime(1, 30, 0, 0))), false) is <emu-eqn>-4 × msPerHour</emu-eqn>.</p> | ||
<p>2:30 AM on March 12, 2017 in America/New_York does not exist, but it must be interpreted as 2:30 AM UTC-05. LocalTZA(TimeClip(MakeDate(MakeDay(2017, 2, 12), MakeTime(2, 30, 0, 0))), false) is <emu-eqn>-5 × msPerHour</emu-eqn>.</p>. | ||
</emu-note> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This </emu-note> seems to be missing its opening
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I fixed in my 3rd commit.
Offset is the preferred terminology from the Moment.js team - for what it's
worth. I know that it's favored in other parts of the DateTime community as
well.
…On Thu, Jan 26, 2017 at 10:14 AM, jungshik ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In spec.html <#778>:
> @@ -25936,44 +25936,44 @@
<!-- es6num="20.3.1.7" -->
<emu-clause id="sec-local-time-zone-adjustment">
- <h1>Local Time Zone Adjustment</h1>
- <p>An implementation of ECMAScript is expected to determine the local time zone adjustment. The local time zone adjustment is a value <dfn>LocalTZA</dfn> measured in milliseconds which when added to UTC represents the local <em>standard</em> time. Daylight saving time is <em>not</em> reflected by LocalTZA.</p>
+ <h1>LocalTimeZoneAdjustment ( _t_, _isUTC_ )</h1>
I do prefer 'offset' to 'adjustment', too. That's what I did in my earlier
PR. However, the sign of Date.prototype.getTimezoneOffset is exactly the
opposite of what's more common. That is, getTimeZoneOffset() returns a
negative value for west of the primary meridian and a positive value for
east of the primary meridian.
I can use "offset' and match its sign with that of getTimeZoneOffset(),
but I find it rather confusing when I talk about 'positive' offset change
or 'negative' offset change. It's still a possibility, but I chose
otherwise by sticking to the existing term in 'Local Timezone Adjustment'.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#778>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFxi0pr3z1iZfiCRyreqARpnn22HnwPqks5rWOKBgaJpZM4LrraI>
.
|
I'm afraid that you overlooked the fact that LocalTZA is NOT a public API. It's an internal abstract operation. So, Ecma262 implementors need to change their codes (they need to anyway because the current spec has an ambiguity and this PR gets rid of that ambiguity), but web page authors does not in general. Well, their workaround (if there's been any) or reliance on the existing implementations need to adjusted. Given the fact that (according to @mj1856 ) existing implementations changed the behavior over the time and different implementations have different behaviors, I don't think this change is any worse than status quo or alternatives in terms of web compatibility. |
See my comment |
Let me give more details on the awkwardness (at least as perceived by me) when we use "offset' and get its sign to match that of getTimeZoneOffset() (public API). The current PR has this (I spotted a mistake in 'increase' and 'decrease' in the previous commit and I fixed it in the latest commit. Thank you ! ).
With the sign of offset' to match that of getTimeZoneOffset() (public API), I'd have
And, accordingly 'subtracted from' and 'added to' have to be swapped, which is fine. Hmm... having written it down, it does not seem that bad except that 'DST ends ==> tz offset increase' and 'DST starts ==> tz offset decrease' seems still a bit odd to me. Anyway, let's figure out which is the best for this term given all things I mentioned so far. |
WRT sign (+/-): Yes, the Quick history lesson: The Anyway that absolutely cannot be changed in the existing API. It would break all kinds of things. |
@ediosyncratic - Thanks for the feedback - That's a good scenario! I agree that in this case, one would want the 1:30 before the spring-forward transition, and they would also want the second 2:30 in the fall-back transition. However - we are not landing on these times by means of addressing a local time value without offset. We're landing on them through timeline math, as we do the subtraction operation. We know exactly where we're starting on the timeline, and we know the rules for the time zone, so we know exactly where we'll end up. Using
We can demonstrate this directly with the var d = new Date(2017, 2, 26, 4, 30);
d.setUTCHours(d.getUTCHours() - 2);
console.log(d.toString()); // "Sun Mar 26 2017 01:30:00 GMT+0100 (Central Europe Standard Time)" Same in the fall, when the local time from 2 AM to 3 AM is repeated.
We land at 2:30 CET - the second occurrence. Again, to demonstrate: var d = new Date(2017, 9, 29, 4, 30);
d.setUTCHours(d.getUTCHours() - 2);
console.log(d.toString()); // "Sun Oct 29 2017 02:30:00 GMT+0100 (Central Europe Standard Time)" Of course the mistake that is commonly made is that users use So - long story - but there is no problem with the scenario you describe. It doesn't invoke the condition where we we have to decide which way to adjust. That only happens when a user gives us a input in terms of local time, and that input is ambiguous or invalid. Then we go down the path with the arguments I made earlier. Cheers. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed the changes, and they look good to me.
spec.html
Outdated
<emu-note> | ||
<p>It is recommended that implementations use the time zone information of the IANA Time Zone Database <a href="http://www.iana.org/time-zones/">http://www.iana.org/time-zones/</a>.</p> | ||
<p>1:30 AM on November 5, 2017 in America/New_York is repeated twice (fall backward), but it must be interpreted as 1:30 AM UTC-04 instead of 1:30 AM UTC-05. LocalTZA(TimeClip(MakeDate(MakeDay(2017, 10, 5), MakeTime(1, 30, 0, 0))), false) is <emu-eqn>-4 × msPerHour</emu-eqn>.</p> | ||
<p>2:30 AM on March 12, 2017 in America/New_York does not exist, but it must be interpreted as 2:30 AM UTC-05. LocalTZA(TimeClip(MakeDate(MakeDay(2017, 2, 12), MakeTime(2, 30, 0, 0))), false) is <emu-eqn>-5 × msPerHour</emu-eqn>.</p>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be useful to call out here that since the result 2:30 AM UTC-5
doesn't exist, that through normalization, the user will view this as 3:30 AM UTC-4
, since they both have the same equivalency 7:30 AM UTC
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review/LGTM. I added '(equivalent to 3:30 AM UTC-04)'. Would it suffice?
spec.html
Outdated
@@ -25944,7 +25944,7 @@ | |||
<emu-note> | |||
<p>It is recommended that implementations use the time zone information of the IANA Time Zone Database <a href="http://www.iana.org/time-zones/">http://www.iana.org/time-zones/</a>.</p> | |||
<p>1:30 AM on November 5, 2017 in America/New_York is repeated twice (fall backward), but it must be interpreted as 1:30 AM UTC-04 instead of 1:30 AM UTC-05. LocalTZA(TimeClip(MakeDate(MakeDay(2017, 10, 5), MakeTime(1, 30, 0, 0))), false) is <emu-eqn>-4 × msPerHour</emu-eqn>.</p> | |||
<p>2:30 AM on March 12, 2017 in America/New_York does not exist, but it must be interpreted as 2:30 AM UTC-05. LocalTZA(TimeClip(MakeDate(MakeDay(2017, 2, 12), MakeTime(2, 30, 0, 0))), false) is <emu-eqn>-5 × msPerHour</emu-eqn>.</p>. | |||
<p>2:30 AM on March 12, 2017 in America/New_York does not exist, but it must be interpreted as 2:30 AM UTC-05 (equivalent to 3:30 AM UTC-04). LocalTZA(TimeClip(MakeDate(MakeDay(2017, 2, 12), MakeTime(2, 30, 0, 0))), false) is <emu-eqn>-5 × msPerHour</emu-eqn>.</p>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the review and approval !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what comes next.
I rebased the PR to the trunk to resolve a conflict. |
We'll have to discuss in committee. Any volunteers to bring it up? Otherwise I can. |
I'll do it if that would be easier for you, and I'm actually there. |
Thank you, @bterlson and @maggiepint ! |
df671f2
to
49a970a
Compare
Please, take one more look and merge now that I updated the PR to reflect @allenwb's comment. Thank you ! |
What should/can I do to get this merged? |
@bterlson does this seem good to merge to you? |
I'm happy to merge this now, but is there still no tests? I'm worried we may never see them :) |
I also note some must/should confusion in LocalTimeZoneAdjustment now that I'm reading this again. Can we remove should from its specification text via "LocalTZA should return" --> "LocalTZA returns"? I can just make this change myself in order to get this in asap :) |
@allenwb explained the rationale for "should" in this comment. I explained why it would be hard to write tests in this comment. In test262, we've seen a bunch of tests get filled in for areas that had gaps for a while, so I don't think that concern necessarily true (even if I'm a big fan of blocking on tests for most things). |
@littledan must vs should confusion referred to discrepancies between the note saying must and the normative text saying should, but I see now that the note is only talking about the final must requirement not the previous should requirements. It's good, in other words, thanks :) |
Thanks everybody ! |
icu-timezone-data was enabled before but reverted due to a perf issue. (sunspider/date-format-totfe regressed; crbug.com/769706 ). However, my in-Chrome test of the same test [1] shows that there's virtually no perf difference. See https://goo.gl/GX1jt6 . This will introduce a new behavior on POSIX(-like) platforms. Timezone names inside parentheses after GMT offset will not be 3-4 letter abbreviation any longer. They'll be human-readable names in the current default locale. This matches the current Windows behavior. new Date(2017, 5, 22).toString() new Date(2017, 11, 22).toString() Current: Thu Jun 22 2017 00:00:00 GMT-0700 (PDT) Fri Dec 22 2017 00:00:00 GMT-0800 (PST) New: Thu Jun 22 2017 00:00:00 GMT-0700 (Pacific Daylight Time) Fri Dec 22 2017 00:00:00 GMT-0800 (Pacific Standard Time) This CL will be followed by https://chromium-review.googlesource.com/c/v8/v8/+/572148 to implement tc39/ecma262#778 . [1] http://jungshik.github.io/v8/cr769706.html BUG=v8:6031, v8:2137, v8:6076, chromium:769706 TEST=mjsunit/icu-date-lord-howe.js, mjsunit/icu-date-to-string.js Change-Id: I22203670c3307a57fbf99e5f0a271dcbfbbef8fd Reviewed-on: https://chromium-review.googlesource.com/857333 Commit-Queue: Jungshik Shin <jshin@chromium.org> Reviewed-by: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/master@{#51791}
tc39/ecma262#778 was recently merged to Ecma 262. It changes the way to convert between "local time" and UTC in such a way that it'd work for all timezones whether or not there has been any change in the timezone offset of the standard time. For instance, Europe/Moscow and some parts of US state of Indiana have changed the standard (non-DST) timezone offset a few times. The previous spec assumes that the the standard timezone offset is constant, but the new spec take into account the offset change history. In addition, it specifies a new way to calculate the timezone offset during a timezone transition (either in and out of DST or timezone offset shift). During a negative transition (e.g. fall backward / getting out of DST), repeated times are to be interpreted as if the offset before the transition is in effect. During a positive transition (e.g. spring forward / getting into DST), skipped times are to be treated similarly. That is, they are to be interpreted as if the offset before the transition is in effect. With icu-timezone-data, v8 is compliant to the new spec for the past and the future as well as now whether or not the standard timezone offset of a given timezone has changed over time (e.g. Europe/Moscow, Pacific/Apia). With icu-timezone-data, Australia/Lord_Howe (30 minute DST change) also works per spec. Without icu-timezone-data, it works only for timezones of which the standard timezone offset is the same as the current offset (e.g. most North American timezones other than parts of Indiana) and of which the DST shift is an hour. For instance, it doesn't work for Europe/Moscow in 2010 when the standard timezone offset was +4h because the current (2018) standard timezone offset is +3h. Neither does it for Lord Howe in Australia with the DST shift of 0.5 hr. This CL used to require one of the two ICU CLs below, but not any more. https://chromium-review.googlesource.com/c/chromium/deps/icu/+/572652 https://chromium-review.googlesource.com/851265 (a proposed CL to the upstream ICU). Bug: v8:3547,chromium:417640,v8:5714 Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng Change-Id: Ib162295da5bee31b2390bd0918157014aebd3e33 Reviewed-on: https://chromium-review.googlesource.com/572148 Commit-Queue: Jungshik Shin <jshin@chromium.org> Reviewed-by: Daniel Ehrenberg <littledan@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/master@{#52332}
This reverts commit dbdede0. Reason for revert: Fails webkit_tests, blocks roll: https://build.chromium.org/p/client.v8.fyi/builders/V8-Blink%20Linux%2064 Original change's description: > Implement a new spec for timezone offset calculation > > tc39/ecma262#778 was recently merged > to Ecma 262. > > It changes the way to convert between "local time" and UTC in such > a way that it'd work for all timezones whether or not there has > been any change in the timezone offset of the standard time. For > instance, Europe/Moscow and some parts of US state of Indiana have > changed the standard (non-DST) timezone offset a few times. The > previous spec assumes that the the standard timezone offset is > constant, but the new spec take into account the offset change > history. > > In addition, it specifies a new way to calculate the timezone > offset during a timezone transition (either in and > out of DST or timezone offset shift). > > During a negative transition (e.g. fall backward / getting > out of DST), repeated times are to be interpreted as if the > offset before the transition is in effect. > > During a positive transition (e.g. spring forward / getting > into DST), skipped times are to be treated similarly. That > is, they are to be interpreted as if the offset before the > transition is in effect. > > With icu-timezone-data, v8 is compliant to the new spec for the > past and the future as well as now whether or not the standard > timezone offset of a given timezone has changed over time > (e.g. Europe/Moscow, Pacific/Apia). With icu-timezone-data, > Australia/Lord_Howe (30 minute DST change) also works per spec. > > Without icu-timezone-data, it works only for timezones of which > the standard timezone offset is the same as the current offset > (e.g. most North American timezones other than parts of Indiana) > and of which the DST shift is an hour. For instance, it doesn't work > for Europe/Moscow in 2010 when the standard timezone offset was > +4h because the current (2018) standard timezone offset is +3h. Neither > does it for Lord Howe in Australia with the DST shift of 0.5 hr. > > This CL used to require one of the two ICU CLs below, but not > any more. > > https://chromium-review.googlesource.com/c/chromium/deps/icu/+/572652 > https://chromium-review.googlesource.com/851265 (a proposed CL to the > upstream ICU). > > Bug: v8:3547,chromium:417640,v8:5714 > Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng > Change-Id: Ib162295da5bee31b2390bd0918157014aebd3e33 > Reviewed-on: https://chromium-review.googlesource.com/572148 > Commit-Queue: Jungshik Shin <jshin@chromium.org> > Reviewed-by: Daniel Ehrenberg <littledan@chromium.org> > Reviewed-by: Michael Lippautz <mlippautz@chromium.org> > Cr-Commit-Position: refs/heads/master@{#52332} TBR=adamk@chromium.org,littledan@chromium.org,mlippautz@chromium.org,jshin@chromium.org Change-Id: I6b3bf4427c761b106280d565a3912cd8e25cf87e No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:3547, chromium:417640, v8:5714 Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng Reviewed-on: https://chromium-review.googlesource.com/994192 Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#52338}
This is a reland of dbdede0 after a webkit layout test (geolocation-api/timestamp.html) was fixed by https://chromium-review.googlesource.com/c/chromium/src/+/994343 . Original change's description: > Implement a new spec for timezone offset calculation > > tc39/ecma262#778 was recently merged > to Ecma 262. > > It changes the way to convert between "local time" and UTC in such > a way that it'd work for all timezones whether or not there has > been any change in the timezone offset of the standard time. For > instance, Europe/Moscow and some parts of US state of Indiana have > changed the standard (non-DST) timezone offset a few times. The > previous spec assumes that the the standard timezone offset is > constant, but the new spec take into account the offset change > history. > > In addition, it specifies a new way to calculate the timezone > offset during a timezone transition (either in and > out of DST or timezone offset shift). > > During a negative transition (e.g. fall backward / getting > out of DST), repeated times are to be interpreted as if the > offset before the transition is in effect. > > During a positive transition (e.g. spring forward / getting > into DST), skipped times are to be treated similarly. That > is, they are to be interpreted as if the offset before the > transition is in effect. > > With icu-timezone-data, v8 is compliant to the new spec for the > past and the future as well as now whether or not the standard > timezone offset of a given timezone has changed over time > (e.g. Europe/Moscow, Pacific/Apia). With icu-timezone-data, > Australia/Lord_Howe (30 minute DST change) also works per spec. > > Without icu-timezone-data, it works only for timezones of which > the standard timezone offset is the same as the current offset > (e.g. most North American timezones other than parts of Indiana) > and of which the DST shift is an hour. For instance, it doesn't work > for Europe/Moscow in 2010 when the standard timezone offset was > +4h because the current (2018) standard timezone offset is +3h. Neither > does it for Lord Howe in Australia with the DST shift of 0.5 hr. > > This CL used to require one of the two ICU CLs below, but not > any more. > > https://chromium-review.googlesource.com/c/chromium/deps/icu/+/572652 > https://chromium-review.googlesource.com/851265 (a proposed CL to the > upstream ICU). > > Bug: v8:3547,chromium:417640,v8:5714 > Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng > Change-Id: Ib162295da5bee31b2390bd0918157014aebd3e33 > Reviewed-on: https://chromium-review.googlesource.com/572148 > Commit-Queue: Jungshik Shin <jshin@chromium.org> > Reviewed-by: Daniel Ehrenberg <littledan@chromium.org> > Reviewed-by: Michael Lippautz <mlippautz@chromium.org> > Cr-Commit-Position: refs/heads/master@{#52332} Bug: v8:3547, chromium:417640, v8:5714 Change-Id: I47536c111143f75e3cfeecf5d9761c43a98a10f5 Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng;master.tryserver.blink:linux_trusty_blink_rel Reviewed-on: https://chromium-review.googlesource.com/995971 Commit-Queue: Jungshik Shin <jshin@chromium.org> Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#52372}
Issues are raising as it became released on chrome 67. It is changing seconds in the time zones and does not get carried when converted to-and-back UTC. |
Not sure what you meant by that. Chrome 67 takes into account the historical time zone offset changes over time as recorded in the IANA time zone database. As explained by one of answers with heading 'Not a bug', some time zones underwent offset/DST changes multiple times even after 2010 (e.g. Europe/Moscow). In case of Sao Paolo, see https://www.timeanddate.com/time/zone/brazil/sao-paulo (select 1900-1924). It switched to UTC-3 from LMT in 1914. |
Yes, but if you read around the discussions you'll see the complaint is not really about the -3h or -3h06m (or other in other time zones), it is about a -3h06m28s or 54s. This is the most likely change in chrome that has introduced the above issue. Converting to-from UTC also results in a different result, e.g. the time converted back from UTC won't match the base time in a local1->UTC->local2 conversion chain. |
I'm not sure what you meant by the above:
|
https://chromium.googlesource.com/v8/v8.git/+log/9cf8abb7ce7e..ff6b34b468c1 This updates V8 to 6.8.44. There has been changes to how JS handles timezones. [1] Update the test expectations to match the new behavior, even though it deviates from Acrobat, which still has the old behavior. BUG=pdfium:1075 [1] tc39/ecma262#778 Change-Id: I63f0df9cd423ceee5b8d1008ba12a47ca84bbd6d Reviewed-on: https://pdfium-review.googlesource.com/41450 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Hi, is the following behavior, which seems to result from this spec change, expected?
As a user of the Date API, this is not really what I would have expected, also after carefully reading the docs. (I would have expected the getTime() return value to not change since minute was already 0.) (Sorry if this is the wrong place to ask this question.) |
First: see the intro to [0] for possibly better fora in which to make this enquiry. Just to be clear (I guess you already worked this out): The As the notes on I can understand why a user of this API would expect Not that the situation can't be salvaged: Incidental note (unrelated to this issue, noticed while reading the spec in hopes of getting the above right): the |
|
That Note was removed by the merge of PR #1965. |
The latest version of the standard, for reference: https://tc39.es/ecma262/#sec-timeclip |
Currently, LocalTimezoneAdjustment is assumed to be constant across time
zone rule changes and does not take any argument. Daylight Savings Time
Adjustment does take an argument t.
DSTA(t) can 'absorb' the standard time zone offset changes
(e.g. Europe/Moscow changed the standard time zone offset multiple times
in the last decade.). However, the spec stipulates that it should only
reprsent an additional adjustment necessary when DST is in effect.
In practice, at least two implementations (Spidermonkey/Firefox and
JSC/Safari) do not follow the spec to the letter to produce results
expected by users across time zone rule changes.
This PR revises LocalTZA to accept two arguments, 't' and 'isUTC' and
drop DaylightSavingsTimeAdjustment(t). When isUTC is true, LocalTZA
interprets 't' as a time value representing UTC and gives a time zone
offset in effect at time t for the local time zone (for US ET, it'd be
-4*msPerHour
in summer and-5*msPerHour
in winter). When isUTC is false,'t' is interpreted as local time value and gives a time zone offset in
effect at t = t_local.
It's also specified that LocalTZA(t = t_local, false) will return the offset
before the transition when t_local is local time repeating multiple
times at a negative transition (e.g. fall backward) or skipped local time
at a positive time zone transition (e.g. spring forward).
Currently, implementations do not agree with each other as to how to handle repeating
or skipped local time. This change will standardize the behavior in line with the way Java 8 does.
Finally, UTC(t) and Localtime(t) are reformulated with LocalTZA(t = t_local, false) and
LocalTZA(t = t_UTC, true).
Will fix #725.