Bug 54480 - TimeZoneInfo adjustment rules incorrect for some zones
Summary: TimeZoneInfo adjustment rules incorrect for some zones
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib (show other bugs)
Version: 4.8.0 (C9)
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2017-04-05 09:34 UTC by Jon Skeet
Modified: 2017-11-01 20:27 UTC (History)
3 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:

Program demonstrating the issue (1.61 KB, text/x-csharp)
2017-04-05 09:34 UTC, Jon Skeet

Description Jon Skeet 2017-04-05 09:34:17 UTC
Created attachment 21199 [details]
Program demonstrating the issue

Version 4.8.0 running on Ubuntu 16.04

(Discovered when validating Noda Time behaviour.)

The adjustment rules returned by TimeZoneInfo.GetAdjustmentRules() don't correctly describe the zone it's called on in all cases. The attached program demonstrates this using Africa/Tunis.

Portions of the output:

Rule for 1940/1941:

[1940-01-01 - 1941-1231]; Delta: 01:00:00
  DST start: Month: 2; Week: 1; Day: 25; DoW: Sunday; Time: 23:00; Fixed? True
  DST end: Month: 10; Week: 1; Day: 6; DoW: Sunday; Time: 00:00; Fixed? True

Output with the fetched TimeZoneInfo:
1940-10-05T21:00: 02:00:00
1940-10-05T22:00: 02:00:00
1940-10-05T23:00: 02:00:00

Output with a TimeZoneInfo created from the rules returned by TimeZoneInfo.GetAdjustmentRules:
1940-10-05T21:00: 02:00:00
1940-10-05T22:00: 01:00:00
1940-10-05T23:00: 01:00:00

The latter output is correct for the rules returned - it's the rules that are wrong.

The transitions for Tunis should look like this:

1940-02-25 22:00:00Z +02:00:00 daylight CEST
1941-10-05 22:00:00Z +01:00:00 standard CET

So Tunis was in DST from 1940-02-25 until 1941-10-05 - DST *didn't end* in 1940, contrary to the rule.

I would suggest a test that looks through every system time zone and recreates it from itself with the rules it advertises, then checks the offset for, say, one day per week for all years 1900-2100. That would at least be a good smoke test.

Note You need to log in before you can comment on or make changes to this bug.