Touffy / client-zip

A client-side streaming ZIP generator
MIT License
351 stars 22 forks source link

MacOS Date Modified is incorrect and years in the future or the past #2

Closed duttonkj closed 4 years ago

duttonkj commented 4 years ago

Thanks for the great package! It's lightning fast and super reliable.

We have installed in our app and during QC and noticed the following issue. Date Modified is showing some wild dates:

image

I have attempted to set the lastModified property with new Date() but it still has issues:

image

Touffy commented 4 years ago

Oh dear. I couldn't find proper documentation on the DOS date/time format used by ZIP (especially the byte order which I may have gotten completely wrong). I'll look into it more.

Just in case, have you checked the date on your original resources (Last-Modified header for Responses, or lastModified property on Files) ?

duttonkj commented 4 years ago

Yes, we are using Cloudfront to serve images and it provides a Last-Modified header.

Touffy commented 4 years ago

OK, I had indeed reversed the date and time and their endianness. It appears also that I was misled into the common misconception that a DOS datetime should be based on UTC (I see that JSZip and some Node.js libs do it). … It's not. It's "local time". So… I guess I'll just use the client's timezone, that way when they unzip the archive to their more modern filesystem, their zip program will resolve the time based on the same timezone and it'll cancel out. Tested on my macOS.

It means that different clients (living in different timezones) will get different dates in their ZIP files. Cool, huh ?

duttonkj commented 4 years ago

Thanks for the quick fix. That works for our use case

Touffy commented 4 years ago

You're welcome. Thank you for using client-zip and getting me to finally dive into this issue and get it right (I think — I really hope that using the client's timezone will work for everyone).

mfrobben commented 4 years ago

Thank you!