in reply to Re^5: Archive::Zip Modify Date Oddity
in thread Archive::Zip Modify Date Oddity

use IO::Compress::Zip qw(zip $ZipError); my $zip = zip [$0] => 'test.zip', Name => 'test.txt', exTime => [$atime, $mtime, $ctime] or die;
Well, it still does not retain the original modified date of the file, losing the seconds resolution. Not sure if this is correct, perhaps someone could share and prove that the original modified date can be retained.
Keeping things simple, Perl shell execution Zip doesn't require much setting to retain the original modified date.

Replies are listed 'Best First'.
Re^7: Archive::Zip Modify Date Oddity
by pmqs (Friar) on Jan 06, 2017 at 16:20 UTC

    You don't need the exTime option - when you give the "zip" sub a filename (or list of filenames) it automatically gets the timestamps.

    use IO::Compress::Zip qw(zip $ZipError); zip [$0] => 'test.zip', Name => 'test.txt' or die "Cannot zip: $ZipError\n";
      Could you kindly test by "stat" of the file you are zipping and after zipping, unzip the file and "stat" the modified date? It was definitely not retained for me.

        Sure. Starting with a file where the seconds field of the modification time is an odd number.

        $ stat abc | grep Mod Modify: 2017-01-09 15:41:05.405778746 +0000

        Now add that file into a zip archive.

        $ perl -M'IO::Compress::Zip qw(zip)' -e ' zip "abc" => "abc.zip" '

        unzip in a different directory

        $ cd out $ unzip ../abc.zip

        And stat the uncompressed file

        $ stat abc | grep Mod Modify: 2017-01-09 15:41:05.000000000 +0000