Merge pull request #3076 from akoeplinger/fix-ziptime-offbyone
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Tue, 31 May 2016 14:06:41 +0000 (16:06 +0200)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Tue, 31 May 2016 14:06:41 +0000 (16:06 +0200)
[WindowsBase] Fix off-by-one error in ZipTime

mcs/class/WindowsBase/Test/System.IO.Packaging/PackageTest.cs
mcs/class/WindowsBase/ZipSharp/ZipTime.cs

index d4867c936b18c606ac3db1f5ae928fb6e8225d65..9a1aa2ea4fb7006c4dae06c4b1b1a4bea1a2d3b6 100644 (file)
@@ -432,7 +432,11 @@ namespace MonoTests.System.IO.Packaging {
             using (var archive = new ZipArchive(stream))\r
             {                \r
                 foreach (var entry in archive.Entries)\r
+                {\r
                     Assert.AreEqual (DateTime.Now.Year, entry.LastWriteTime.Year);\r
+                    Assert.AreEqual (DateTime.Now.Month, entry.LastWriteTime.Month);\r
+                    Assert.AreEqual (DateTime.Now.Day, entry.LastWriteTime.Day);\r
+                }\r
             }\r
         }           \r
     }\r
index 2736df9410d31eafd67219677f04fbe3f186166c..e2c3abb66ca539a39524f6c8f9406f9b83755020 100644 (file)
@@ -25,13 +25,13 @@ namespace zipsharp
                        minute = (uint) time.Minute;
                        hour = (uint) time.Hour;
                        day = (uint) time.Day;
-                       month = (uint) time.Month;
+                       month = (uint) time.Month - 1;
                        year = (uint) time.Year;
                }
 
                public DateTime Date
                {
-                       get { return new DateTime ((int) year, (int) month, (int) day, (int) hour, (int) minute, (int) second); }
+                       get { return new DateTime ((int) year, (int) month + 1, (int) day, (int) hour, (int) minute, (int) second); }
                }
        }
 }