From 1c6ce663e4b130ff55b1b6e4ca88acbb3c4626cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Kubern=C3=A1t?= Date: Wed, 30 Oct 2024 18:19:51 +0100 Subject: [PATCH] Don't deserialize 0 offset --- src/chainpack.ts | 2 +- src/cpon.ts | 2 +- test.ts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/chainpack.ts b/src/chainpack.ts index 98ae9bc..1c43669 100644 --- a/src/chainpack.ts +++ b/src/chainpack.ts @@ -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: { diff --git a/src/cpon.ts b/src/cpon.ts index 41a37da..ac50553 100644 --- a/src/cpon.ts +++ b/src/cpon.ts @@ -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() { diff --git a/test.ts b/test.ts index a21c08f..5a297cf 100644 --- a/test.ts +++ b/test.ts @@ -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];