libshv-js 3.4.1 → 3.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libshv-js",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
4
4
  "description": "Typescript implementation of libshv",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
package/src/chainpack.ts CHANGED
@@ -178,7 +178,7 @@ class ChainPackReader {
178
178
 
179
179
  msec += SHV_EPOCH_MSEC;
180
180
  msec -= offset * 60_000;
181
- return withOffset(new Date(msec), offset);
181
+ return withOffset(new Date(msec), offset ?? undefined);
182
182
  }
183
183
 
184
184
  case PackingSchema.Map: {
@@ -559,14 +559,14 @@ class ChainPackWriter {
559
559
  }
560
560
 
561
561
  let bi = BigInt(msecs);
562
- if (dt.utc_offset !== undefined) {
562
+ if (dt.utc_offset !== undefined && dt.utc_offset !== 0) {
563
563
  bi <<= 7n;
564
564
  bi |= BigInt((dt.utc_offset / 15) & 0x7F);
565
565
  }
566
566
 
567
567
  bi <<= 2n;
568
568
 
569
- if (dt.utc_offset !== undefined) {
569
+ if (dt.utc_offset !== undefined && dt.utc_offset !== 0) {
570
570
  bi |= 1n;
571
571
  }
572
572
 
package/src/cpon.ts CHANGED
@@ -315,7 +315,7 @@ class CponReader {
315
315
  // let epoch_sec = CponReader.timegm(year, month, mday, hour, min, sec);
316
316
  let epochMsec = Date.UTC(year, month - 1, day, hour, min, sec, msec);
317
317
  epochMsec -= utcOffset * 60_000;
318
- return withOffset(new Date(epochMsec), utcOffset);
318
+ return withOffset(new Date(epochMsec), utcOffset ?? undefined);
319
319
  }
320
320
 
321
321
  readCString() {
package/test.ts CHANGED
@@ -64,6 +64,7 @@ for (const lst of [
64
64
  ['<4:"svete">i{2:<4:"svete">[0,1]}', null],
65
65
  ['d"2019-05-03T11:30:00-0700"', 'd"2019-05-03T11:30:00-07"'],
66
66
  ['d"2018-02-02T00:00:00Z"', null],
67
+ ['d"2024-10-30T16:30:57.890Z"', null],
67
68
  ['d"2027-05-03T11:30:12.345+01"', null],
68
69
  ]) {
69
70
  const cpon1 = lst[0];