win: Don't assume offsets the same when kDoesNotObserveDaylightSavingTime

kDoesNotObserveDaylightSavingTime can indicate only that the
standard/daylight transition is not automatic, as opposed to it not
existing at all.

Bug: crashpad:214
Change-Id: Ib7016806e79465a6dde605dd667b75a802e1b6c5
Reviewed-on: https://chromium-review.googlesource.com/904767
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Scott Graham 2018-02-06 11:34:20 -08:00 committed by Commit Bot
parent 6cf4f928eb
commit 36679d572b

View File

@ -134,22 +134,24 @@ TEST_F(SystemSnapshotWinTest, TimeZone) {
EXPECT_EQ(standard_offset_seconds % (15 * 60), 0)
<< "standard_offset_seconds " << standard_offset_seconds;
if (dst_status == SystemSnapshot::kDoesNotObserveDaylightSavingTime) {
EXPECT_EQ(daylight_offset_seconds, standard_offset_seconds);
EXPECT_EQ(daylight_name, standard_name);
} else {
EXPECT_EQ(daylight_offset_seconds % (15 * 60), 0)
<< "daylight_offset_seconds " << daylight_offset_seconds;
// dst_status of kDoesNotObserveDaylightSavingTime can mean only that the
// adjustment is not automatic, as opposed to daylight/standard differences
// not existing at all. So it cannot be asserted that the two offsets are the
// same in that case.
// In contemporary usage, dst_delta_seconds will almost always be one hour,
// except for Lord Howe Island, Australia, which uses a 30-minute delta.
// Throughout history, other variations existed. See
// https://www.timeanddate.com/time/dst/.
int dst_delta_seconds = daylight_offset_seconds - standard_offset_seconds;
if (dst_delta_seconds != 60 * 60 && dst_delta_seconds != 30 * 60) {
FAIL() << "dst_delta_seconds " << dst_delta_seconds;
}
EXPECT_EQ(daylight_offset_seconds % (15 * 60), 0)
<< "daylight_offset_seconds " << daylight_offset_seconds;
// In contemporary usage, dst_delta_seconds will almost always be one hour,
// except for Lord Howe Island, Australia, which uses a 30-minute delta.
// Throughout history, other variations existed. See
// https://www.timeanddate.com/time/dst/.
int dst_delta_seconds = daylight_offset_seconds - standard_offset_seconds;
if (dst_delta_seconds != 60 * 60 && dst_delta_seconds != 30 * 60) {
FAIL() << "dst_delta_seconds " << dst_delta_seconds;
}
if (dst_status != SystemSnapshot::kDoesNotObserveDaylightSavingTime) {
EXPECT_NE(standard_name, daylight_name);
}
}