Skip to content

Setting last modified year to older than 1980 produces unexpected results #70

@mdcarson

Description

@mdcarson

I'm new to the developer role, please forgive me if I ask questions where the answers may seem obvious.

I'm using gulp-zip, which depends on yazl, and I'm including a modifiedTime option. I need to match the existing code that gulp-zip is replacing by setting the last-modified time to epoch 0. I'm finding that adding a modifiedTime option works fine so long as the time stamp is newer than "1980-01-01T24:00:00Z". If it's anything older, I get a far future date. For example, if I use 0 or "1970-01-01T00:00:00Z", I get a last modified of 1/1/2098.

It looks like the cause is in the dateToDosDateTime function that begins at line 624.

function dateToDosDateTime(jsDate) {
  var date = 0;
  date |= jsDate.getDate() & 0x1f; // 1-31
  date |= ((jsDate.getMonth() + 1) & 0xf) << 5; // 0-11, 1-12
  date |= ((jsDate.getFullYear() - 1980) & 0x7f) << 9; // 0-128, 1980-2108

Is using 1980 instead of 1970 a bug or intentional?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions