Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Issue 1845483002: Fix core lib DateTime in the VM. (Closed)

Created:
4 years, 8 months ago by regis
Modified:
4 years, 8 months ago
Reviewers:
rmacnak, floitsch
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Base URL:
git@github.com:dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Fix core lib DateTime in the VM (fixes #19923). Symptom of the problem: Set your Linux workstation (or Mac or MIPS board) to the Europe/London timezone and the corelib/date_time test will fail, claiming that 1/1/1970 was a Wednesday (it was actually a Thursday, trust me, I was already born). Problem: The implementation of DateTime in the VM relies on Unix time_t, the number of seconds since the Epoch (1/1/1970 UTC). When asked for the weekday of a given time, our implementation limits itself to a 32-bit positive range of time_t. If the time falls outside of this range, the implementation picks an equivalent time in the valid range with the same weekday, also in leap year or not, etc... The issue is that DateTime is using the underlying OS in an inconsistent manner. Let's take the example above: 1/1/1970 in the Europe/London timezone. First, the number of seconds since the Epoch in UTC is calculated, here 0. Then, the timezone offset at the given time is calculated using the underlying OS. In this case, an historical deviation is taken into account. Indeed, London stayed on British Summer Time between 27 October 1968 and 31 October 1971. See https://en.wikipedia.org/wiki/British_Summer_Time#Periods_of_deviation for details. Our resulting time is therefore negative (one hour difference with UTC). When asked about the weekday of this time, the implementation notices that the time is not in the positive range and picks an "equivalent" time in the future. It then asks the underlying OS about the timezone offset for this time, which is 0 (usually no daylight saving time in January in London). Unfortunately, this time is not really equivalent, because it ignores the original historical deviation. The result is wrongly equivalent to 12/31/1969 23:00 in London, i.e. a Wednesday, and not a Thursday as expected. Solution: We should use the underlying OS in a consistent way, by simply allowing the value of time_t passed to the underlying OS to be negative, which is legal. R=floitsch@google.com, rmacnak@google.com Committed: https://github.com/dart-lang/sdk/commit/48dc7903980e728e6e88b3588714be49c62f5a91

Patch Set 1 #

Total comments: 6

Patch Set 2 : clarify comment #

Patch Set 3 : adress comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+31 lines, -13 lines) Patch
M CHANGELOG.md View 1 2 1 chunk +5 lines, -0 lines 0 comments Download
M runtime/lib/date.cc View 1 2 2 chunks +3 lines, -3 lines 0 comments Download
M runtime/lib/date_patch.dart View 1 3 chunks +23 lines, -10 lines 0 comments Download

Messages

Total messages: 9 (3 generated)
regis
4 years, 8 months ago (2016-03-30 00:37:03 UTC) #2
floitsch
Thanks for doing this! I have often tried to figure out if time_t could be ...
4 years, 8 months ago (2016-03-30 16:01:32 UTC) #3
floitsch
On 2016/03/30 16:01:32, floitsch wrote: > Thanks for doing this! > I have often tried ...
4 years, 8 months ago (2016-03-30 16:03:05 UTC) #4
rmacnak
lgtm w/ 64-bit comparison https://codereview.chromium.org/1845483002/diff/1/runtime/lib/date.cc File runtime/lib/date.cc (right): https://codereview.chromium.org/1845483002/diff/1/runtime/lib/date.cc#newcode15 runtime/lib/date.cc:15: static int32_t kMaxAllowedSeconds = kMaxInt32; ...
4 years, 8 months ago (2016-03-30 16:41:53 UTC) #6
regis
Thank you both! I was not aware of issue 19923. I commented on it and ...
4 years, 8 months ago (2016-03-30 17:09:36 UTC) #7
regis
4 years, 8 months ago (2016-03-30 17:10:03 UTC) #9
Message was sent while issue was closed.
Committed patchset #3 (id:40001) manually as
48dc7903980e728e6e88b3588714be49c62f5a91 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698