[Mono-dev] DateTime unspecified-to-localtime conversions different between mono and .net

Atsushi Eno atsushi at ximian.com
Thu Nov 29 16:06:20 EST 2007


Hello,

Avery Pennarun wrote:
> Hi all,
> 
> I tried the following program in Microsoft .NET 2.0 and 3.5 (same
> results both times) and mono 1.2.3 and 1.2.5 (same results both
> times).
> 
> I see two main differences here:
> 
> 1) Dates after the Y2.038k bug in 2038 do not calculate daylight
> savings time correctly.
> 
> 2) DateTime.Parse in .NET seems to return a timezone-unspecified
> DateTime, such that converting it ToLocalTime() or ToUniversalTime()
> will always change the timestamp in one direction or the other.  In
> mono, it seems to be a timezone-localtime DateTime, so that
> ToLocalTime() has no effect.
> 
> Should I file a bug with this?  I've heard of people having trouble

I'm not sure what the daylight saving time issue is but for this
questoin, the answer is yes :)

> signing up for the new bugzilla, is that fixed?

When it works for you, it should not be a real issue.

Atsushi Eno

> Thanks,
> 
> Avery
> 
> 
> 
> Source code:
> 
>  using System;
> 
>  public static class Test
>  {
>     public static void test(DateTime dt)
>     {
> 	System.Console.WriteLine("{0} -- {1}",
> 		 dt.ToLocalTime(), dt.ToUniversalTime());
> 	System.Console.WriteLine("   {0} -- {1} -- {2}",
> 		 dt.Ticks, dt.ToLocalTime().Ticks, dt.ToUniversalTime().Ticks);
>     }
> 
>     public static void Main()
>     {
> 	test(DateTime.Parse("2007-09-27 5:14:14"));
> 	test(DateTime.Parse("2007-11-27 5:14:14"));
> 	test(DateTime.Parse("2039-09-27 5:14:14"));
> 	test(DateTime.Parse("2039-11-27 5:14:14"));
> 	test(DateTime.Parse("0001-01-01 10:01:02"));
>     }
>  }
> 
> 
> Results in .NET:
> 
> 9-27-2007 1:14:14 AM -- 9-27-2007 9:14:14 AM
>    633264668540000000 -- 633264524540000000 -- 633264812540000000
> 11-27-2007 12:14:14 AM -- 11-27-2007 10:14:14 AM
>    633317372540000000 -- 633317192540000000 -- 633317552540000000
> 9-27-2039 1:14:14 AM -- 9-27-2039 9:14:14 AM
>    643363100540000000 -- 643362956540000000 -- 643363244540000000
> 11-27-2039 12:14:14 AM -- 11-27-2039 10:14:14 AM
>    643415804540000000 -- 643415624540000000 -- 643415984540000000
> 1-1-0001 5:01:02 AM -- 1-1-0001 3:01:02 PM
>    360620000000 -- 180620000000 -- 540620000000
> 
> 
> Results in mono:
> 
> 27/09/2007 5:14:14 AM -- 27/09/2007 9:14:14 AM
>    633264668540000000 -- 633264668540000000 -- 633264812540000000
> 27/11/2007 5:14:14 AM -- 27/11/2007 10:14:14 AM
>    633317372540000000 -- 633317372540000000 -- 633317552540000000
> 27/09/2039 5:14:14 AM -- 27/09/2039 10:14:14 AM
>    643363100540000000 -- 643363100540000000 -- 643363280540000000
> 27/11/2039 5:14:14 AM -- 27/11/2039 10:14:14 AM
>    643415804540000000 -- 643415804540000000 -- 643415984540000000
> 01/01/0001 10:01:02 AM -- 01/01/0001 3:01:02 PM
>    360620000000 -- 360620000000 -- 540620000000
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 





More information about the Mono-devel-list mailing list