@fabriktor/fx 0.0.79 → 0.0.81
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/dist/src/core/date.d.ts +2 -0
- package/dist/src/core/date.js +27 -8
- package/dist/src/jobs/jobs.js +3 -6
- package/package.json +1 -1
package/dist/src/core/date.d.ts
CHANGED
|
@@ -10,3 +10,5 @@ export declare function normalizeInputDate(v: InDate): InDate;
|
|
|
10
10
|
export declare function zeroInputDate(): InDate;
|
|
11
11
|
export declare function zeroDate(): SchemaDate;
|
|
12
12
|
export declare function isZeroDate(v: LocalDateParts): boolean;
|
|
13
|
+
export declare function isZeroDateTime(value: string | null | undefined): boolean;
|
|
14
|
+
export declare function isZeroSchemaDate(value: SchemaDate | null | undefined): boolean;
|
package/dist/src/core/date.js
CHANGED
|
@@ -3,7 +3,19 @@
|
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4
4
|
// not use this file except in compliance with the License. You may obtain
|
|
5
5
|
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
const
|
|
6
|
+
const zeroDateParts = {
|
|
7
|
+
y: 1,
|
|
8
|
+
m: 1,
|
|
9
|
+
d: 1,
|
|
10
|
+
h: 0,
|
|
11
|
+
min: 0,
|
|
12
|
+
};
|
|
13
|
+
const zeroDatePrefix = [
|
|
14
|
+
String(zeroDateParts.y).padStart(4, "0"),
|
|
15
|
+
String(zeroDateParts.m).padStart(2, "0"),
|
|
16
|
+
String(zeroDateParts.d).padStart(2, "0"),
|
|
17
|
+
].join("-");
|
|
18
|
+
const zeroUTC = `${zeroDatePrefix}T00:00:00Z`;
|
|
7
19
|
const utcTimezone = "UTC";
|
|
8
20
|
export function normalizeInputDate(v) {
|
|
9
21
|
if (isZeroDate(v)) {
|
|
@@ -13,11 +25,7 @@ export function normalizeInputDate(v) {
|
|
|
13
25
|
}
|
|
14
26
|
export function zeroInputDate() {
|
|
15
27
|
return {
|
|
16
|
-
|
|
17
|
-
m: 1,
|
|
18
|
-
d: 1,
|
|
19
|
-
h: 0,
|
|
20
|
-
min: 0,
|
|
28
|
+
...zeroDateParts,
|
|
21
29
|
tz: utcTimezone,
|
|
22
30
|
};
|
|
23
31
|
}
|
|
@@ -28,9 +36,20 @@ export function zeroDate() {
|
|
|
28
36
|
};
|
|
29
37
|
}
|
|
30
38
|
export function isZeroDate(v) {
|
|
31
|
-
if (v.h !==
|
|
39
|
+
if (v.h !== zeroDateParts.h || v.min !== zeroDateParts.min) {
|
|
32
40
|
return false;
|
|
33
41
|
}
|
|
34
42
|
return ((v.y === 0 && v.m === 0 && v.d === 0) ||
|
|
35
|
-
(v.y ===
|
|
43
|
+
(v.y === zeroDateParts.y &&
|
|
44
|
+
v.m === zeroDateParts.m &&
|
|
45
|
+
v.d === zeroDateParts.d));
|
|
46
|
+
}
|
|
47
|
+
export function isZeroDateTime(value) {
|
|
48
|
+
const timestamp = value?.trim() ?? "";
|
|
49
|
+
return timestamp === "" || timestamp.startsWith(zeroDatePrefix);
|
|
50
|
+
}
|
|
51
|
+
export function isZeroSchemaDate(value) {
|
|
52
|
+
return (value === null ||
|
|
53
|
+
value === undefined ||
|
|
54
|
+
(isZeroDate(value) && isZeroDateTime(value.utc)));
|
|
36
55
|
}
|
package/dist/src/jobs/jobs.js
CHANGED
|
@@ -426,14 +426,14 @@ function validateProgramStart(opts) {
|
|
|
426
426
|
msg: msgTimezoneInvalid,
|
|
427
427
|
});
|
|
428
428
|
}
|
|
429
|
-
const
|
|
430
|
-
if (
|
|
429
|
+
const comparison = compareLocalDate(opts.start, now);
|
|
430
|
+
if (comparison < 0) {
|
|
431
431
|
throw errValidation({
|
|
432
432
|
field: "in",
|
|
433
433
|
msg: msgProgramStartPast,
|
|
434
434
|
});
|
|
435
435
|
}
|
|
436
|
-
return
|
|
436
|
+
return comparison === 0;
|
|
437
437
|
}
|
|
438
438
|
function validateDuration(v, field) {
|
|
439
439
|
if (!Number.isFinite(v) || !Number.isInteger(v) || v < 0) {
|
|
@@ -483,9 +483,6 @@ function normalizeRecurrenceEnd(opts) {
|
|
|
483
483
|
});
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
-
function sameCalendarDay(a, b) {
|
|
487
|
-
return a.y === b.y && a.m === b.m && a.d === b.d;
|
|
488
|
-
}
|
|
489
486
|
function locationTimezone(location, field) {
|
|
490
487
|
const out = location.timezone.trim();
|
|
491
488
|
if (out === "") {
|