Bug 54480 - TimeZoneInfo adjustment rules incorrect for some zones
Summary: TimeZoneInfo adjustment rules incorrect for some zones
Status: CONFIRMED
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
URL:
Depends on:
Blocks:
 
Reported: 2017-04-05 09:34 UTC by Jon Skeet
Modified: 2018-05-16 02:17 UTC (History)
4 users (show)

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


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


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 54480 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

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.
Comment 1 Katelyn Gadd 2018-05-16 02:17:38 UTC
Can confirm this is still broken for the latest rev on Ubuntu. I can't test this on Windows .NET Framework since it seems to not support any of the time zone IDs we support.