Bug 2167 - Moscow timezone issue
Summary: Moscow timezone issue
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 2.10.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: marcos.henrich
: 1337 ()
Depends on:
Reported: 2011-11-23 06:29 UTC by Oleg Stepanischev
Modified: 2016-02-15 17:27 UTC (History)
5 users (show)

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

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 on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Oleg Stepanischev 2011-11-23 06:29:09 UTC
Before 2011 year Moscow had +3 GMT timezone with daylight saving time, so it was +4 GMT between March and October. In 2011 October return to +3 GMT was cancelled, so it's +4 GMT from March 2011 permanently. In applications using Mono and MonoTouch Moscow time handled incorrectly. For example, DateTime.Now.ToString() returns time less by hour.
After discovering how Mono detects current system daylight saving periods I found that it uses System.CurrentSystemTimeZone.GetTimeZoneData method. For Moscow timezone and 2011 year it returns (634367880000000000, 0, 108000000000, 36000000000). So daylight saving starts at 27 March 2011 and don't have end. But System.CurrentSystemTimeZone.IsDaylightSavingTime method cannot handle DaylightTime without end. It always returns false.

Adding this to end of System.CurrentSystemTimeZone.IsDaylightSavingTime can solve the problem:

if (daylightTimes.End.Ticks == 0 && time.Ticks > daylightTimes.Start.Ticks)
	return true;

So it will correctly return true for date after 27 March 2011.

Or maybe System.CurrentSystemTimeZone.GetTimeZoneData should return end of year instead of 0.
Comment 1 Jeffrey Stedfast 2011-12-09 12:07:43 UTC
I think this is solved by the patch in bug #2223

If someone can confirm, I can get this patch pushed into MonoTouch/MonoDroid
Comment 2 Jeffrey Stedfast 2011-12-09 12:10:50 UTC
*** Bug 1337 has been marked as a duplicate of this bug. ***
Comment 3 marcos.henrich 2016-02-15 17:27:39 UTC
This issue no longer exists in mono 4.2.