libshv-js 3.4.0 → 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 +1 -1
- package/src/chainpack.ts +3 -3
- package/src/cpon.ts +1 -1
- package/src/zod.ts +6 -3
- package/test.ts +1 -0
package/package.json
CHANGED
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/src/zod.ts
CHANGED
|
@@ -8,6 +8,9 @@ export const metamap = <T extends Record<string | number, ZodType<any, any, any>
|
|
|
8
8
|
export const int = () => z.number();
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments -- Zod needs the default argument, otherwise it'll infer as UInt<unknown>
|
|
10
10
|
export const uint = () => z.instanceof(UInt<number>);
|
|
11
|
+
export const double = () => z.instanceof(Double);
|
|
12
|
+
export const decimal = () => z.instanceof(Decimal);
|
|
13
|
+
export const blob = () => z.instanceof(ArrayBuffer);
|
|
11
14
|
|
|
12
15
|
const withMetaInstanceParser = z.instanceof(RpcValueWithMetaData);
|
|
13
16
|
export const rpcvalue = () => z.union([
|
|
@@ -15,9 +18,9 @@ export const rpcvalue = () => z.union([
|
|
|
15
18
|
z.boolean(),
|
|
16
19
|
z.number(),
|
|
17
20
|
uint(),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
double(),
|
|
22
|
+
decimal(),
|
|
23
|
+
blob(),
|
|
21
24
|
z.string(),
|
|
22
25
|
z.date(),
|
|
23
26
|
z.array(z.any()),
|
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];
|