@duplojs/utils 1.3.29 → 1.3.30
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/index.cjs +13 -0
- package/dist/clean/index.mjs +7 -1
- 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/common/toWrappedValue.d.ts +2 -1
- 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/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 +33 -24
- package/dist/dataParser/index.mjs +3 -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/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/metadata.json +359 -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/string/types/index.d.ts +1 -0
- package/dist/string/types/replace.d.ts +1 -0
- package/package.json +1 -1
package/dist/date/index.mjs
CHANGED
|
@@ -1,22 +1,36 @@
|
|
|
1
|
-
export { daysInOneWeek, hoursInOneDay, maxTimestamp, millisecondInOneHour, millisecondInOneMinute, millisecondInOneWeek, millisecondsInOneDay, millisecondsInOneSecond, minTimestamp, minutesInOneHour, monthsInOneYear, secondsInOneMinute, theDateRegex } from './constants.mjs';
|
|
1
|
+
export { daysInOneWeek, hoursInOneDay, isoDateRegex, isoTimeRegex, maxTimeValue, maxTimestamp, millisecondInOneHour, millisecondInOneMinute, millisecondInOneWeek, millisecondsInOneDay, millisecondsInOneSecond, minTimeValue, minTimestamp, minutesInOneHour, monthsInOneYear, secondsInOneMinute, theDateRegex, theTimeRegex } from './constants.mjs';
|
|
2
2
|
export { create } from './create.mjs';
|
|
3
3
|
export { now } from './now.mjs';
|
|
4
4
|
export { today } from './today.mjs';
|
|
5
5
|
export { yesterday } from './yesterday.mjs';
|
|
6
6
|
export { tomorrow } from './tomorrow.mjs';
|
|
7
7
|
export { toNative } from './toNative.mjs';
|
|
8
|
-
export {
|
|
8
|
+
export { toTimestamp } from './toTimestamp.mjs';
|
|
9
|
+
export { toTimeValue } from './toTimeValue.mjs';
|
|
9
10
|
export { toISOString } from './toISOString.mjs';
|
|
10
11
|
export { closestTo } from './closestTo.mjs';
|
|
11
12
|
export { each } from './each.mjs';
|
|
12
13
|
export { CreateTheDateError, createOrThrow } from './createOrThrow.mjs';
|
|
13
14
|
export { round } from './round.mjs';
|
|
14
15
|
export { isSafeTimestamp } from './isSafeTimestamp.mjs';
|
|
16
|
+
export { isSafeTimeValue } from './isSafeTimeValue.mjs';
|
|
15
17
|
export { min } from './min.mjs';
|
|
18
|
+
export { minTime } from './minTime.mjs';
|
|
16
19
|
export { max } from './max.mjs';
|
|
20
|
+
export { maxTime } from './maxTime.mjs';
|
|
17
21
|
export { sort } from './sort.mjs';
|
|
22
|
+
export { sortTimes } from './sortTimes.mjs';
|
|
18
23
|
export { is } from './is.mjs';
|
|
19
|
-
export {
|
|
24
|
+
export { isTime } from './isTime.mjs';
|
|
25
|
+
export { timezone } from './timezone.mjs';
|
|
26
|
+
export { getTimezoneOffset } from './getTimezoneOffset.mjs';
|
|
27
|
+
export { applyTimezone } from './applyTimezone.mjs';
|
|
28
|
+
export { format } from './format.mjs';
|
|
29
|
+
export { makeSafeTimestamp } from './makeSafeTimestamp.mjs';
|
|
30
|
+
export { createTheDate } from './createTheDate.mjs';
|
|
31
|
+
export { createTheTime } from './createTheTime.mjs';
|
|
32
|
+
export { createTime } from './createTime.mjs';
|
|
33
|
+
export { CreateTheTimeError, createTimeOrThrow } from './createTimeOrThrow.mjs';
|
|
20
34
|
export { getDayOfMonth } from './getters/getDayOfMonth.mjs';
|
|
21
35
|
export { getDayOfWeek } from './getters/getDayOfWeek.mjs';
|
|
22
36
|
export { getFirstDayOfWeek } from './getters/getFirstDayOfWeek.mjs';
|
|
@@ -37,6 +51,7 @@ export { addMilliseconds } from './operators/addMilliseconds.mjs';
|
|
|
37
51
|
export { addMinutes } from './operators/addMinutes.mjs';
|
|
38
52
|
export { addMonths } from './operators/addMonths.mjs';
|
|
39
53
|
export { addSeconds } from './operators/addSeconds.mjs';
|
|
54
|
+
export { addTime } from './operators/addTime.mjs';
|
|
40
55
|
export { addWeeks } from './operators/addWeeks.mjs';
|
|
41
56
|
export { addYears } from './operators/addYears.mjs';
|
|
42
57
|
export { subtractDays } from './operators/subtractDays.mjs';
|
|
@@ -45,11 +60,18 @@ export { subtractMilliseconds } from './operators/subtractMilliseconds.mjs';
|
|
|
45
60
|
export { subtractMinutes } from './operators/subtractMinutes.mjs';
|
|
46
61
|
export { subtractMonths } from './operators/subtractMonths.mjs';
|
|
47
62
|
export { subtractSeconds } from './operators/subtractSeconds.mjs';
|
|
63
|
+
export { subtractTime } from './operators/subtractTime.mjs';
|
|
48
64
|
export { subtractWeeks } from './operators/subtractWeeks.mjs';
|
|
49
65
|
export { subtractYears } from './operators/subtractYears.mjs';
|
|
50
66
|
export { between } from './operators/between.mjs';
|
|
51
67
|
export { betweenThan } from './operators/betweenThan.mjs';
|
|
68
|
+
export { betweenThanTime } from './operators/betweenThanTime.mjs';
|
|
69
|
+
export { betweenTime } from './operators/betweenTime.mjs';
|
|
52
70
|
export { greater } from './operators/greater.mjs';
|
|
53
71
|
export { greaterThan } from './operators/greaterThan.mjs';
|
|
72
|
+
export { greaterThanTime } from './operators/greaterThanTime.mjs';
|
|
73
|
+
export { greaterTime } from './operators/greaterTime.mjs';
|
|
54
74
|
export { less } from './operators/less.mjs';
|
|
55
75
|
export { lessThan } from './operators/lessThan.mjs';
|
|
76
|
+
export { lessThanTime } from './operators/lessThanTime.mjs';
|
|
77
|
+
export { lessTime } from './operators/lessTime.mjs';
|
package/dist/date/is.cjs
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var constants = require('./constants.cjs');
|
|
4
|
+
var isSafeTimestamp = require('./isSafeTimestamp.cjs');
|
|
4
5
|
|
|
5
6
|
function is(input) {
|
|
6
|
-
|
|
7
|
+
const theDateMatch = input.match(constants.theDateRegex);
|
|
8
|
+
if (theDateMatch) {
|
|
9
|
+
const { value, sign } = theDateMatch.groups;
|
|
10
|
+
return isSafeTimestamp.isSafeTimestamp(Number(sign === "-"
|
|
11
|
+
? `-${value}`
|
|
12
|
+
: value));
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
7
15
|
}
|
|
8
16
|
|
|
9
17
|
exports.is = is;
|
package/dist/date/is.mjs
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { theDateRegex } from './constants.mjs';
|
|
2
|
+
import { isSafeTimestamp } from './isSafeTimestamp.mjs';
|
|
2
3
|
|
|
3
4
|
function is(input) {
|
|
4
|
-
|
|
5
|
+
const theDateMatch = input.match(theDateRegex);
|
|
6
|
+
if (theDateMatch) {
|
|
7
|
+
const { value, sign } = theDateMatch.groups;
|
|
8
|
+
return isSafeTimestamp(Number(sign === "-"
|
|
9
|
+
? `-${value}`
|
|
10
|
+
: value));
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
5
13
|
}
|
|
6
14
|
|
|
7
15
|
export { is };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants = require('./constants.cjs');
|
|
4
|
+
|
|
5
|
+
function isSafeTimeValue(timeValue) {
|
|
6
|
+
if (!Number.isSafeInteger(timeValue)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (timeValue <= constants.minTimeValue || timeValue >= constants.maxTimeValue) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.isSafeTimeValue = isSafeTimeValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isSafeTimeValue(timeValue: number): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { minTimeValue, maxTimeValue } from './constants.mjs';
|
|
2
|
+
|
|
3
|
+
function isSafeTimeValue(timeValue) {
|
|
4
|
+
if (!Number.isSafeInteger(timeValue)) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
if (timeValue <= minTimeValue || timeValue >= maxTimeValue) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { isSafeTimeValue };
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var constants = require('./constants.cjs');
|
|
4
4
|
|
|
5
|
-
function isSafeTimestamp(
|
|
6
|
-
if (!Number.isSafeInteger(
|
|
5
|
+
function isSafeTimestamp(timestamp) {
|
|
6
|
+
if (!Number.isSafeInteger(timestamp)) {
|
|
7
7
|
return false;
|
|
8
8
|
}
|
|
9
|
-
if (
|
|
9
|
+
if (timestamp <= constants.minTimestamp || timestamp >= constants.maxTimestamp) {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
12
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function isSafeTimestamp(
|
|
1
|
+
export declare function isSafeTimestamp(timestamp: number): boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { minTimestamp, maxTimestamp } from './constants.mjs';
|
|
2
2
|
|
|
3
|
-
function isSafeTimestamp(
|
|
4
|
-
if (!Number.isSafeInteger(
|
|
3
|
+
function isSafeTimestamp(timestamp) {
|
|
4
|
+
if (!Number.isSafeInteger(timestamp)) {
|
|
5
5
|
return false;
|
|
6
6
|
}
|
|
7
|
-
if (
|
|
7
|
+
if (timestamp <= minTimestamp || timestamp >= maxTimestamp) {
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
10
|
return true;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants = require('./constants.cjs');
|
|
4
|
+
var isSafeTimestamp = require('./isSafeTimestamp.cjs');
|
|
5
|
+
|
|
6
|
+
function isTime(input) {
|
|
7
|
+
const theTimeMatch = input.match(constants.theTimeRegex);
|
|
8
|
+
if (theTimeMatch) {
|
|
9
|
+
const { value, sign } = theTimeMatch.groups;
|
|
10
|
+
return isSafeTimestamp.isSafeTimestamp(Number(sign === "-"
|
|
11
|
+
? `-${value}`
|
|
12
|
+
: value));
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.isTime = isTime;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { theTimeRegex } from './constants.mjs';
|
|
2
|
+
import { isSafeTimestamp } from './isSafeTimestamp.mjs';
|
|
3
|
+
|
|
4
|
+
function isTime(input) {
|
|
5
|
+
const theTimeMatch = input.match(theTimeRegex);
|
|
6
|
+
if (theTimeMatch) {
|
|
7
|
+
const { value, sign } = theTimeMatch.groups;
|
|
8
|
+
return isSafeTimestamp(Number(sign === "-"
|
|
9
|
+
? `-${value}`
|
|
10
|
+
: value));
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { isTime };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants = require('./constants.cjs');
|
|
4
|
+
|
|
5
|
+
function makeSafeTimeValue(timeValue) {
|
|
6
|
+
if (Number.isNaN(timeValue)) {
|
|
7
|
+
return 0;
|
|
8
|
+
}
|
|
9
|
+
if (timeValue > constants.maxTimeValue) {
|
|
10
|
+
return constants.maxTimeValue;
|
|
11
|
+
}
|
|
12
|
+
if (timeValue < constants.minTimeValue) {
|
|
13
|
+
return constants.minTimeValue;
|
|
14
|
+
}
|
|
15
|
+
return Number.isInteger(timeValue)
|
|
16
|
+
? timeValue
|
|
17
|
+
: Math.round(timeValue);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.makeSafeTimeValue = makeSafeTimeValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makeSafeTimeValue(timeValue: number): number;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { maxTimeValue, minTimeValue } from './constants.mjs';
|
|
2
|
+
|
|
3
|
+
function makeSafeTimeValue(timeValue) {
|
|
4
|
+
if (Number.isNaN(timeValue)) {
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
if (timeValue > maxTimeValue) {
|
|
8
|
+
return maxTimeValue;
|
|
9
|
+
}
|
|
10
|
+
if (timeValue < minTimeValue) {
|
|
11
|
+
return minTimeValue;
|
|
12
|
+
}
|
|
13
|
+
return Number.isInteger(timeValue)
|
|
14
|
+
? timeValue
|
|
15
|
+
: Math.round(timeValue);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { makeSafeTimeValue };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants = require('./constants.cjs');
|
|
4
|
+
|
|
5
|
+
function makeSafeTimestamp(timestamp) {
|
|
6
|
+
if (Number.isNaN(timestamp)) {
|
|
7
|
+
return 0;
|
|
8
|
+
}
|
|
9
|
+
if (timestamp > constants.maxTimestamp) {
|
|
10
|
+
return constants.maxTimestamp;
|
|
11
|
+
}
|
|
12
|
+
if (timestamp < constants.minTimestamp) {
|
|
13
|
+
return constants.minTimestamp;
|
|
14
|
+
}
|
|
15
|
+
return Number.isInteger(timestamp)
|
|
16
|
+
? timestamp
|
|
17
|
+
: Math.round(timestamp);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.makeSafeTimestamp = makeSafeTimestamp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makeSafeTimestamp(timestamp: number): number;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { maxTimestamp, minTimestamp } from './constants.mjs';
|
|
2
|
+
|
|
3
|
+
function makeSafeTimestamp(timestamp) {
|
|
4
|
+
if (Number.isNaN(timestamp)) {
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
if (timestamp > maxTimestamp) {
|
|
8
|
+
return maxTimestamp;
|
|
9
|
+
}
|
|
10
|
+
if (timestamp < minTimestamp) {
|
|
11
|
+
return minTimestamp;
|
|
12
|
+
}
|
|
13
|
+
return Number.isInteger(timestamp)
|
|
14
|
+
? timestamp
|
|
15
|
+
: Math.round(timestamp);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { makeSafeTimestamp };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var createTheTime = require('./createTheTime.cjs');
|
|
4
|
+
var toTimeValue = require('./toTimeValue.cjs');
|
|
5
|
+
|
|
6
|
+
function maxTime(input) {
|
|
7
|
+
return createTheTime.createTheTime(Math.max(...input.map(toTimeValue.toTimeValue)));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.maxTime = maxTime;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var createTheTime = require('./createTheTime.cjs');
|
|
4
|
+
var toTimeValue = require('./toTimeValue.cjs');
|
|
5
|
+
|
|
6
|
+
function minTime(input) {
|
|
7
|
+
return createTheTime.createTheTime(Math.min(...input.map(toTimeValue.toTimeValue)));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.minTime = minTime;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var toNative = require('../toNative.cjs');
|
|
4
4
|
var constants = require('../constants.cjs');
|
|
5
|
+
var createTheDate = require('../createTheDate.cjs');
|
|
5
6
|
|
|
6
7
|
function addDays(...args) {
|
|
7
8
|
if (args.length === 1) {
|
|
@@ -11,9 +12,7 @@ function addDays(...args) {
|
|
|
11
12
|
const [input, day] = args;
|
|
12
13
|
const date = toNative.toNative(input);
|
|
13
14
|
date.setTime(date.getTime() + (day * constants.millisecondsInOneDay));
|
|
14
|
-
|
|
15
|
-
const isNegative = timestamp < 0;
|
|
16
|
-
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
15
|
+
return createTheDate.createTheDate(date.getTime());
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
exports.addDays = addDays;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { toNative } from '../toNative.mjs';
|
|
2
2
|
import { millisecondsInOneDay } from '../constants.mjs';
|
|
3
|
+
import { createTheDate } from '../createTheDate.mjs';
|
|
3
4
|
|
|
4
5
|
function addDays(...args) {
|
|
5
6
|
if (args.length === 1) {
|
|
@@ -9,9 +10,7 @@ function addDays(...args) {
|
|
|
9
10
|
const [input, day] = args;
|
|
10
11
|
const date = toNative(input);
|
|
11
12
|
date.setTime(date.getTime() + (day * millisecondsInOneDay));
|
|
12
|
-
|
|
13
|
-
const isNegative = timestamp < 0;
|
|
14
|
-
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
13
|
+
return createTheDate(date.getTime());
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
export { addDays };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var constants = require('../constants.cjs');
|
|
4
|
+
var createTheDate = require('../createTheDate.cjs');
|
|
4
5
|
var toNative = require('../toNative.cjs');
|
|
5
6
|
|
|
6
7
|
function addHours(...args) {
|
|
@@ -11,9 +12,7 @@ function addHours(...args) {
|
|
|
11
12
|
const [input, hour] = args;
|
|
12
13
|
const date = toNative.toNative(input);
|
|
13
14
|
date.setTime(date.getTime() + (hour * constants.millisecondInOneHour));
|
|
14
|
-
|
|
15
|
-
const isNegative = timestamp < 0;
|
|
16
|
-
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
15
|
+
return createTheDate.createTheDate(date.getTime());
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
exports.addHours = addHours;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { millisecondInOneHour } from '../constants.mjs';
|
|
2
|
+
import { createTheDate } from '../createTheDate.mjs';
|
|
2
3
|
import { toNative } from '../toNative.mjs';
|
|
3
4
|
|
|
4
5
|
function addHours(...args) {
|
|
@@ -9,9 +10,7 @@ function addHours(...args) {
|
|
|
9
10
|
const [input, hour] = args;
|
|
10
11
|
const date = toNative(input);
|
|
11
12
|
date.setTime(date.getTime() + (hour * millisecondInOneHour));
|
|
12
|
-
|
|
13
|
-
const isNegative = timestamp < 0;
|
|
14
|
-
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
13
|
+
return createTheDate(date.getTime());
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
export { addHours };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var createTheDate = require('../createTheDate.cjs');
|
|
3
4
|
var toNative = require('../toNative.cjs');
|
|
4
5
|
|
|
5
6
|
function addMilliseconds(...args) {
|
|
@@ -10,9 +11,7 @@ function addMilliseconds(...args) {
|
|
|
10
11
|
const [input, millisecond] = args;
|
|
11
12
|
const date = toNative.toNative(input);
|
|
12
13
|
date.setTime(date.getTime() + millisecond);
|
|
13
|
-
|
|
14
|
-
const isNegative = timestamp < 0;
|
|
15
|
-
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
14
|
+
return createTheDate.createTheDate(date.getTime());
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
exports.addMilliseconds = addMilliseconds;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createTheDate } from '../createTheDate.mjs';
|
|
1
2
|
import { toNative } from '../toNative.mjs';
|
|
2
3
|
|
|
3
4
|
function addMilliseconds(...args) {
|
|
@@ -8,9 +9,7 @@ function addMilliseconds(...args) {
|
|
|
8
9
|
const [input, millisecond] = args;
|
|
9
10
|
const date = toNative(input);
|
|
10
11
|
date.setTime(date.getTime() + millisecond);
|
|
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 { addMilliseconds };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var constants = require('../constants.cjs');
|
|
4
|
+
var createTheDate = require('../createTheDate.cjs');
|
|
4
5
|
var toNative = require('../toNative.cjs');
|
|
5
6
|
|
|
6
7
|
function addMinutes(...args) {
|
|
@@ -11,9 +12,7 @@ function addMinutes(...args) {
|
|
|
11
12
|
const [input, minute] = args;
|
|
12
13
|
const date = toNative.toNative(input);
|
|
13
14
|
date.setTime(date.getTime() + (minute * constants.millisecondInOneMinute));
|
|
14
|
-
|
|
15
|
-
const isNegative = timestamp < 0;
|
|
16
|
-
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
15
|
+
return createTheDate.createTheDate(date.getTime());
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
exports.addMinutes = addMinutes;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { millisecondInOneMinute } from '../constants.mjs';
|
|
2
|
+
import { createTheDate } from '../createTheDate.mjs';
|
|
2
3
|
import { toNative } from '../toNative.mjs';
|
|
3
4
|
|
|
4
5
|
function addMinutes(...args) {
|
|
@@ -9,9 +10,7 @@ function addMinutes(...args) {
|
|
|
9
10
|
const [input, minute] = args;
|
|
10
11
|
const date = toNative(input);
|
|
11
12
|
date.setTime(date.getTime() + (minute * millisecondInOneMinute));
|
|
12
|
-
|
|
13
|
-
const isNegative = timestamp < 0;
|
|
14
|
-
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
13
|
+
return createTheDate(date.getTime());
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
export { addMinutes };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var createTheDate = require('../createTheDate.cjs');
|
|
3
4
|
var toNative = require('../toNative.cjs');
|
|
4
5
|
|
|
5
6
|
function addMonths(...args) {
|
|
@@ -10,9 +11,7 @@ function addMonths(...args) {
|
|
|
10
11
|
const [input, month] = args;
|
|
11
12
|
const date = toNative.toNative(input);
|
|
12
13
|
date.setUTCMonth(date.getUTCMonth() + month);
|
|
13
|
-
|
|
14
|
-
const isNegative = timestamp < 0;
|
|
15
|
-
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
14
|
+
return createTheDate.createTheDate(date.getTime());
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
exports.addMonths = addMonths;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createTheDate } from '../createTheDate.mjs';
|
|
1
2
|
import { toNative } from '../toNative.mjs';
|
|
2
3
|
|
|
3
4
|
function addMonths(...args) {
|
|
@@ -8,9 +9,7 @@ function addMonths(...args) {
|
|
|
8
9
|
const [input, month] = args;
|
|
9
10
|
const date = toNative(input);
|
|
10
11
|
date.setUTCMonth(date.getUTCMonth() + month);
|
|
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 { addMonths };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var constants = require('../constants.cjs');
|
|
4
|
+
var createTheDate = require('../createTheDate.cjs');
|
|
4
5
|
var toNative = require('../toNative.cjs');
|
|
5
6
|
|
|
6
7
|
function addSeconds(...args) {
|
|
@@ -11,9 +12,7 @@ function addSeconds(...args) {
|
|
|
11
12
|
const [input, second] = args;
|
|
12
13
|
const date = toNative.toNative(input);
|
|
13
14
|
date.setTime(date.getTime() + (second * constants.millisecondsInOneSecond));
|
|
14
|
-
|
|
15
|
-
const isNegative = timestamp < 0;
|
|
16
|
-
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
15
|
+
return createTheDate.createTheDate(date.getTime());
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
exports.addSeconds = addSeconds;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { millisecondsInOneSecond } from '../constants.mjs';
|
|
2
|
+
import { createTheDate } from '../createTheDate.mjs';
|
|
2
3
|
import { toNative } from '../toNative.mjs';
|
|
3
4
|
|
|
4
5
|
function addSeconds(...args) {
|
|
@@ -9,9 +10,7 @@ function addSeconds(...args) {
|
|
|
9
10
|
const [input, second] = args;
|
|
10
11
|
const date = toNative(input);
|
|
11
12
|
date.setTime(date.getTime() + (second * millisecondsInOneSecond));
|
|
12
|
-
|
|
13
|
-
const isNegative = timestamp < 0;
|
|
14
|
-
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
13
|
+
return createTheDate(date.getTime());
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
export { addSeconds };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var createTheDate = require('../createTheDate.cjs');
|
|
4
|
+
var createTheTime = require('../createTheTime.cjs');
|
|
5
|
+
var toTimestamp = require('../toTimestamp.cjs');
|
|
6
|
+
var toTimeValue = require('../toTimeValue.cjs');
|
|
7
|
+
|
|
8
|
+
function addTime(...args) {
|
|
9
|
+
if (args.length === 1) {
|
|
10
|
+
const [time] = args;
|
|
11
|
+
return (input) => addTime(input, time);
|
|
12
|
+
}
|
|
13
|
+
const [input, time] = args;
|
|
14
|
+
const timeTimestamp = toTimeValue.toTimeValue(time);
|
|
15
|
+
if (input.startsWith("date")) {
|
|
16
|
+
return createTheDate.createTheDate(toTimestamp.toTimestamp(input) + timeTimestamp);
|
|
17
|
+
}
|
|
18
|
+
return createTheTime.createTheTime(toTimeValue.toTimeValue(input) + timeTimestamp);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.addTime = addTime;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TheDate, TheTime } from "../types";
|
|
2
|
+
export declare function addTime<GenericInput extends TheDate>(time: TheTime): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function addTime<GenericInput extends TheTime>(time: TheTime): (input: GenericInput) => TheTime;
|
|
4
|
+
export declare function addTime<GenericInput extends TheDate>(input: GenericInput, time: TheTime): TheDate;
|
|
5
|
+
export declare function addTime<GenericInput extends TheTime>(input: GenericInput, time: TheTime): TheTime;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createTheDate } from '../createTheDate.mjs';
|
|
2
|
+
import { createTheTime } from '../createTheTime.mjs';
|
|
3
|
+
import { toTimestamp } from '../toTimestamp.mjs';
|
|
4
|
+
import { toTimeValue } from '../toTimeValue.mjs';
|
|
5
|
+
|
|
6
|
+
function addTime(...args) {
|
|
7
|
+
if (args.length === 1) {
|
|
8
|
+
const [time] = args;
|
|
9
|
+
return (input) => addTime(input, time);
|
|
10
|
+
}
|
|
11
|
+
const [input, time] = args;
|
|
12
|
+
const timeTimestamp = toTimeValue(time);
|
|
13
|
+
if (input.startsWith("date")) {
|
|
14
|
+
return createTheDate(toTimestamp(input) + timeTimestamp);
|
|
15
|
+
}
|
|
16
|
+
return createTheTime(toTimeValue(input) + timeTimestamp);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { addTime };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var constants = require('../constants.cjs');
|
|
4
|
+
var createTheDate = require('../createTheDate.cjs');
|
|
4
5
|
var toNative = require('../toNative.cjs');
|
|
5
6
|
|
|
6
7
|
function addWeeks(...args) {
|
|
@@ -11,9 +12,7 @@ function addWeeks(...args) {
|
|
|
11
12
|
const [input, week] = args;
|
|
12
13
|
const date = toNative.toNative(input);
|
|
13
14
|
date.setTime(date.getTime() + (week * constants.millisecondInOneWeek));
|
|
14
|
-
|
|
15
|
-
const isNegative = timestamp < 0;
|
|
16
|
-
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
15
|
+
return createTheDate.createTheDate(date.getTime());
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
exports.addWeeks = addWeeks;
|