Skip to content

Commit

Permalink
Merge pull request #32 from vleam/fix-ambiguous-date
Browse files Browse the repository at this point in the history
Set date from small to large time unit
  • Loading branch information
massivefermion committed Jun 2, 2024
2 parents 3e4f1b8 + 6d72017 commit 17b48be
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/birl_ffi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ export function to_parts(timestamp, offset) {
}

export function from_parts(parts, offset) {
const date = new Date();
date.setUTCFullYear(parts[0][0]);
date.setUTCMonth(parts[0][1] - 1);
date.setUTCDate(parts[0][2]);
date.setUTCHours(parts[1][0]);
date.setUTCMinutes(parts[1][1]);
date.setUTCSeconds(parts[1][2]);
date.setUTCMilliseconds(parts[1][3]);
const date = new Date(Date.UTC(
parts[0][0],
parts[0][1] - 1,
parts[0][2],
parts[1][0],
parts[1][1],
parts[1][2],
parts[1][3],
));

return date.getTime() * 1000 - offset;
}

Expand Down

0 comments on commit 17b48be

Please sign in to comment.