[
  {
    "Id": "223101",
    "ThreadId": "65509",
    "Html": "<p>Hello!</p>\r\n<p>I noticed that timestamps for zimEntries in my ZipFile instance are not correct. Here is the code I am using to zip a directory:</p>\r\n<p><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">&lt;font size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;\r\n<p>using</p>\r\n&lt;/font&gt;&lt;/font&gt;</span>&lt;font size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;\r\n<p>&nbsp;</p>\r\n&lt;/font&gt;</span>\r\n<p><span style=\"font-size:x-small\">(</span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">ZipFile</span></span><span style=\"font-size:x-small\"> zip = </span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">new</span></span><span style=\"font-size:x-small\"> </span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">ZipFile</span></span><span style=\"font-size:x-small\">())</span></p>\r\n<p>{<span style=\"font-size:x-small\">&nbsp;</span></p>\r\n<p><span style=\"font-size:x-small\">&nbsp;&nbsp;&nbsp; zip.AddDirectory(path);</span></p>\r\n<p>&nbsp;&nbsp; <span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">&nbsp;MemoryStream</span></span><span style=\"font-size:x-small\"> memoryStream = </span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">new</span></span><span style=\"font-size:x-small\"> </span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">MemoryStream</span></span><span style=\"font-size:x-small\">();</span></p>\r\n<p><span style=\"color:#008000\">}</span></p>\r\n<p><span style=\"color:#000000\">in the debugger, I can see the timestamp values for one of the Entries that look like this: </span></p>\r\n</p>\r\n<p><span style=\"color:#000000\">Ctime&nbsp;{8/13/2009 7:47:36 PM}&nbsp;System.DateTime</span></p>\r\n<p><span style=\"color:#000000\">LastModified&nbsp;{8/13/2009 3:47:36 PM}&nbsp;System.DateTime</span></p>\r\n<p><span style=\"color:#000000\">Mtime&nbsp;{8/13/2009 7:47:36 PM}&nbsp;System.DateTime</span></p>\r\n<p><span style=\"color:#000000\">Only the LastModified field has the timestamp that is close to the actual timestamp of the file. It is not clear to me why Mtime and Ctime are shifted by 4 hrs? Also the timestamp for LastModified seems to be rounded and doesn't exactly match the timestamp of the file. So, the comparison of timestamps will not work properly. </span></p>\r\n<p><span style=\"color:#000000\">Does anyone have any suggestion on how to work around this issue?</span></p>\r\n<p><span style=\"color:#000000\">Thanks,</span></p>\r\n<p><span style=\"color:#000000\">Norton.</span><span style=\"color:#000000\"></span></p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-08-13T13:19:37.907-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "223112",
    "ThreadId": "65509",
    "Html": "<p>This is my favorite topic!</p>\r\n<p>I kid.&nbsp; It's been very tricky for me to get the timestamps to work properly.</p>\r\n<p>But your problem is simple.&nbsp; LastModified is expressed in LocalTime, while Ctime and Mtime are in UTC.&nbsp; They are all the same point in time.&nbsp;</p>\r\n<p>The rounding is a side effect of the way the zip format stores timestamps.&nbsp; If you want to compare LastModified to another time, you'll need to compare the delta.&nbsp; In other words, subtract the time on the file from another time, and then compare that difference (which is a TimeSpan) to a fixed TimeSpan.&nbsp;&nbsp;If you are using the LastModified time, the precision is 2 seconds, so you will need to compare to a TimeSpan of 2 seconds.&nbsp;</p>\r\n<p>If you use Mtime or Ctime, then the comparison is exact.&nbsp; These numbers are stored differently in the zip file, stored with the full precision of the&nbsp;NTFS filesystem.&nbsp; But if the zip file was created on a non-NTFS system, then you probably have to revert to the delta approach again.&nbsp; It's safest to just use the delta approach in all cases.</p>\r\n<p>Check the doc on these properties for more info. &nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-08-13T13:57:08.167-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "223564",
    "ThreadId": "65509",
    "Html": "\r\n<div><span class=211501016-14082009>Thank you very much for your \r\nresponse, it was very helpful!</span></div><br>\r\n<div class=OutlookMessageHeader lang=en-us dir=ltr align=left>\r\n<hr>\r\n<b>From:</b> Cheeso [mailto:notifications@codeplex.com] \r\n<br><b>Sent:</b> Thursday, August 13, 2009 4:57 PM<br><b>To:</b> Akopov, Sergei \r\n(GE EntSol, Intelligent Platforms)<br><b>Subject:</b> Re: Timestamp Issues \r\n[DotNetZip:65509]<br><br></div>\r\n<div></div>\r\n\r\n\r\n<p>From: Cheeso</p>\r\n<div id=ThreadNotificationPostBody>\r\n<p>This is my favorite topic!</p>\r\n<p>I kid.  It's been very tricky for me to get the timestamps to work \r\nproperly.</p>\r\n<p>But your problem is simple.  LastModified is expressed in LocalTime, \r\nwhile Ctime and Mtime are in UTC.  They are all the same point in \r\ntime. </p>\r\n<p>The rounding is a side effect of the way the zip format stores \r\ntimestamps.  If you want to compare LastModified to another time, you'll \r\nneed to compare the delta.  In other words, subtract the time on the file \r\nfrom another time, and then compare that difference (which is a TimeSpan) to a \r\nfixed TimeSpan.  If you are using the LastModified time, the precision \r\nis 2 seconds, so you will need to compare to a TimeSpan of 2 seconds. </p>\r\n<p>If you use Mtime or Ctime, then the comparison is exact.  These numbers \r\nare stored differently in the zip file, stored with the full precision of \r\nthe NTFS filesystem.  But if the zip file was created on a non-NTFS \r\nsystem, then you probably have to revert to the delta approach again.  It's \r\nsafest to just use the delta approach in all cases.</p>\r\n<p>Check the doc on these properties for more info.  </p>\r\n<p> </p></div>\r\n",
    "PostedDate": "2009-08-14T09:11:41.133-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]