[Mono-bugs] [Bug 80320][Nor] New - DateTime.MinValue.ToLocalTime() with a negative UTC offset throws out of range exception

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Dec 19 19:20:57 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by joeshaw at novell.com.

http://bugzilla.ximian.com/show_bug.cgi?id=80320

--- shadow/80320	2006-12-19 19:20:57.000000000 -0500
+++ shadow/80320.tmp.23068	2006-12-19 19:20:57.000000000 -0500
@@ -0,0 +1,44 @@
+Bug#: 80320
+Product: Mono: Class Libraries
+Version: 1.2
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: joeshaw at novell.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: DateTime.MinValue.ToLocalTime() with a negative UTC offset throws out of range exception
+
+According to msdn's docs for DateTime.ToLocalTime():
+
+A DateTime object whose Kind property is Local, and whose value is the
+local time equivalent to the value of the current DateTime object, or
+MaxValue if the converted value is too large to be represented by a
+DateTime object, or MinValue if the converted value is too small to be
+represented as a DateTime object.
+
+(http://msdn2.microsoft.com/en-us/library/system.datetime.tolocaltime.aspx)
+
+However, if you evaluate DateTime.MinValue.ToLocalTime() on Mono (1.2.2.1)
+in a time zone that has a negative UTC offset, you get an out of range
+exception:
+
+System.ArgumentOutOfRangeException: Argument is out of range.
+  at System.DateTime.AddTicks (Int64 t) [0x00000]
+  at System.DateTime.Add (TimeSpan ts) [0x00000]
+  at System.TimeZone.ToLocalTime (DateTime time) [0x00000]
+  at System.DateTime.ToLocalTime () [0x00000]
+  at Input13Module.Main (System.String[] argv) [0x00000]
+
+I suspect you would also get one if you called
+DateTime.MinValue.ToUniversalTime() in a time zone with a positive UTC offset.
+
+Running DateTime.MaxValue.ToUniversalTime() in a negative UTC offsetted
+timezone works fine.


More information about the mono-bugs mailing list