Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Archive::Zip Modify Date Oddity

by lhchin (Novice)
on Jan 03, 2017 at 09:29 UTC ( #1178835=perlquestion: print w/replies, xml ) Need Help??

lhchin has asked for the wisdom of the Perl Monks concerning the following question:

use Archive::Zip; my $zip = Archive::Zip->new(); $zip->addFile($0,'test.txt'); $zip->writeToFileNamed('');

Save the above code as and run the following command and grep original and post zip Modify date to compare.
Perl Library Zipped file extracted is always 1 second behind original modify file? Is this a bug with the library???

stat | grep Modify && perl && unzip && stat test.txt| grep Modify && rm test.*


Modify: 2017-01-03 01:15:55.000000000 -0800
inflating: test.txt
Modify: 2017-01-03 01:15:54.000000000 -0800

Replies are listed 'Best First'.
Re: Archive::Zip Modify Date Oddity
by Corion (Pope) on Jan 03, 2017 at 09:32 UTC

    The Zip (file format) uses FAT timestamps which only have a resolution of two seconds.

      Thank you for sharing the info. If this is to mimic windows time stamp, it is not desirable. Further test verified it does round down the original file Modify date to lower even-seconds.
      It is not the case when tested using Windows GUI or Unix Shell from Perl to zip file, it does not modify the original Modify date of the file.
      As such I have submitted an enhancement request to the Archive::Zip Library in for ZIP64 support for higher-resolution NTFS or Unix file timestamps

        Zip64 support doesn't have anything to do with the granularity of the timestamp recorded in the zip file. It just allows file larger than 4Gig to be stored in a zip archive.

        The two second time granularity is dealt with in modern zip implementations by storing an extended timestamp field.

        Archive::Zip::SimpleZip supports this field.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1178835]
Approved by haukex
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2021-06-15 11:02 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (70 votes). Check out past polls.