Skip to content

Commit

Permalink
Don't deserialize 0 offset
Browse files Browse the repository at this point in the history
  • Loading branch information
syyyr committed Oct 30, 2024
1 parent c6e200d commit 1c6ce66
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/chainpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class ChainPackReader {

msec += SHV_EPOCH_MSEC;
msec -= offset * 60_000;
return withOffset(new Date(msec), offset);
return withOffset(new Date(msec), offset ?? undefined);
}

case PackingSchema.Map: {
Expand Down
2 changes: 1 addition & 1 deletion src/cpon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class CponReader {
// let epoch_sec = CponReader.timegm(year, month, mday, hour, min, sec);
let epochMsec = Date.UTC(year, month - 1, day, hour, min, sec, msec);
epochMsec -= utcOffset * 60_000;
return withOffset(new Date(epochMsec), utcOffset);
return withOffset(new Date(epochMsec), utcOffset ?? undefined);
}

readCString() {
Expand Down
1 change: 1 addition & 0 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ for (const lst of [
['<4:"svete">i{2:<4:"svete">[0,1]}', null],
['d"2019-05-03T11:30:00-0700"', 'd"2019-05-03T11:30:00-07"'],
['d"2018-02-02T00:00:00Z"', null],
['d"2024-10-30T16:30:57.890Z"', null],
['d"2027-05-03T11:30:12.345+01"', null],
]) {
const cpon1 = lst[0];
Expand Down

0 comments on commit 1c6ce66

Please sign in to comment.