@naturalcycles/nodejs-lib 15.122.1 → 15.122.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.
|
@@ -543,10 +543,15 @@ export class JString extends JBuilder {
|
|
|
543
543
|
}
|
|
544
544
|
pattern(pattern, opt) {
|
|
545
545
|
const clone = this.cloneAndUpdateSchema({ pattern });
|
|
546
|
-
if (opt?.
|
|
547
|
-
clone.setErrorMessage('pattern', `is not a valid ${opt.name}`);
|
|
548
|
-
if (opt?.msg)
|
|
546
|
+
if (opt?.msg) {
|
|
549
547
|
clone.setErrorMessage('pattern', opt.msg);
|
|
548
|
+
}
|
|
549
|
+
else if (opt?.name) {
|
|
550
|
+
clone.setErrorMessage('pattern', `is not a valid ${opt.name}`);
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
clone.setErrorMessage('pattern', 'is not matching the expected pattern');
|
|
554
|
+
}
|
|
550
555
|
return clone;
|
|
551
556
|
}
|
|
552
557
|
minLength(minLength) {
|
package/dist/zip/zipInternal.js
CHANGED
|
@@ -60,8 +60,13 @@ const MAX_DOS_DATE = new Date(2107, 11, 31, 23, 59, 58);
|
|
|
60
60
|
* timestamp is rendered in the local timezone. Out-of-range dates are clamped to 1980-2107.
|
|
61
61
|
*/
|
|
62
62
|
export function unixToDosDateTime(ts) {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
let d = new Date(ts * 1000);
|
|
64
|
+
if (d < MIN_DOS_DATE) {
|
|
65
|
+
d = MIN_DOS_DATE;
|
|
66
|
+
}
|
|
67
|
+
else if (d > MAX_DOS_DATE) {
|
|
68
|
+
d = MAX_DOS_DATE;
|
|
69
|
+
}
|
|
65
70
|
const date = (d.getDate() & 0x1f) | // 1-31
|
|
66
71
|
(((d.getMonth() + 1) & 0x0f) << 5) | // 1-12
|
|
67
72
|
(((d.getFullYear() - 1980) & 0x7f) << 9); // 1980-2107
|
package/package.json
CHANGED
|
@@ -734,8 +734,14 @@ export class JString<
|
|
|
734
734
|
|
|
735
735
|
pattern(pattern: string, opt?: JsonBuilderRuleOpt): this {
|
|
736
736
|
const clone = this.cloneAndUpdateSchema({ pattern })
|
|
737
|
-
if (opt?.
|
|
738
|
-
|
|
737
|
+
if (opt?.msg) {
|
|
738
|
+
clone.setErrorMessage('pattern', opt.msg)
|
|
739
|
+
} else if (opt?.name) {
|
|
740
|
+
clone.setErrorMessage('pattern', `is not a valid ${opt.name}`)
|
|
741
|
+
} else {
|
|
742
|
+
clone.setErrorMessage('pattern', 'is not matching the expected pattern')
|
|
743
|
+
}
|
|
744
|
+
|
|
739
745
|
return clone
|
|
740
746
|
}
|
|
741
747
|
|
package/src/zip/zipInternal.ts
CHANGED
|
@@ -76,8 +76,12 @@ const MAX_DOS_DATE = new Date(2107, 11, 31, 23, 59, 58)
|
|
|
76
76
|
* timestamp is rendered in the local timezone. Out-of-range dates are clamped to 1980-2107.
|
|
77
77
|
*/
|
|
78
78
|
export function unixToDosDateTime(ts: UnixTimestamp): { date: number; time: number } {
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
let d = new Date(ts * 1000)
|
|
80
|
+
if (d < MIN_DOS_DATE) {
|
|
81
|
+
d = MIN_DOS_DATE
|
|
82
|
+
} else if (d > MAX_DOS_DATE) {
|
|
83
|
+
d = MAX_DOS_DATE
|
|
84
|
+
}
|
|
81
85
|
|
|
82
86
|
const date =
|
|
83
87
|
(d.getDate() & 0x1f) | // 1-31
|