@duplojs/utils 1.3.29 → 1.3.31
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/clean/entity.d.ts +2 -2
- package/dist/clean/flag.cjs +4 -0
- package/dist/clean/flag.d.ts +1 -0
- package/dist/clean/flag.mjs +4 -0
- package/dist/clean/index.cjs +15 -0
- package/dist/clean/index.d.ts +1 -0
- package/dist/clean/index.mjs +8 -1
- package/dist/clean/newType.d.ts +2 -2
- package/dist/clean/primitive/base.cjs +3 -0
- package/dist/clean/primitive/base.d.ts +4 -2
- package/dist/clean/primitive/base.mjs +3 -1
- package/dist/clean/primitive/operations/date/dateAddTime.cjs +16 -0
- package/dist/clean/primitive/operations/date/dateAddTime.d.ts +4 -0
- package/dist/clean/primitive/operations/date/dateAddTime.mjs +14 -0
- package/dist/clean/primitive/operations/date/dateMax.cjs +1 -5
- package/dist/clean/primitive/operations/date/dateMax.d.ts +1 -2
- package/dist/clean/primitive/operations/date/dateMax.mjs +1 -5
- package/dist/clean/primitive/operations/date/dateMin.cjs +1 -5
- package/dist/clean/primitive/operations/date/dateMin.d.ts +1 -2
- package/dist/clean/primitive/operations/date/dateMin.mjs +1 -5
- package/dist/clean/primitive/operations/date/dateSubtractTime.cjs +16 -0
- package/dist/clean/primitive/operations/date/dateSubtractTime.d.ts +4 -0
- package/dist/clean/primitive/operations/date/dateSubtractTime.mjs +14 -0
- package/dist/clean/primitive/operations/date/index.d.ts +2 -4
- package/dist/clean/primitive/operations/equal.d.ts +3 -3
- package/dist/clean/primitive/operations/index.d.ts +1 -0
- package/dist/clean/primitive/operations/sort.cjs +6 -0
- package/dist/clean/primitive/operations/sort.d.ts +4 -8
- package/dist/clean/primitive/operations/sort.mjs +6 -0
- package/dist/clean/primitive/operations/time/index.d.ts +4 -0
- package/dist/clean/primitive/operations/time/timeGreaterThan.cjs +15 -0
- package/dist/clean/primitive/operations/time/timeGreaterThan.d.ts +4 -0
- package/dist/clean/primitive/operations/time/timeGreaterThan.mjs +13 -0
- package/dist/clean/primitive/operations/time/timeLessThan.cjs +15 -0
- package/dist/clean/primitive/operations/time/timeLessThan.d.ts +4 -0
- package/dist/clean/primitive/operations/time/timeLessThan.mjs +13 -0
- package/dist/clean/primitive/operations/time/timeMax.cjs +12 -0
- package/dist/clean/primitive/operations/time/timeMax.d.ts +4 -0
- package/dist/clean/primitive/operations/time/timeMax.mjs +10 -0
- package/dist/clean/primitive/operations/time/timeMin.cjs +12 -0
- package/dist/clean/primitive/operations/time/timeMin.d.ts +4 -0
- package/dist/clean/primitive/operations/time/timeMin.mjs +10 -0
- package/dist/clean/unwrapEntity.cjs +26 -0
- package/dist/clean/unwrapEntity.d.ts +13 -0
- package/dist/clean/unwrapEntity.mjs +24 -0
- package/dist/common/index.d.ts +2 -0
- package/dist/common/override.cjs +38 -17
- package/dist/common/override.d.ts +5 -8
- package/dist/common/override.mjs +38 -17
- package/dist/common/pipeCall.cjs +7 -0
- package/dist/common/pipeCall.d.ts +1 -0
- package/dist/common/pipeCall.mjs +5 -0
- package/dist/common/toCurriedPredicate.cjs +7 -0
- package/dist/common/toCurriedPredicate.d.ts +1 -0
- package/dist/common/toCurriedPredicate.mjs +5 -0
- package/dist/common/toWrappedValue.d.ts +2 -1
- package/dist/common/types/DeepReadonly.d.ts +3 -0
- package/dist/common/types/index.d.ts +1 -0
- package/dist/dataParser/extended/coerce/index.cjs +2 -0
- package/dist/dataParser/extended/coerce/index.d.ts +1 -0
- package/dist/dataParser/extended/coerce/index.mjs +1 -0
- package/dist/dataParser/extended/coerce/time.cjs +12 -0
- package/dist/dataParser/extended/coerce/time.d.ts +7 -0
- package/dist/dataParser/extended/coerce/time.mjs +10 -0
- package/dist/dataParser/extended/index.cjs +2 -0
- package/dist/dataParser/extended/index.d.ts +1 -0
- package/dist/dataParser/extended/index.mjs +1 -0
- package/dist/dataParser/extended/object.cjs +5 -0
- package/dist/dataParser/extended/object.d.ts +4 -0
- package/dist/dataParser/extended/object.mjs +5 -0
- package/dist/dataParser/extended/time.cjs +22 -0
- package/dist/dataParser/extended/time.d.ts +34 -0
- package/dist/dataParser/extended/time.mjs +20 -0
- package/dist/dataParser/identifier.d.ts +10 -4
- package/dist/dataParser/index.cjs +36 -24
- package/dist/dataParser/index.mjs +4 -0
- package/dist/dataParser/parsers/coerce/index.cjs +2 -0
- package/dist/dataParser/parsers/coerce/index.d.ts +1 -0
- package/dist/dataParser/parsers/coerce/index.mjs +1 -0
- package/dist/dataParser/parsers/coerce/time.cjs +12 -0
- package/dist/dataParser/parsers/coerce/time.d.ts +6 -0
- package/dist/dataParser/parsers/coerce/time.mjs +10 -0
- package/dist/dataParser/parsers/date.cjs +6 -12
- package/dist/dataParser/parsers/date.mjs +6 -12
- package/dist/dataParser/parsers/index.d.ts +1 -0
- package/dist/dataParser/parsers/literal.d.ts +2 -2
- package/dist/dataParser/parsers/object/extends.cjs +15 -0
- package/dist/dataParser/parsers/object/extends.d.ts +9 -0
- package/dist/dataParser/parsers/object/extends.mjs +12 -0
- package/dist/dataParser/parsers/object/index.d.ts +1 -0
- package/dist/dataParser/parsers/time/checkers/index.d.ts +2 -0
- package/dist/dataParser/parsers/time/checkers/max.cjs +19 -0
- package/dist/dataParser/parsers/time/checkers/max.d.ts +12 -0
- package/dist/dataParser/parsers/time/checkers/max.mjs +16 -0
- package/dist/dataParser/parsers/time/checkers/min.cjs +19 -0
- package/dist/dataParser/parsers/time/checkers/min.d.ts +12 -0
- package/dist/dataParser/parsers/time/checkers/min.mjs +16 -0
- package/dist/dataParser/parsers/time/index.cjs +47 -0
- package/dist/dataParser/parsers/time/index.d.ts +33 -0
- package/dist/dataParser/parsers/time/index.mjs +44 -0
- package/dist/dataParser/types/checkers.d.ts +1 -1
- package/dist/dataParser/types/dataParsers.d.ts +2 -2
- package/dist/date/applyTimezone.cjs +17 -0
- package/dist/date/applyTimezone.d.ts +4 -0
- package/dist/date/applyTimezone.mjs +15 -0
- package/dist/date/constants.cjs +13 -3
- package/dist/date/constants.d.ts +6 -1
- package/dist/date/constants.mjs +9 -4
- package/dist/date/create.cjs +62 -29
- package/dist/date/create.d.ts +10 -6
- package/dist/date/create.mjs +60 -27
- package/dist/date/createOrThrow.cjs +4 -1
- package/dist/date/createOrThrow.d.ts +5 -4
- package/dist/date/createOrThrow.mjs +4 -1
- package/dist/date/createTheDate.cjs +10 -0
- package/dist/date/createTheDate.d.ts +2 -0
- package/dist/date/createTheDate.mjs +8 -0
- package/dist/date/createTheTime.cjs +10 -0
- package/dist/date/createTheTime.d.ts +2 -0
- package/dist/date/createTheTime.mjs +8 -0
- package/dist/date/createTime.cjs +61 -0
- package/dist/date/createTime.d.ts +44 -0
- package/dist/date/createTime.mjs +59 -0
- package/dist/date/createTimeOrThrow.cjs +28 -0
- package/dist/date/createTimeOrThrow.d.ts +10 -0
- package/dist/date/createTimeOrThrow.mjs +25 -0
- package/dist/date/format.cjs +37 -0
- package/dist/date/format.d.ts +4 -0
- package/dist/date/format.mjs +35 -0
- package/dist/date/getTimezoneOffset.cjs +27 -0
- package/dist/date/getTimezoneOffset.d.ts +4 -0
- package/dist/date/getTimezoneOffset.mjs +25 -0
- package/dist/date/getters/getDayOfYear.cjs +2 -1
- package/dist/date/getters/getDayOfYear.mjs +2 -1
- package/dist/date/index.cjs +51 -2
- package/dist/date/index.d.ts +15 -0
- package/dist/date/index.mjs +25 -3
- package/dist/date/is.cjs +9 -1
- package/dist/date/is.mjs +9 -1
- package/dist/date/isSafeTimeValue.cjs +15 -0
- package/dist/date/isSafeTimeValue.d.ts +1 -0
- package/dist/date/isSafeTimeValue.mjs +13 -0
- package/dist/date/isSafeTimestamp.cjs +3 -3
- package/dist/date/isSafeTimestamp.d.ts +1 -1
- package/dist/date/isSafeTimestamp.mjs +3 -3
- package/dist/date/isTime.cjs +17 -0
- package/dist/date/isTime.d.ts +2 -0
- package/dist/date/isTime.mjs +15 -0
- package/dist/date/makeSafeTimeValue.cjs +20 -0
- package/dist/date/makeSafeTimeValue.d.ts +1 -0
- package/dist/date/makeSafeTimeValue.mjs +18 -0
- package/dist/date/makeSafeTimestamp.cjs +20 -0
- package/dist/date/makeSafeTimestamp.d.ts +1 -0
- package/dist/date/makeSafeTimestamp.mjs +18 -0
- package/dist/date/maxTime.cjs +10 -0
- package/dist/date/maxTime.d.ts +3 -0
- package/dist/date/maxTime.mjs +8 -0
- package/dist/date/minTime.cjs +10 -0
- package/dist/date/minTime.d.ts +3 -0
- package/dist/date/minTime.mjs +8 -0
- package/dist/date/operators/addDays.cjs +2 -3
- package/dist/date/operators/addDays.mjs +2 -3
- package/dist/date/operators/addHours.cjs +2 -3
- package/dist/date/operators/addHours.mjs +2 -3
- package/dist/date/operators/addMilliseconds.cjs +2 -3
- package/dist/date/operators/addMilliseconds.mjs +2 -3
- package/dist/date/operators/addMinutes.cjs +2 -3
- package/dist/date/operators/addMinutes.mjs +2 -3
- package/dist/date/operators/addMonths.cjs +2 -3
- package/dist/date/operators/addMonths.mjs +2 -3
- package/dist/date/operators/addSeconds.cjs +2 -3
- package/dist/date/operators/addSeconds.mjs +2 -3
- package/dist/date/operators/addTime.cjs +21 -0
- package/dist/date/operators/addTime.d.ts +5 -0
- package/dist/date/operators/addTime.mjs +19 -0
- package/dist/date/operators/addWeeks.cjs +2 -3
- package/dist/date/operators/addWeeks.mjs +2 -3
- package/dist/date/operators/addYears.cjs +2 -3
- package/dist/date/operators/addYears.mjs +2 -3
- package/dist/date/operators/betweenThanTime.cjs +17 -0
- package/dist/date/operators/betweenThanTime.d.ts +3 -0
- package/dist/date/operators/betweenThanTime.mjs +15 -0
- package/dist/date/operators/betweenTime.cjs +17 -0
- package/dist/date/operators/betweenTime.d.ts +3 -0
- package/dist/date/operators/betweenTime.mjs +15 -0
- package/dist/date/operators/greaterThanTime.cjs +16 -0
- package/dist/date/operators/greaterThanTime.d.ts +3 -0
- package/dist/date/operators/greaterThanTime.mjs +14 -0
- package/dist/date/operators/greaterTime.cjs +16 -0
- package/dist/date/operators/greaterTime.d.ts +3 -0
- package/dist/date/operators/greaterTime.mjs +14 -0
- package/dist/date/operators/index.d.ts +8 -0
- package/dist/date/operators/lessThanTime.cjs +16 -0
- package/dist/date/operators/lessThanTime.d.ts +3 -0
- package/dist/date/operators/lessThanTime.mjs +14 -0
- package/dist/date/operators/lessTime.cjs +16 -0
- package/dist/date/operators/lessTime.d.ts +3 -0
- package/dist/date/operators/lessTime.mjs +14 -0
- package/dist/date/operators/subtractDays.cjs +2 -3
- package/dist/date/operators/subtractDays.mjs +2 -3
- package/dist/date/operators/subtractHours.cjs +2 -3
- package/dist/date/operators/subtractHours.mjs +2 -3
- package/dist/date/operators/subtractMilliseconds.cjs +2 -3
- package/dist/date/operators/subtractMilliseconds.mjs +2 -3
- package/dist/date/operators/subtractMinutes.cjs +2 -3
- package/dist/date/operators/subtractMinutes.mjs +2 -3
- package/dist/date/operators/subtractMonths.cjs +2 -3
- package/dist/date/operators/subtractMonths.mjs +2 -3
- package/dist/date/operators/subtractSeconds.cjs +2 -3
- package/dist/date/operators/subtractSeconds.mjs +2 -3
- package/dist/date/operators/subtractTime.cjs +21 -0
- package/dist/date/operators/subtractTime.d.ts +5 -0
- package/dist/date/operators/subtractTime.mjs +19 -0
- package/dist/date/operators/subtractWeeks.cjs +2 -3
- package/dist/date/operators/subtractWeeks.mjs +2 -3
- package/dist/date/operators/subtractYears.cjs +2 -3
- package/dist/date/operators/subtractYears.mjs +2 -3
- package/dist/date/sortTimes.cjs +20 -0
- package/dist/date/sortTimes.d.ts +4 -0
- package/dist/date/sortTimes.mjs +18 -0
- package/dist/date/{types/timezone.cjs → timezone.cjs} +1 -1
- package/dist/date/{types/timezone.d.ts → timezone.d.ts} +1 -1
- package/dist/date/{types/timezone.mjs → timezone.mjs} +1 -1
- package/dist/date/toTimeValue.cjs +14 -0
- package/dist/date/toTimeValue.d.ts +2 -0
- package/dist/date/toTimeValue.mjs +12 -0
- package/dist/date/toTimestamp.cjs +6 -21
- package/dist/date/toTimestamp.d.ts +0 -8
- package/dist/date/toTimestamp.mjs +8 -22
- package/dist/date/types/index.d.ts +3 -1
- package/dist/date/types/isSafeYear.d.ts +5 -52
- package/dist/date/types/spoolingDate.d.ts +12 -0
- package/dist/date/types/spoolingTime.d.ts +9 -0
- package/dist/date/types/theTime.d.ts +1 -0
- package/dist/index.cjs +4 -0
- package/dist/index.mjs +2 -0
- package/dist/metadata.json +401 -5
- package/dist/number/types/index.d.ts +2 -0
- package/dist/number/types/isGreater.d.ts +50 -0
- package/dist/number/types/isLess.d.ts +3 -0
- package/dist/object/hasKeys.d.ts +2 -2
- package/dist/object/types/forbiddenKey.d.ts +6 -0
- package/dist/object/types/index.d.ts +1 -0
- package/dist/string/types/index.d.ts +1 -0
- package/dist/string/types/replace.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createTheDate } from '../createTheDate.mjs';
|
|
1
2
|
import { toNative } from '../toNative.mjs';
|
|
2
3
|
|
|
3
4
|
function subtractYears(...args) {
|
|
@@ -8,9 +9,7 @@ function subtractYears(...args) {
|
|
|
8
9
|
const [input, year] = args;
|
|
9
10
|
const date = toNative(input);
|
|
10
11
|
date.setUTCFullYear(date.getUTCFullYear() - year);
|
|
11
|
-
|
|
12
|
-
const isNegative = timestamp < 0;
|
|
13
|
-
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
12
|
+
return createTheDate(date.getTime());
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
export { subtractYears };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var createTheTime = require('./createTheTime.cjs');
|
|
4
|
+
var toTimeValue = require('./toTimeValue.cjs');
|
|
5
|
+
|
|
6
|
+
function sortTimes(...args) {
|
|
7
|
+
if (args.length === 1) {
|
|
8
|
+
const [type] = args;
|
|
9
|
+
return (array) => sortTimes(array, type);
|
|
10
|
+
}
|
|
11
|
+
const [array, type] = args;
|
|
12
|
+
return array
|
|
13
|
+
.map(toTimeValue.toTimeValue)
|
|
14
|
+
.sort(type === "DSC"
|
|
15
|
+
? (first, second) => second - first
|
|
16
|
+
: (first, second) => first - second)
|
|
17
|
+
.map(createTheTime.createTheTime);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.sortTimes = sortTimes;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type SortType } from "../common";
|
|
2
|
+
import { type TheTime } from "./types";
|
|
3
|
+
export declare function sortTimes<GenericArray extends readonly TheTime[]>(type: SortType): (array: GenericArray) => TheTime[];
|
|
4
|
+
export declare function sortTimes<GenericArray extends readonly TheTime[]>(array: GenericArray, type: SortType): TheTime[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createTheTime } from './createTheTime.mjs';
|
|
2
|
+
import { toTimeValue } from './toTimeValue.mjs';
|
|
3
|
+
|
|
4
|
+
function sortTimes(...args) {
|
|
5
|
+
if (args.length === 1) {
|
|
6
|
+
const [type] = args;
|
|
7
|
+
return (array) => sortTimes(array, type);
|
|
8
|
+
}
|
|
9
|
+
const [array, type] = args;
|
|
10
|
+
return array
|
|
11
|
+
.map(toTimeValue)
|
|
12
|
+
.sort(type === "DSC"
|
|
13
|
+
? (first, second) => second - first
|
|
14
|
+
: (first, second) => first - second)
|
|
15
|
+
.map(createTheTime);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { sortTimes };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants = require('./constants.cjs');
|
|
4
|
+
var makeSafeTimeValue = require('./makeSafeTimeValue.cjs');
|
|
5
|
+
|
|
6
|
+
function toTimeValue(input) {
|
|
7
|
+
const match = input.match(constants.theTimeRegex);
|
|
8
|
+
const { value, sign } = match.groups;
|
|
9
|
+
return makeSafeTimeValue.makeSafeTimeValue(Number(sign === "-"
|
|
10
|
+
? `-${value}`
|
|
11
|
+
: value));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.toTimeValue = toTimeValue;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { theTimeRegex } from './constants.mjs';
|
|
2
|
+
import { makeSafeTimeValue } from './makeSafeTimeValue.mjs';
|
|
3
|
+
|
|
4
|
+
function toTimeValue(input) {
|
|
5
|
+
const match = input.match(theTimeRegex);
|
|
6
|
+
const { value, sign } = match.groups;
|
|
7
|
+
return makeSafeTimeValue(Number(sign === "-"
|
|
8
|
+
? `-${value}`
|
|
9
|
+
: value));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { toTimeValue };
|
|
@@ -1,31 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var constants = require('./constants.cjs');
|
|
4
|
-
var
|
|
5
|
-
var kind = require('../common/kind.cjs');
|
|
6
|
-
var errorKindNamespace = require('../common/errorKindNamespace.cjs');
|
|
4
|
+
var makeSafeTimestamp = require('./makeSafeTimestamp.cjs');
|
|
7
5
|
|
|
8
|
-
class InvalidTheDateError extends kind.kindHeritage("invalid-the-Date-error", errorKindNamespace.createErrorKind("invalid-the-Date-error"), Error) {
|
|
9
|
-
theDate;
|
|
10
|
-
constructor(theDate) {
|
|
11
|
-
super({}, ["TheDate is invalid."]);
|
|
12
|
-
this.theDate = theDate;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
6
|
function toTimestamp(input) {
|
|
16
|
-
const match = input.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
7
|
+
const match = input.startsWith("date")
|
|
8
|
+
? input.match(constants.theDateRegex)
|
|
9
|
+
: input.match(constants.theTimeRegex);
|
|
20
10
|
const { value, sign } = match.groups;
|
|
21
|
-
|
|
11
|
+
return makeSafeTimestamp.makeSafeTimestamp(Number(sign === "-"
|
|
22
12
|
? `-${value}`
|
|
23
|
-
: value);
|
|
24
|
-
if (!isSafeTimestamp.isSafeTimestamp(timestamp)) {
|
|
25
|
-
throw new InvalidTheDateError(input);
|
|
26
|
-
}
|
|
27
|
-
return timestamp;
|
|
13
|
+
: value));
|
|
28
14
|
}
|
|
29
15
|
|
|
30
|
-
exports.InvalidTheDateError = InvalidTheDateError;
|
|
31
16
|
exports.toTimestamp = toTimestamp;
|
|
@@ -1,10 +1,2 @@
|
|
|
1
1
|
import type { TheDate } from "./types";
|
|
2
|
-
declare const InvalidTheDateError_base: new (params: {
|
|
3
|
-
"@DuplojsUtilsError/invalid-the-Date-error"?: unknown;
|
|
4
|
-
}, parentParams: [message?: string | undefined, options?: ErrorOptions | undefined]) => Error & import("../common").Kind<import("../common").KindDefinition<"invalid-the-Date-error", unknown>, unknown> & import("../common").Kind<import("../common").KindDefinition<"@DuplojsUtilsError/invalid-the-Date-error", unknown>, unknown>;
|
|
5
|
-
export declare class InvalidTheDateError extends InvalidTheDateError_base {
|
|
6
|
-
theDate: TheDate;
|
|
7
|
-
constructor(theDate: TheDate);
|
|
8
|
-
}
|
|
9
2
|
export declare function toTimestamp<GenericInput extends TheDate>(input: GenericInput): number;
|
|
10
|
-
export {};
|
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
import { theDateRegex } from './constants.mjs';
|
|
2
|
-
import {
|
|
3
|
-
import { kindHeritage } from '../common/kind.mjs';
|
|
4
|
-
import { createErrorKind } from '../common/errorKindNamespace.mjs';
|
|
1
|
+
import { theDateRegex, theTimeRegex } from './constants.mjs';
|
|
2
|
+
import { makeSafeTimestamp } from './makeSafeTimestamp.mjs';
|
|
5
3
|
|
|
6
|
-
class InvalidTheDateError extends kindHeritage("invalid-the-Date-error", createErrorKind("invalid-the-Date-error"), Error) {
|
|
7
|
-
theDate;
|
|
8
|
-
constructor(theDate) {
|
|
9
|
-
super({}, ["TheDate is invalid."]);
|
|
10
|
-
this.theDate = theDate;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
4
|
function toTimestamp(input) {
|
|
14
|
-
const match = input.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
5
|
+
const match = input.startsWith("date")
|
|
6
|
+
? input.match(theDateRegex)
|
|
7
|
+
: input.match(theTimeRegex);
|
|
18
8
|
const { value, sign } = match.groups;
|
|
19
|
-
|
|
9
|
+
return makeSafeTimestamp(Number(sign === "-"
|
|
20
10
|
? `-${value}`
|
|
21
|
-
: value);
|
|
22
|
-
if (!isSafeTimestamp(timestamp)) {
|
|
23
|
-
throw new InvalidTheDateError(input);
|
|
24
|
-
}
|
|
25
|
-
return timestamp;
|
|
11
|
+
: value));
|
|
26
12
|
}
|
|
27
13
|
|
|
28
|
-
export {
|
|
14
|
+
export { toTimestamp };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from "./theDate";
|
|
2
2
|
export * from "./isLeapYear";
|
|
3
|
-
export * from "./timezone";
|
|
4
3
|
export * from "./unit";
|
|
5
4
|
export * from "./month";
|
|
6
5
|
export * from "./time";
|
|
7
6
|
export * from "./isSafeYear";
|
|
7
|
+
export * from "./spoolingDate";
|
|
8
|
+
export * from "./theTime";
|
|
9
|
+
export * from "./spoolingTime";
|
|
@@ -1,53 +1,6 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type * as DString from "../../string";
|
|
3
|
-
import type * as DArray from "../../array";
|
|
1
|
+
import { type And } from "../../common";
|
|
4
2
|
import type * as DNumber from "../../number";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"8" | "9",
|
|
10
|
-
"6" | "7" | "8" | "9",
|
|
11
|
-
"8" | "9",
|
|
12
|
-
"6" | "7" | "8" | "9",
|
|
13
|
-
""
|
|
14
|
-
];
|
|
15
|
-
equal: [
|
|
16
|
-
"2",
|
|
17
|
-
"7",
|
|
18
|
-
"5",
|
|
19
|
-
"7",
|
|
20
|
-
"5",
|
|
21
|
-
"9"
|
|
22
|
-
];
|
|
23
|
-
};
|
|
24
|
-
negative: {
|
|
25
|
-
greater: [
|
|
26
|
-
"3" | "4" | "5" | "6" | "7" | "8" | "9",
|
|
27
|
-
"8" | "9",
|
|
28
|
-
"2" | "3" | "4" | "5" | "6" | "7" | "8" | "9",
|
|
29
|
-
"9",
|
|
30
|
-
"3" | "4" | "5" | "6" | "7" | "8" | "9",
|
|
31
|
-
"1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
|
|
32
|
-
];
|
|
33
|
-
equal: [
|
|
34
|
-
"2",
|
|
35
|
-
"7",
|
|
36
|
-
"1",
|
|
37
|
-
"8",
|
|
38
|
-
"2",
|
|
39
|
-
"0"
|
|
40
|
-
];
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
type CheckSplitYear<GenericSplitYear extends AnyTuple<DString.Number>, GenericGreaterTable extends AnyTuple<string>, GenericEqualTable extends AnyTuple<string>> = GenericSplitYear[0] extends GenericGreaterTable[0] ? false : GenericSplitYear[0] extends GenericEqualTable[0] ? [
|
|
44
|
-
DArray.ShiftTuple<GenericSplitYear>,
|
|
45
|
-
DArray.ShiftTuple<GenericGreaterTable>,
|
|
46
|
-
DArray.ShiftTuple<GenericEqualTable>
|
|
47
|
-
] extends [
|
|
48
|
-
infer InferredSplitYear extends readonly DString.Number[],
|
|
49
|
-
infer InferredGreaterTable extends readonly string[],
|
|
50
|
-
infer InferredEqualTable extends readonly string[]
|
|
51
|
-
] ? InferredSplitYear extends AnyTuple<DString.Number> ? CheckSplitYear<InferredSplitYear, Adaptor<InferredGreaterTable, AnyTuple<string>>, Adaptor<InferredEqualTable, AnyTuple<string>>> : true : never : true;
|
|
52
|
-
export type IsSafeYear<GenericYears extends number> = DNumber.Absolute<GenericYears> extends infer InferredYear extends number ? DString.StringLength<`${InferredYear}`> extends infer InferredLength extends number ? InferredLength extends 1 | 2 | 3 | 4 | 5 | 6 ? InferredLength extends 6 ? DString.Split<`${InferredYear}`, ""> extends infer InferredSplitYear extends AnyTuple<DString.Number> ? CheckSplitYear<InferredSplitYear, DNumber.IsPositive<GenericYears> extends true ? GreaterTable["positive"]["greater"] : GreaterTable["negative"]["greater"], DNumber.IsPositive<GenericYears> extends true ? GreaterTable["positive"]["equal"] : GreaterTable["negative"]["equal"]> : false : true : false : never : never;
|
|
53
|
-
export {};
|
|
3
|
+
export type IsSafeYear<GenericYears extends number> = And<[
|
|
4
|
+
DNumber.IsGreater<GenericYears, -271820>,
|
|
5
|
+
DNumber.IsLess<GenericYears, 275759>
|
|
6
|
+
]>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Timezone } from "../timezone";
|
|
2
|
+
export interface SpoolingDate {
|
|
3
|
+
value: string | Date | number;
|
|
4
|
+
timezone?: Timezone;
|
|
5
|
+
year?: number;
|
|
6
|
+
month?: number;
|
|
7
|
+
day?: number;
|
|
8
|
+
hour?: number;
|
|
9
|
+
minute?: number;
|
|
10
|
+
second?: number;
|
|
11
|
+
millisecond?: number;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TheTime = `time${number}${"+" | "-"}`;
|
package/dist/index.cjs
CHANGED
|
@@ -58,6 +58,8 @@ var truthy = require('./common/truthy.cjs');
|
|
|
58
58
|
var falsy = require('./common/falsy.cjs');
|
|
59
59
|
var hasSomeKinds = require('./common/hasSomeKinds.cjs');
|
|
60
60
|
var hasKinds = require('./common/hasKinds.cjs');
|
|
61
|
+
var toCurriedPredicate = require('./common/toCurriedPredicate.cjs');
|
|
62
|
+
var pipeCall = require('./common/pipeCall.cjs');
|
|
61
63
|
|
|
62
64
|
|
|
63
65
|
|
|
@@ -143,3 +145,5 @@ exports.truthy = truthy.truthy;
|
|
|
143
145
|
exports.falsy = falsy.falsy;
|
|
144
146
|
exports.hasSomeKinds = hasSomeKinds.hasSomeKinds;
|
|
145
147
|
exports.hasKinds = hasKinds.hasKinds;
|
|
148
|
+
exports.toCurriedPredicate = toCurriedPredicate.toCurriedPredicate;
|
|
149
|
+
exports.pipeCall = pipeCall.pipeCall;
|
package/dist/index.mjs
CHANGED
|
@@ -80,3 +80,5 @@ export { truthy } from './common/truthy.mjs';
|
|
|
80
80
|
export { falsy } from './common/falsy.mjs';
|
|
81
81
|
export { hasSomeKinds } from './common/hasSomeKinds.mjs';
|
|
82
82
|
export { hasKinds } from './common/hasKinds.mjs';
|
|
83
|
+
export { toCurriedPredicate } from './common/toCurriedPredicate.mjs';
|
|
84
|
+
export { pipeCall } from './common/pipeCall.mjs';
|