kriskowal / zip

An implementation of unzip in JavaScript for Node
MIT License
85 stars 28 forks source link

zip file_mod date time to JavaScript Date #6

Closed jdarling closed 12 years ago

jdarling commented 12 years ago

Here is some code you could add to decode the file_mod date and time components back into JavaScript Date object. Tested to work with all dates after 1980 due to zip encoding.

var decodeZipDateTime = function(date, time){ var year = (date>>>9)+1980, month = ((date>>>5)&15)-1, day = (date)&31, hours = (time>>>11)&31, minutes = (time>>>5)&63, seconds = (time&63)*2; return { year: year, month: month, day: day, hours: hours, minutes: minutes, seconds: seconds, date: new Date(year, month, day, hours, minutes, seconds) }; }

kriskowal commented 12 years ago

Neat! Thanks.

kriskowal commented 12 years ago

Integrated as entry.lastModified()