[Mono-bugs] [Bug 345057] New: DateTime unspecified-to-localtime conversions different between mono and . net
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Thu Nov 29 16:37:01 EST 2007
https://bugzilla.novell.com/show_bug.cgi?id=345057
Summary: DateTime unspecified-to-localtime conversions different
between mono and .net
Product: Mono: Class Libraries
Version: 1.2.5
Platform: x86
OS/Version: Ubuntu
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Sys.Core
AssignedTo: mono-bugs at ximian.com
ReportedBy: apenwarr at versabanq.com
QAContact: mono-bugs at ximian.com
Found By: Development
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.
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
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list