Bug 29959 - TimeZone.ConvertTimeToUtc makes wrong conversion
Summary: TimeZone.ConvertTimeToUtc makes wrong conversion
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 3.12.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-05-11 18:53 UTC by Sergey Zhukov
Modified: 2015-05-12 08:17 UTC (History)
2 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Sergey Zhukov 2015-05-11 18:53:29 UTC
For Russian timezones timezones e. g. `Asia/Novosibirsk` `TimeZoneInfo.ConvertTimeToUtc()` produces wrong results for some dates. See the sample code:

            var utcDate = new DateTime(2010, 05, 10, 18, 00, 00, DateTimeKind.Utc);
            var test1 = utcDate.ToLocalTime().ToUniversalTime();
            var test2 = TimeZoneInfo.ConvertTimeToUtc(utcDate.ToLocalTime());

            Console.WriteLine("utc={0}, test1={1}, test2={2}", utcDate, test1, test2);

Output: 

utc=5/10/2010 6:00:00 PM, test1=5/10/2010 6:00:00 PM, test2=5/10/2010 7:00:00 PM

OS: Ubuntu Linux 12.04

Mono JIT compiler version 3.12.1 (tarball Fri Mar  6 19:14:08 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  x86
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen
Comment 1 Sergey Zhukov 2015-05-11 19:35:20 UTC
Works on mono-20150511140237 snapshot, so issue is only on mono 3.12

Output: 

utc=5/10/2010 6:00:00 PM, test1=5/10/2010 6:00:00 PM, test2=5/10/2010 6:00:00 PM


Mono JIT compiler version 4.1.0 (tarball Mon May 11 15:45:43 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  x86
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen
Comment 2 Marek Safar 2015-05-12 07:19:46 UTC
The issue should be also fixed in Mono 4
Comment 3 Sergey Zhukov 2015-05-12 08:13:44 UTC
What about 3.12? Will the fix be merged into 3.12 branch? Or 3.12 is a dead branch and there will be no future bug fixes merged into it?
Comment 4 Marek Safar 2015-05-12 08:17:24 UTC
4.0 is major line now. I don't think 3.12 will get any functional fixes