[Mono-bugs] [Bug 60970][Wis] New - FileInfo.LastWriteTime fails for dates older thatn 1970

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 1 Jul 2004 05:48:35 -0400 (EDT)


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 ianm@activestate.com.

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

--- shadow/60970	2004-07-01 05:48:35.000000000 -0400
+++ shadow/60970.tmp.27455	2004-07-01 05:48:35.000000000 -0400
@@ -0,0 +1,64 @@
+Bug#: 60970
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: ianm@activestate.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: FileInfo.LastWriteTime fails for dates older thatn 1970
+
+Description of Problem:
+using FileInfo.LastWriteTime to set the last write time gives bogus results
+for dates of 01/01/1970 09:00:00 or earlier. Instead of setting to that
+date it cycles to 2037
+
+Steps to reproduce the problem:
+1. Run the following code:
+          string path = "afile"; 
+            string dateString="01/01/1970 08:01:00";
+                 
+            DateTime touchDateTime = DateTime.Parse(dateString,
+CultureInfo.InvariantCulture);
+            Console.WriteLine("Touch DateTime is {0}", touchDateTime);
+                    
+            System.IO.File.SetLastWriteTime(path, touchDateTime);          
+            
+            FileInfo file = new FileInfo(path);
+            DateTime lastTouchDate = file.LastWriteTime;           
+                
+            Console.WriteLine("Touch DateTime is {0}",
+lastTouchDate.ToString() );
+            
+            if ( ! touchDateTime.Equals(lastTouchDate) ) {
+                Console.WriteLine("Date is wrong! new date is {0} but file
+date is {1}", touchDateTime.ToString(), lastTouchDate.ToString());
+            }
+
+Actual Results:
+Touch DateTime is 1/1/1970 8:01:00 AM
+File  DateTime is 8/9/2037 9:30:46 PM
+Date is wrong! new date is 1/1/1970 8:01:00 AM but file date is 8/9/2037
+9:30:46 PM
+
+Expected Results:
+
+Touch DateTime is 1/1/1970 8:01:00 AM
+File  DateTime is 1/1/1970 8:01:00 AM
+
+How often does this happen? 
+Consistently.
+
+Additional Information:
+- This is a bit of a weird one since you don't often need to set LastWrite
+time to somthing that old anyway. Interestingly on ms.net doing the same
+thing gives a System.IO exception 'The paramater is incorrect' for any date
+value before 1980. Guess setting things to old dates isn't a good idea.