@duplojs/utils 1.4.57 → 1.4.59
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/array/group.cjs +11 -11
- package/dist/array/group.d.ts +1 -1
- package/dist/array/group.mjs +11 -11
- package/dist/clean/constraint/base.d.ts +6 -4
- package/dist/clean/constraint/defaultConstraint/index.d.ts +1 -0
- package/dist/clean/constraint/defaultConstraint/number.d.ts +6 -6
- package/dist/clean/constraint/defaultConstraint/string.d.ts +4 -4
- package/dist/clean/constraint/defaultConstraint/time.cjs +19 -0
- package/dist/clean/constraint/defaultConstraint/time.d.ts +61 -0
- package/dist/clean/constraint/defaultConstraint/time.mjs +16 -0
- package/dist/clean/constraint/set.d.ts +6 -4
- package/dist/clean/entity.d.ts +2 -1
- package/dist/clean/index.cjs +3 -0
- package/dist/clean/index.mjs +1 -0
- package/dist/clean/newType.d.ts +7 -5
- package/dist/clean/primitive/base.d.ts +25 -34
- package/dist/clean/primitive/operations/date/dateAddTime.d.ts +7 -11
- package/dist/clean/primitive/operations/date/dateGreaterThan.d.ts +9 -7
- package/dist/clean/primitive/operations/date/dateLessThan.d.ts +9 -7
- package/dist/clean/primitive/operations/date/dateMax.d.ts +3 -10
- package/dist/clean/primitive/operations/date/dateMin.d.ts +3 -10
- package/dist/clean/primitive/operations/date/dateSubtractTime.d.ts +7 -11
- package/dist/clean/primitive/operations/equal.cjs +1 -1
- package/dist/clean/primitive/operations/equal.d.ts +3 -3
- package/dist/clean/primitive/operations/equal.mjs +1 -1
- package/dist/clean/primitive/operations/sort.d.ts +8 -10
- package/dist/clean/primitive/operations/time/timeGreaterThan.d.ts +11 -9
- package/dist/clean/primitive/operations/time/timeLessThan.d.ts +11 -9
- package/dist/clean/primitive/operations/time/timeMax.cjs +2 -2
- package/dist/clean/primitive/operations/time/timeMax.d.ts +10 -17
- package/dist/clean/primitive/operations/time/timeMax.mjs +2 -2
- package/dist/clean/primitive/operations/time/timeMin.cjs +3 -3
- package/dist/clean/primitive/operations/time/timeMin.d.ts +10 -17
- package/dist/clean/primitive/operations/time/timeMin.mjs +3 -3
- package/dist/clean/unwrapEntity.cjs +13 -3
- package/dist/clean/unwrapEntity.d.ts +57 -5
- package/dist/clean/unwrapEntity.mjs +13 -3
- package/dist/common/index.d.ts +3 -4
- package/dist/common/kind.d.ts +1 -0
- package/dist/common/path.cjs +13 -13
- package/dist/common/path.d.ts +17 -11
- package/dist/common/path.mjs +13 -13
- package/dist/common/toRegExp.cjs +19 -0
- package/dist/common/toRegExp.d.ts +31 -0
- package/dist/common/toRegExp.mjs +17 -0
- package/dist/common/transformer.cjs +45 -0
- package/dist/common/transformer.d.ts +61 -0
- package/dist/common/transformer.mjs +40 -0
- package/dist/common/types/DeepReadonly.d.ts +1 -1
- package/dist/common/types/toLargeEnsemble.d.ts +2 -2
- package/dist/dataParser/error.cjs +4 -2
- package/dist/dataParser/error.d.ts +4 -2
- package/dist/dataParser/error.mjs +4 -2
- package/dist/dataParser/extended/date.d.ts +9 -4
- package/dist/dataParser/extended/time.d.ts +28 -12
- package/dist/dataParser/identifier.d.ts +20 -8
- package/dist/dataParser/parsers/date.cjs +16 -12
- package/dist/dataParser/parsers/date.d.ts +15 -9
- package/dist/dataParser/parsers/date.mjs +16 -12
- package/dist/dataParser/parsers/time/checkers/max.cjs +3 -0
- package/dist/dataParser/parsers/time/checkers/max.d.ts +28 -0
- package/dist/dataParser/parsers/time/checkers/max.mjs +3 -0
- package/dist/dataParser/parsers/time/checkers/min.cjs +3 -0
- package/dist/dataParser/parsers/time/checkers/min.d.ts +28 -0
- package/dist/dataParser/parsers/time/checkers/min.mjs +3 -0
- package/dist/dataParser/parsers/time/index.cjs +14 -10
- package/dist/dataParser/parsers/time/index.d.ts +15 -9
- package/dist/dataParser/parsers/time/index.mjs +14 -10
- package/dist/date/applyTimezone.cjs +4 -4
- package/dist/date/applyTimezone.d.ts +18 -16
- package/dist/date/applyTimezone.mjs +2 -2
- package/dist/date/closestTo.cjs +6 -2
- package/dist/date/closestTo.d.ts +15 -15
- package/dist/date/closestTo.mjs +6 -2
- package/dist/date/constants.cjs +4 -4
- package/dist/date/constants.d.ts +2 -2
- package/dist/date/constants.mjs +3 -3
- package/dist/date/create.cjs +20 -10
- package/dist/date/create.d.ts +24 -38
- package/dist/date/create.mjs +21 -11
- package/dist/date/createOrThrow.d.ts +18 -20
- package/dist/date/createTime.cjs +16 -7
- package/dist/date/createTime.d.ts +19 -18
- package/dist/date/createTime.mjs +17 -8
- package/dist/date/createTimeOrThrow.d.ts +17 -20
- package/dist/date/each.cjs +6 -4
- package/dist/date/each.d.ts +21 -19
- package/dist/date/each.mjs +6 -4
- package/dist/date/format.d.ts +17 -15
- package/dist/date/formatTime.d.ts +17 -16
- package/dist/date/getTimezoneOffset.cjs +6 -3
- package/dist/date/getTimezoneOffset.d.ts +17 -18
- package/dist/date/getTimezoneOffset.mjs +6 -3
- package/dist/date/getters/getDayOfMonth.cjs +3 -3
- package/dist/date/getters/getDayOfMonth.d.ts +20 -14
- package/dist/date/getters/getDayOfMonth.mjs +3 -3
- package/dist/date/getters/getDayOfWeek.cjs +3 -3
- package/dist/date/getters/getDayOfWeek.d.ts +15 -12
- package/dist/date/getters/getDayOfWeek.mjs +3 -3
- package/dist/date/getters/getDayOfYear.cjs +6 -6
- package/dist/date/getters/getDayOfYear.d.ts +21 -13
- package/dist/date/getters/getDayOfYear.mjs +6 -6
- package/dist/date/getters/getFirstDayOfMonth.cjs +2 -3
- package/dist/date/getters/getFirstDayOfMonth.d.ts +16 -10
- package/dist/date/getters/getFirstDayOfMonth.mjs +2 -3
- package/dist/date/getters/getFirstDayOfWeek.cjs +2 -3
- package/dist/date/getters/getFirstDayOfWeek.d.ts +17 -10
- package/dist/date/getters/getFirstDayOfWeek.mjs +2 -3
- package/dist/date/getters/getHour.cjs +3 -3
- package/dist/date/getters/getHour.d.ts +16 -14
- package/dist/date/getters/getHour.mjs +3 -3
- package/dist/date/getters/getLastDayOfMonth.cjs +2 -3
- package/dist/date/getters/getLastDayOfMonth.d.ts +16 -10
- package/dist/date/getters/getLastDayOfMonth.mjs +2 -3
- package/dist/date/getters/getLastDayOfWeek.cjs +2 -3
- package/dist/date/getters/getLastDayOfWeek.d.ts +17 -10
- package/dist/date/getters/getLastDayOfWeek.mjs +2 -3
- package/dist/date/getters/getMilliseconds.cjs +2 -2
- package/dist/date/getters/getMilliseconds.d.ts +11 -9
- package/dist/date/getters/getMilliseconds.mjs +2 -2
- package/dist/date/getters/getMinute.cjs +3 -3
- package/dist/date/getters/getMinute.d.ts +17 -15
- package/dist/date/getters/getMinute.mjs +3 -3
- package/dist/date/getters/getMonth.cjs +3 -3
- package/dist/date/getters/getMonth.d.ts +20 -15
- package/dist/date/getters/getMonth.mjs +3 -3
- package/dist/date/getters/getSecond.cjs +3 -3
- package/dist/date/getters/getSecond.d.ts +17 -15
- package/dist/date/getters/getSecond.mjs +3 -3
- package/dist/date/getters/getWeekOfYear.cjs +12 -11
- package/dist/date/getters/getWeekOfYear.d.ts +17 -11
- package/dist/date/getters/getWeekOfYear.mjs +12 -11
- package/dist/date/getters/getYear.cjs +3 -3
- package/dist/date/getters/getYear.d.ts +16 -15
- package/dist/date/getters/getYear.mjs +3 -3
- package/dist/date/index.cjs +12 -6
- package/dist/date/index.d.ts +5 -2
- package/dist/date/index.mjs +6 -3
- package/dist/date/is.cjs +3 -8
- package/dist/date/is.d.ts +9 -14
- package/dist/date/is.mjs +3 -8
- package/dist/date/isSafeTimeValue.d.ts +9 -13
- package/dist/date/isSafeTimestamp.d.ts +7 -16
- package/dist/date/isSerializedTheDate.cjs +20 -0
- package/dist/date/isSerializedTheDate.d.ts +31 -0
- package/dist/date/isSerializedTheDate.mjs +18 -0
- package/dist/date/isSerializedTheTime.cjs +20 -0
- package/dist/date/isSerializedTheTime.d.ts +31 -0
- package/dist/date/isSerializedTheTime.mjs +18 -0
- package/dist/date/isTime.cjs +3 -8
- package/dist/date/isTime.d.ts +7 -14
- package/dist/date/isTime.mjs +3 -8
- package/dist/date/kind.cjs +9 -0
- package/dist/date/kind.d.ts +1 -0
- package/dist/date/kind.mjs +7 -0
- package/dist/date/makeSafeTimeValue.d.ts +12 -11
- package/dist/date/makeSafeTimestamp.d.ts +12 -11
- package/dist/date/max.cjs +2 -2
- package/dist/date/max.d.ts +13 -13
- package/dist/date/max.mjs +2 -2
- package/dist/date/maxTime.cjs +2 -2
- package/dist/date/maxTime.d.ts +13 -21
- package/dist/date/maxTime.mjs +2 -2
- package/dist/date/min.cjs +2 -2
- package/dist/date/min.d.ts +13 -13
- package/dist/date/min.mjs +2 -2
- package/dist/date/minTime.cjs +2 -2
- package/dist/date/minTime.d.ts +13 -21
- package/dist/date/minTime.mjs +2 -2
- package/dist/date/now.cjs +3 -1
- package/dist/date/now.d.ts +9 -7
- package/dist/date/now.mjs +3 -1
- package/dist/date/operators/addDays.cjs +3 -5
- package/dist/date/operators/addDays.d.ts +14 -11
- package/dist/date/operators/addDays.mjs +3 -5
- package/dist/date/operators/addHours.cjs +3 -5
- package/dist/date/operators/addHours.d.ts +14 -11
- package/dist/date/operators/addHours.mjs +3 -5
- package/dist/date/operators/addMilliseconds.cjs +3 -5
- package/dist/date/operators/addMilliseconds.d.ts +14 -11
- package/dist/date/operators/addMilliseconds.mjs +3 -5
- package/dist/date/operators/addMinutes.cjs +3 -5
- package/dist/date/operators/addMinutes.d.ts +14 -11
- package/dist/date/operators/addMinutes.mjs +3 -5
- package/dist/date/operators/addMonths.cjs +2 -2
- package/dist/date/operators/addMonths.d.ts +13 -13
- package/dist/date/operators/addMonths.mjs +2 -2
- package/dist/date/operators/addSeconds.cjs +3 -5
- package/dist/date/operators/addSeconds.d.ts +14 -11
- package/dist/date/operators/addSeconds.mjs +3 -5
- package/dist/date/operators/addTime.cjs +13 -6
- package/dist/date/operators/addTime.d.ts +20 -18
- package/dist/date/operators/addTime.mjs +13 -6
- package/dist/date/operators/addWeeks.cjs +6 -5
- package/dist/date/operators/addWeeks.d.ts +14 -11
- package/dist/date/operators/addWeeks.mjs +6 -5
- package/dist/date/operators/addYears.cjs +2 -2
- package/dist/date/operators/addYears.d.ts +13 -13
- package/dist/date/operators/addYears.mjs +2 -2
- package/dist/date/operators/between.d.ts +11 -11
- package/dist/date/operators/betweenThan.d.ts +11 -11
- package/dist/date/operators/betweenThanTime.d.ts +18 -22
- package/dist/date/operators/betweenTime.d.ts +17 -21
- package/dist/date/operators/greater.d.ts +12 -9
- package/dist/date/operators/greaterThan.d.ts +14 -11
- package/dist/date/operators/greaterThanTime.d.ts +17 -21
- package/dist/date/operators/greaterTime.d.ts +16 -20
- package/dist/date/operators/less.d.ts +12 -9
- package/dist/date/operators/lessThan.d.ts +13 -10
- package/dist/date/operators/lessThanTime.d.ts +17 -21
- package/dist/date/operators/lessTime.d.ts +16 -20
- package/dist/date/operators/subtractDays.cjs +3 -5
- package/dist/date/operators/subtractDays.d.ts +14 -11
- package/dist/date/operators/subtractDays.mjs +3 -5
- package/dist/date/operators/subtractHours.cjs +3 -5
- package/dist/date/operators/subtractHours.d.ts +14 -11
- package/dist/date/operators/subtractHours.mjs +3 -5
- package/dist/date/operators/subtractMilliseconds.cjs +3 -5
- package/dist/date/operators/subtractMilliseconds.d.ts +14 -11
- package/dist/date/operators/subtractMilliseconds.mjs +3 -5
- package/dist/date/operators/subtractMinutes.cjs +3 -5
- package/dist/date/operators/subtractMinutes.d.ts +14 -11
- package/dist/date/operators/subtractMinutes.mjs +3 -5
- package/dist/date/operators/subtractMonths.cjs +2 -2
- package/dist/date/operators/subtractMonths.d.ts +17 -11
- package/dist/date/operators/subtractMonths.mjs +2 -2
- package/dist/date/operators/subtractSeconds.cjs +3 -5
- package/dist/date/operators/subtractSeconds.d.ts +14 -11
- package/dist/date/operators/subtractSeconds.mjs +3 -5
- package/dist/date/operators/subtractTime.cjs +13 -6
- package/dist/date/operators/subtractTime.d.ts +20 -18
- package/dist/date/operators/subtractTime.mjs +13 -6
- package/dist/date/operators/subtractWeeks.cjs +3 -5
- package/dist/date/operators/subtractWeeks.d.ts +14 -11
- package/dist/date/operators/subtractWeeks.mjs +3 -5
- package/dist/date/operators/subtractYears.cjs +2 -2
- package/dist/date/operators/subtractYears.d.ts +17 -11
- package/dist/date/operators/subtractYears.mjs +2 -2
- package/dist/date/round.cjs +2 -2
- package/dist/date/round.d.ts +11 -14
- package/dist/date/round.mjs +2 -2
- package/dist/date/serialize.cjs +14 -0
- package/dist/date/serialize.d.ts +41 -0
- package/dist/date/serialize.mjs +12 -0
- package/dist/date/sort.cjs +2 -2
- package/dist/date/sort.d.ts +16 -15
- package/dist/date/sort.mjs +2 -2
- package/dist/date/sortTimes.cjs +2 -2
- package/dist/date/sortTimes.d.ts +15 -21
- package/dist/date/sortTimes.mjs +2 -2
- package/dist/date/theDate.cjs +124 -0
- package/dist/date/theDate.d.ts +114 -0
- package/dist/date/theDate.mjs +122 -0
- package/dist/date/theTime.cjs +36 -0
- package/dist/date/theTime.d.ts +53 -0
- package/dist/date/theTime.mjs +34 -0
- package/dist/date/timezone.cjs +3 -0
- package/dist/date/timezone.d.ts +27 -0
- package/dist/date/timezone.mjs +3 -0
- package/dist/date/toISOString.cjs +5 -2
- package/dist/date/toISOString.d.ts +12 -10
- package/dist/date/toISOString.mjs +5 -2
- package/dist/date/toNative.cjs +4 -0
- package/dist/date/toNative.d.ts +12 -10
- package/dist/date/toNative.mjs +4 -0
- package/dist/date/toTimeValue.cjs +6 -2
- package/dist/date/toTimeValue.d.ts +14 -12
- package/dist/date/toTimeValue.mjs +6 -2
- package/dist/date/toTimestamp.cjs +5 -3
- package/dist/date/toTimestamp.d.ts +11 -9
- package/dist/date/toTimestamp.mjs +6 -4
- package/dist/date/today.cjs +3 -1
- package/dist/date/today.d.ts +14 -7
- package/dist/date/today.mjs +3 -1
- package/dist/date/tomorrow.cjs +2 -1
- package/dist/date/tomorrow.d.ts +12 -7
- package/dist/date/tomorrow.mjs +2 -1
- package/dist/date/types/index.d.ts +2 -2
- package/dist/date/types/serializedTheDate.d.ts +1 -0
- package/dist/date/types/serializedTheTime.d.ts +42 -0
- package/dist/date/types/spoolingDate.d.ts +2 -1
- package/dist/date/yesterday.cjs +2 -1
- package/dist/date/yesterday.d.ts +12 -7
- package/dist/date/yesterday.mjs +2 -1
- package/dist/generator/asyncGroup.cjs +31 -0
- package/dist/generator/asyncGroup.d.ts +39 -0
- package/dist/generator/asyncGroup.mjs +29 -0
- package/dist/generator/group.cjs +39 -0
- package/dist/generator/group.d.ts +101 -0
- package/dist/generator/group.mjs +36 -0
- package/dist/generator/index.cjs +5 -0
- package/dist/generator/index.d.ts +3 -0
- package/dist/generator/index.mjs +2 -0
- package/dist/index.cjs +7 -6
- package/dist/index.mjs +2 -3
- package/dist/metadata.json +94 -40
- package/dist/object/entries.cjs +7 -2
- package/dist/object/entries.mjs +7 -2
- package/dist/object/keys.cjs +7 -2
- package/dist/object/keys.d.ts +1 -1
- package/dist/object/keys.mjs +7 -2
- package/package.json +1 -1
- package/dist/common/toJSON.cjs +0 -37
- package/dist/common/toJSON.d.ts +0 -44
- package/dist/common/toJSON.mjs +0 -35
- package/dist/common/toString.cjs +0 -10
- package/dist/common/toString.d.ts +0 -17
- package/dist/common/toString.mjs +0 -8
- package/dist/common/toTransform.cjs +0 -37
- package/dist/common/toTransform.d.ts +0 -50
- package/dist/common/toTransform.mjs +0 -35
- package/dist/date/createTheDate.cjs +0 -13
- package/dist/date/createTheDate.d.ts +0 -28
- package/dist/date/createTheDate.mjs +0 -11
- package/dist/date/createTheTime.cjs +0 -13
- package/dist/date/createTheTime.d.ts +0 -25
- package/dist/date/createTheTime.mjs +0 -11
- package/dist/date/types/theDate.d.ts +0 -11
- package/dist/date/types/theTime.d.ts +0 -10
package/dist/date/minTime.d.ts
CHANGED
|
@@ -1,31 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { AnyTuple } from "../common/types/anyTuple";
|
|
2
|
+
import { TheTime } from "./theTime";
|
|
3
|
+
import type { SerializedTheTime } from "./types";
|
|
3
4
|
/**
|
|
4
|
-
* Returns the smallest
|
|
5
|
+
* Returns the smallest duration from a tuple of time values.
|
|
5
6
|
*
|
|
6
|
-
* Signature: `minTime(input)` →
|
|
7
|
-
*
|
|
8
|
-
* The input value is not mutated.
|
|
7
|
+
* Signature: `minTime(input)` → `TheTime`
|
|
9
8
|
*
|
|
10
9
|
* ```ts
|
|
11
|
-
* const
|
|
12
|
-
* D.
|
|
13
|
-
* D.
|
|
14
|
-
*
|
|
15
|
-
* ]);
|
|
16
|
-
* //
|
|
10
|
+
* const value = D.minTime([
|
|
11
|
+
* D.createTime(3_000, "millisecond"),
|
|
12
|
+
* D.createTime(1_000, "millisecond"),
|
|
13
|
+
* "time2000+",
|
|
14
|
+
* ] as const);
|
|
15
|
+
* // value: TheTime
|
|
17
16
|
*
|
|
18
|
-
* const
|
|
17
|
+
* const value2 = D.minTime([
|
|
19
18
|
* "time3000-",
|
|
20
19
|
* "time1000-",
|
|
21
20
|
* ] as const);
|
|
22
|
-
* // result2: "time3000-"
|
|
23
|
-
*
|
|
24
|
-
* const result3 = D.minTime([
|
|
25
|
-
* "time500+",
|
|
26
|
-
* "time100+",
|
|
27
|
-
* ] as const);
|
|
28
|
-
* // result3: "time100+"
|
|
29
21
|
* ```
|
|
30
22
|
*
|
|
31
23
|
* @see https://utils.duplojs.dev/en/v1/api/date/minTime
|
|
@@ -33,4 +25,4 @@ import { type TheTime } from "./types";
|
|
|
33
25
|
* @namespace D
|
|
34
26
|
*
|
|
35
27
|
*/
|
|
36
|
-
export declare function minTime<GenericInput extends AnyTuple<TheTime>>(input: GenericInput):
|
|
28
|
+
export declare function minTime<GenericInput extends AnyTuple<TheTime | SerializedTheTime>>(input: GenericInput): TheTime;
|
package/dist/date/minTime.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TheTime } from './theTime.mjs';
|
|
2
2
|
import { toTimeValue } from './toTimeValue.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* {@include date/minTime/index.md}
|
|
6
6
|
*/
|
|
7
7
|
function minTime(input) {
|
|
8
|
-
return
|
|
8
|
+
return TheTime.new(Math.min(...input.map(toTimeValue)));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export { minTime };
|
package/dist/date/now.cjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var theDate = require('./theDate.cjs');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* {@include date/now/index.md}
|
|
5
7
|
*/
|
|
6
8
|
function now() {
|
|
7
9
|
const timestamp = Date.now();
|
|
8
|
-
return
|
|
10
|
+
return theDate.TheDate.new(timestamp);
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
exports.now = now;
|
package/dist/date/now.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { TheDate } from "./theDate";
|
|
1
2
|
/**
|
|
2
|
-
* Returns the current
|
|
3
|
+
* Returns the current instant as `TheDate`.
|
|
3
4
|
*
|
|
4
|
-
* Signature: `now()` →
|
|
5
|
-
*
|
|
6
|
-
* The input value is not mutated.
|
|
5
|
+
* Signature: `now()` → `TheDate`
|
|
7
6
|
*
|
|
8
7
|
* ```ts
|
|
9
|
-
* const
|
|
10
|
-
* //
|
|
8
|
+
* const value = D.now();
|
|
9
|
+
* // value: TheDate
|
|
10
|
+
*
|
|
11
|
+
* const timestamp = value.getTime();
|
|
12
|
+
* // timestamp: number
|
|
11
13
|
*
|
|
12
14
|
* ```
|
|
13
15
|
*
|
|
@@ -16,4 +18,4 @@
|
|
|
16
18
|
* @namespace D
|
|
17
19
|
*
|
|
18
20
|
*/
|
|
19
|
-
export declare function now():
|
|
21
|
+
export declare function now(): TheDate;
|
package/dist/date/now.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var toNative = require('../toNative.cjs');
|
|
4
3
|
var constants = require('../constants.cjs');
|
|
5
|
-
var
|
|
4
|
+
var theDate = require('../theDate.cjs');
|
|
5
|
+
var toTimestamp = require('../toTimestamp.cjs');
|
|
6
6
|
|
|
7
7
|
function addDays(...args) {
|
|
8
8
|
if (args.length === 1) {
|
|
@@ -10,9 +10,7 @@ function addDays(...args) {
|
|
|
10
10
|
return (input) => addDays(input, day);
|
|
11
11
|
}
|
|
12
12
|
const [input, day] = args;
|
|
13
|
-
|
|
14
|
-
date.setTime(date.getTime() + (day * constants.millisecondsInOneDay));
|
|
15
|
-
return createTheDate.createTheDate(date.getTime());
|
|
13
|
+
return theDate.TheDate.new(toTimestamp.toTimestamp(input) + (day * constants.millisecondsInOneDay));
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
exports.addDays = addDays;
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TheDate } from "../theDate";
|
|
2
|
+
import type { SerializedTheDate } from "../types";
|
|
2
3
|
/**
|
|
3
|
-
* Adds days to a date.
|
|
4
|
+
* Adds a number of days to a date.
|
|
4
5
|
*
|
|
5
6
|
* **Supported call styles:**
|
|
6
|
-
* - Classic: `addDays(input, day)` →
|
|
7
|
-
* - Curried: `addDays(day)` →
|
|
7
|
+
* - Classic: `addDays(input, day)` → `TheDate`
|
|
8
|
+
* - Curried: `addDays(day)` → `(input) => TheDate`
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
+
* `input` accepts `TheDate` or `SerializedTheDate`.
|
|
10
11
|
*
|
|
11
12
|
* ```ts
|
|
12
13
|
* const input = D.create("2024-06-15");
|
|
13
14
|
* const result = D.addDays(input, 5);
|
|
14
|
-
* // result:
|
|
15
|
+
* // result: TheDate
|
|
16
|
+
*
|
|
17
|
+
* const serialized = D.serialize(result);
|
|
18
|
+
* // serialized: SerializedTheDate
|
|
15
19
|
*
|
|
16
20
|
* pipe(
|
|
17
|
-
*
|
|
21
|
+
* serialized,
|
|
18
22
|
* D.addDays(5),
|
|
19
|
-
* ); //
|
|
20
|
-
*
|
|
23
|
+
* ); // TheDate
|
|
21
24
|
* ```
|
|
22
25
|
*
|
|
23
26
|
* @see https://utils.duplojs.dev/en/v1/api/date/addDays
|
|
@@ -25,5 +28,5 @@ import type { TheDate } from "../types";
|
|
|
25
28
|
* @namespace D
|
|
26
29
|
*
|
|
27
30
|
*/
|
|
28
|
-
export declare function addDays<GenericInput extends TheDate, GenericDay extends number>(day: GenericDay): (input: GenericInput) => TheDate;
|
|
29
|
-
export declare function addDays<GenericInput extends TheDate, GenericDay extends number>(input: GenericInput, day: GenericDay): TheDate;
|
|
31
|
+
export declare function addDays<GenericInput extends TheDate | SerializedTheDate, GenericDay extends number>(day: GenericDay): (input: GenericInput) => TheDate;
|
|
32
|
+
export declare function addDays<GenericInput extends TheDate | SerializedTheDate, GenericDay extends number>(input: GenericInput, day: GenericDay): TheDate;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { toNative } from '../toNative.mjs';
|
|
2
1
|
import { millisecondsInOneDay } from '../constants.mjs';
|
|
3
|
-
import {
|
|
2
|
+
import { TheDate } from '../theDate.mjs';
|
|
3
|
+
import { toTimestamp } from '../toTimestamp.mjs';
|
|
4
4
|
|
|
5
5
|
function addDays(...args) {
|
|
6
6
|
if (args.length === 1) {
|
|
@@ -8,9 +8,7 @@ function addDays(...args) {
|
|
|
8
8
|
return (input) => addDays(input, day);
|
|
9
9
|
}
|
|
10
10
|
const [input, day] = args;
|
|
11
|
-
|
|
12
|
-
date.setTime(date.getTime() + (day * millisecondsInOneDay));
|
|
13
|
-
return createTheDate(date.getTime());
|
|
11
|
+
return TheDate.new(toTimestamp(input) + (day * millisecondsInOneDay));
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
export { addDays };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var constants = require('../constants.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var theDate = require('../theDate.cjs');
|
|
5
|
+
var toTimestamp = require('../toTimestamp.cjs');
|
|
6
6
|
|
|
7
7
|
function addHours(...args) {
|
|
8
8
|
if (args.length === 1) {
|
|
@@ -10,9 +10,7 @@ function addHours(...args) {
|
|
|
10
10
|
return (input) => addHours(input, hour);
|
|
11
11
|
}
|
|
12
12
|
const [input, hour] = args;
|
|
13
|
-
|
|
14
|
-
date.setTime(date.getTime() + (hour * constants.millisecondInOneHour));
|
|
15
|
-
return createTheDate.createTheDate(date.getTime());
|
|
13
|
+
return theDate.TheDate.new(toTimestamp.toTimestamp(input) + (hour * constants.millisecondInOneHour));
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
exports.addHours = addHours;
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TheDate } from "../theDate";
|
|
2
|
+
import type { SerializedTheDate } from "../types";
|
|
2
3
|
/**
|
|
3
|
-
* Adds hours to a date.
|
|
4
|
+
* Adds a number of hours to a date.
|
|
4
5
|
*
|
|
5
6
|
* **Supported call styles:**
|
|
6
|
-
* - Classic: `addHours(input, hour)` →
|
|
7
|
-
* - Curried: `addHours(hour)` →
|
|
7
|
+
* - Classic: `addHours(input, hour)` → `TheDate`
|
|
8
|
+
* - Curried: `addHours(hour)` → `(input) => TheDate`
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
+
* `input` accepts `TheDate` or `SerializedTheDate`.
|
|
10
11
|
*
|
|
11
12
|
* ```ts
|
|
12
13
|
* const input = D.create("2024-06-20");
|
|
13
14
|
* const result = D.addHours(input, 2);
|
|
14
|
-
* // result:
|
|
15
|
+
* // result: TheDate
|
|
16
|
+
*
|
|
17
|
+
* const serialized = D.serialize(result);
|
|
18
|
+
* // serialized: SerializedTheDate
|
|
15
19
|
*
|
|
16
20
|
* pipe(
|
|
17
|
-
*
|
|
21
|
+
* serialized,
|
|
18
22
|
* D.addHours(2),
|
|
19
|
-
* ); //
|
|
20
|
-
*
|
|
23
|
+
* ); // TheDate
|
|
21
24
|
* ```
|
|
22
25
|
*
|
|
23
26
|
* @see https://utils.duplojs.dev/en/v1/api/date/addHours
|
|
@@ -25,5 +28,5 @@ import type { TheDate } from "../types";
|
|
|
25
28
|
* @namespace D
|
|
26
29
|
*
|
|
27
30
|
*/
|
|
28
|
-
export declare function addHours<GenericInput extends TheDate, GenericHour extends number>(hour: GenericHour): (input: GenericInput) => TheDate;
|
|
29
|
-
export declare function addHours<GenericInput extends TheDate, GenericHour extends number>(input: GenericInput, hour: GenericHour): TheDate;
|
|
31
|
+
export declare function addHours<GenericInput extends TheDate | SerializedTheDate, GenericHour extends number>(hour: GenericHour): (input: GenericInput) => TheDate;
|
|
32
|
+
export declare function addHours<GenericInput extends TheDate | SerializedTheDate, GenericHour extends number>(input: GenericInput, hour: GenericHour): TheDate;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { millisecondInOneHour } from '../constants.mjs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { TheDate } from '../theDate.mjs';
|
|
3
|
+
import { toTimestamp } from '../toTimestamp.mjs';
|
|
4
4
|
|
|
5
5
|
function addHours(...args) {
|
|
6
6
|
if (args.length === 1) {
|
|
@@ -8,9 +8,7 @@ function addHours(...args) {
|
|
|
8
8
|
return (input) => addHours(input, hour);
|
|
9
9
|
}
|
|
10
10
|
const [input, hour] = args;
|
|
11
|
-
|
|
12
|
-
date.setTime(date.getTime() + (hour * millisecondInOneHour));
|
|
13
|
-
return createTheDate(date.getTime());
|
|
11
|
+
return TheDate.new(toTimestamp(input) + (hour * millisecondInOneHour));
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
export { addHours };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var theDate = require('../theDate.cjs');
|
|
4
|
+
var toTimestamp = require('../toTimestamp.cjs');
|
|
5
5
|
|
|
6
6
|
function addMilliseconds(...args) {
|
|
7
7
|
if (args.length === 1) {
|
|
@@ -9,9 +9,7 @@ function addMilliseconds(...args) {
|
|
|
9
9
|
return (input) => addMilliseconds(input, millisecond);
|
|
10
10
|
}
|
|
11
11
|
const [input, millisecond] = args;
|
|
12
|
-
|
|
13
|
-
date.setTime(date.getTime() + millisecond);
|
|
14
|
-
return createTheDate.createTheDate(date.getTime());
|
|
12
|
+
return theDate.TheDate.new(toTimestamp.toTimestamp(input) + millisecond);
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
exports.addMilliseconds = addMilliseconds;
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TheDate } from "../theDate";
|
|
2
|
+
import type { SerializedTheDate } from "../types";
|
|
2
3
|
/**
|
|
3
|
-
* Adds milliseconds to a date.
|
|
4
|
+
* Adds a number of milliseconds to a date.
|
|
4
5
|
*
|
|
5
6
|
* **Supported call styles:**
|
|
6
|
-
* - Classic: `addMilliseconds(input, millisecond)` →
|
|
7
|
-
* - Curried: `addMilliseconds(millisecond)` →
|
|
7
|
+
* - Classic: `addMilliseconds(input, millisecond)` → `TheDate`
|
|
8
|
+
* - Curried: `addMilliseconds(millisecond)` → `(input) => TheDate`
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
+
* `input` accepts `TheDate` or `SerializedTheDate`.
|
|
10
11
|
*
|
|
11
12
|
* ```ts
|
|
12
13
|
* const input = D.create("2024-06-20");
|
|
13
14
|
* const result = D.addMilliseconds(input, 10);
|
|
14
|
-
* // result:
|
|
15
|
+
* // result: TheDate
|
|
16
|
+
*
|
|
17
|
+
* const serialized = D.serialize(result);
|
|
18
|
+
* // serialized: SerializedTheDate
|
|
15
19
|
*
|
|
16
20
|
* pipe(
|
|
17
|
-
*
|
|
21
|
+
* serialized,
|
|
18
22
|
* D.addMilliseconds(10),
|
|
19
|
-
* ); //
|
|
20
|
-
*
|
|
23
|
+
* ); // TheDate
|
|
21
24
|
* ```
|
|
22
25
|
*
|
|
23
26
|
* @see https://utils.duplojs.dev/en/v1/api/date/addMilliseconds
|
|
@@ -25,5 +28,5 @@ import type { TheDate } from "../types";
|
|
|
25
28
|
* @namespace D
|
|
26
29
|
*
|
|
27
30
|
*/
|
|
28
|
-
export declare function addMilliseconds<GenericInput extends TheDate, GenericMillisecond extends number>(millisecond: GenericMillisecond): (input: GenericInput) => TheDate;
|
|
29
|
-
export declare function addMilliseconds<GenericInput extends TheDate, GenericMillisecond extends number>(input: GenericInput, millisecond: GenericMillisecond): TheDate;
|
|
31
|
+
export declare function addMilliseconds<GenericInput extends TheDate | SerializedTheDate, GenericMillisecond extends number>(millisecond: GenericMillisecond): (input: GenericInput) => TheDate;
|
|
32
|
+
export declare function addMilliseconds<GenericInput extends TheDate | SerializedTheDate, GenericMillisecond extends number>(input: GenericInput, millisecond: GenericMillisecond): TheDate;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { TheDate } from '../theDate.mjs';
|
|
2
|
+
import { toTimestamp } from '../toTimestamp.mjs';
|
|
3
3
|
|
|
4
4
|
function addMilliseconds(...args) {
|
|
5
5
|
if (args.length === 1) {
|
|
@@ -7,9 +7,7 @@ function addMilliseconds(...args) {
|
|
|
7
7
|
return (input) => addMilliseconds(input, millisecond);
|
|
8
8
|
}
|
|
9
9
|
const [input, millisecond] = args;
|
|
10
|
-
|
|
11
|
-
date.setTime(date.getTime() + millisecond);
|
|
12
|
-
return createTheDate(date.getTime());
|
|
10
|
+
return TheDate.new(toTimestamp(input) + millisecond);
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
export { addMilliseconds };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var constants = require('../constants.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var theDate = require('../theDate.cjs');
|
|
5
|
+
var toTimestamp = require('../toTimestamp.cjs');
|
|
6
6
|
|
|
7
7
|
function addMinutes(...args) {
|
|
8
8
|
if (args.length === 1) {
|
|
@@ -10,9 +10,7 @@ function addMinutes(...args) {
|
|
|
10
10
|
return (input) => addMinutes(input, minute);
|
|
11
11
|
}
|
|
12
12
|
const [input, minute] = args;
|
|
13
|
-
|
|
14
|
-
date.setTime(date.getTime() + (minute * constants.millisecondInOneMinute));
|
|
15
|
-
return createTheDate.createTheDate(date.getTime());
|
|
13
|
+
return theDate.TheDate.new(toTimestamp.toTimestamp(input) + (minute * constants.millisecondInOneMinute));
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
exports.addMinutes = addMinutes;
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TheDate } from "../theDate";
|
|
2
|
+
import type { SerializedTheDate } from "../types";
|
|
2
3
|
/**
|
|
3
|
-
* Adds minutes to a date.
|
|
4
|
+
* Adds a number of minutes to a date.
|
|
4
5
|
*
|
|
5
6
|
* **Supported call styles:**
|
|
6
|
-
* - Classic: `addMinutes(input, minute)` →
|
|
7
|
-
* - Curried: `addMinutes(minute)` →
|
|
7
|
+
* - Classic: `addMinutes(input, minute)` → `TheDate`
|
|
8
|
+
* - Curried: `addMinutes(minute)` → `(input) => TheDate`
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
+
* `input` accepts `TheDate` or `SerializedTheDate`.
|
|
10
11
|
*
|
|
11
12
|
* ```ts
|
|
12
13
|
* const input = D.create("2024-06-20");
|
|
13
14
|
* const result = D.addMinutes(input, 45);
|
|
14
|
-
* // result:
|
|
15
|
+
* // result: TheDate
|
|
16
|
+
*
|
|
17
|
+
* const serialized = D.serialize(result);
|
|
18
|
+
* // serialized: SerializedTheDate
|
|
15
19
|
*
|
|
16
20
|
* pipe(
|
|
17
|
-
*
|
|
21
|
+
* serialized,
|
|
18
22
|
* D.addMinutes(45),
|
|
19
|
-
* ); //
|
|
20
|
-
*
|
|
23
|
+
* ); // TheDate
|
|
21
24
|
* ```
|
|
22
25
|
*
|
|
23
26
|
* @see https://utils.duplojs.dev/en/v1/api/date/addMinutes
|
|
@@ -25,5 +28,5 @@ import type { TheDate } from "../types";
|
|
|
25
28
|
* @namespace D
|
|
26
29
|
*
|
|
27
30
|
*/
|
|
28
|
-
export declare function addMinutes<GenericInput extends TheDate, GenericMinute extends number>(minute: GenericMinute): (input: GenericInput) => TheDate;
|
|
29
|
-
export declare function addMinutes<GenericInput extends TheDate, GenericMinute extends number>(input: GenericInput, minute: GenericMinute): TheDate;
|
|
31
|
+
export declare function addMinutes<GenericInput extends TheDate | SerializedTheDate, GenericMinute extends number>(minute: GenericMinute): (input: GenericInput) => TheDate;
|
|
32
|
+
export declare function addMinutes<GenericInput extends TheDate | SerializedTheDate, GenericMinute extends number>(input: GenericInput, minute: GenericMinute): TheDate;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { millisecondInOneMinute } from '../constants.mjs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { TheDate } from '../theDate.mjs';
|
|
3
|
+
import { toTimestamp } from '../toTimestamp.mjs';
|
|
4
4
|
|
|
5
5
|
function addMinutes(...args) {
|
|
6
6
|
if (args.length === 1) {
|
|
@@ -8,9 +8,7 @@ function addMinutes(...args) {
|
|
|
8
8
|
return (input) => addMinutes(input, minute);
|
|
9
9
|
}
|
|
10
10
|
const [input, minute] = args;
|
|
11
|
-
|
|
12
|
-
date.setTime(date.getTime() + (minute * millisecondInOneMinute));
|
|
13
|
-
return createTheDate(date.getTime());
|
|
11
|
+
return TheDate.new(toTimestamp(input) + (minute * millisecondInOneMinute));
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
export { addMinutes };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var theDate = require('../theDate.cjs');
|
|
4
4
|
var toNative = require('../toNative.cjs');
|
|
5
5
|
|
|
6
6
|
function addMonths(...args) {
|
|
@@ -11,7 +11,7 @@ function addMonths(...args) {
|
|
|
11
11
|
const [input, month] = args;
|
|
12
12
|
const date = toNative.toNative(input);
|
|
13
13
|
date.setUTCMonth(date.getUTCMonth() + month);
|
|
14
|
-
return
|
|
14
|
+
return theDate.TheDate.new(date.getTime());
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
exports.addMonths = addMonths;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TheDate } from "../theDate";
|
|
2
|
+
import type { SerializedTheDate } from "../types";
|
|
2
3
|
/**
|
|
3
|
-
* Adds months to a date.
|
|
4
|
+
* Adds a number of calendar months to a date.
|
|
4
5
|
*
|
|
5
6
|
* **Supported call styles:**
|
|
6
|
-
* - Classic: `addMonths(input, month)` →
|
|
7
|
-
* - Curried: `addMonths(month)` →
|
|
7
|
+
* - Classic: `addMonths(input, month)` → `TheDate`
|
|
8
|
+
* - Curried: `addMonths(month)` → `(input) => TheDate`
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
+
* `input` accepts `TheDate` or `SerializedTheDate`.
|
|
10
11
|
*
|
|
11
12
|
* ```ts
|
|
12
13
|
* const input = D.create("2024-01-31");
|
|
13
14
|
* const result = D.addMonths(input, 1);
|
|
14
|
-
* // result:
|
|
15
|
-
*
|
|
16
|
-
* const addQuarter = D.addMonths(3);
|
|
17
|
-
* const result2 = addQuarter(input);
|
|
18
|
-
* // result2: "date1719782400000+" (30 april 2024)
|
|
15
|
+
* // result: TheDate
|
|
19
16
|
*
|
|
20
17
|
* pipe(
|
|
21
18
|
* input,
|
|
22
19
|
* D.addMonths(1),
|
|
23
|
-
* ); //
|
|
20
|
+
* ); // TheDate
|
|
24
21
|
*
|
|
25
22
|
* ```
|
|
26
23
|
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* - Uses UTC month arithmetic (`Date#setUTCMonth` behavior).
|
|
26
|
+
*
|
|
27
27
|
* @see https://utils.duplojs.dev/en/v1/api/date/addMonths
|
|
28
28
|
*
|
|
29
29
|
* @namespace D
|
|
30
30
|
*
|
|
31
31
|
*/
|
|
32
|
-
export declare function addMonths<GenericInput extends TheDate, GenericMonth extends number>(month: GenericMonth): (input: GenericInput) => TheDate;
|
|
33
|
-
export declare function addMonths<GenericInput extends TheDate, GenericMonth extends number>(input: GenericInput, month: GenericMonth): TheDate;
|
|
32
|
+
export declare function addMonths<GenericInput extends TheDate | SerializedTheDate, GenericMonth extends number>(month: GenericMonth): (input: GenericInput) => TheDate;
|
|
33
|
+
export declare function addMonths<GenericInput extends TheDate | SerializedTheDate, GenericMonth extends number>(input: GenericInput, month: GenericMonth): TheDate;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TheDate } from '../theDate.mjs';
|
|
2
2
|
import { toNative } from '../toNative.mjs';
|
|
3
3
|
|
|
4
4
|
function addMonths(...args) {
|
|
@@ -9,7 +9,7 @@ function addMonths(...args) {
|
|
|
9
9
|
const [input, month] = args;
|
|
10
10
|
const date = toNative(input);
|
|
11
11
|
date.setUTCMonth(date.getUTCMonth() + month);
|
|
12
|
-
return
|
|
12
|
+
return TheDate.new(date.getTime());
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export { addMonths };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var constants = require('../constants.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var theDate = require('../theDate.cjs');
|
|
5
|
+
var toTimestamp = require('../toTimestamp.cjs');
|
|
6
6
|
|
|
7
7
|
function addSeconds(...args) {
|
|
8
8
|
if (args.length === 1) {
|
|
@@ -10,9 +10,7 @@ function addSeconds(...args) {
|
|
|
10
10
|
return (input) => addSeconds(input, second);
|
|
11
11
|
}
|
|
12
12
|
const [input, second] = args;
|
|
13
|
-
|
|
14
|
-
date.setTime(date.getTime() + (second * constants.millisecondsInOneSecond));
|
|
15
|
-
return createTheDate.createTheDate(date.getTime());
|
|
13
|
+
return theDate.TheDate.new(toTimestamp.toTimestamp(input) + (second * constants.millisecondsInOneSecond));
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
exports.addSeconds = addSeconds;
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TheDate } from "../theDate";
|
|
2
|
+
import type { SerializedTheDate } from "../types";
|
|
2
3
|
/**
|
|
3
|
-
* Adds seconds to a date.
|
|
4
|
+
* Adds a number of seconds to a date.
|
|
4
5
|
*
|
|
5
6
|
* **Supported call styles:**
|
|
6
|
-
* - Classic: `addSeconds(input, second)` →
|
|
7
|
-
* - Curried: `addSeconds(second)` →
|
|
7
|
+
* - Classic: `addSeconds(input, second)` → `TheDate`
|
|
8
|
+
* - Curried: `addSeconds(second)` → `(input) => TheDate`
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
+
* `input` accepts `TheDate` or `SerializedTheDate`.
|
|
10
11
|
*
|
|
11
12
|
* ```ts
|
|
12
13
|
* const input = D.create("2024-06-20");
|
|
13
14
|
* const result = D.addSeconds(input, 5);
|
|
14
|
-
* // result:
|
|
15
|
+
* // result: TheDate
|
|
16
|
+
*
|
|
17
|
+
* const serialized = D.serialize(result);
|
|
18
|
+
* // serialized: SerializedTheDate
|
|
15
19
|
*
|
|
16
20
|
* pipe(
|
|
17
|
-
*
|
|
21
|
+
* serialized,
|
|
18
22
|
* D.addSeconds(5),
|
|
19
|
-
* ); //
|
|
20
|
-
*
|
|
23
|
+
* ); // TheDate
|
|
21
24
|
* ```
|
|
22
25
|
*
|
|
23
26
|
* @see https://utils.duplojs.dev/en/v1/api/date/addSeconds
|
|
@@ -25,5 +28,5 @@ import type { TheDate } from "../types";
|
|
|
25
28
|
* @namespace D
|
|
26
29
|
*
|
|
27
30
|
*/
|
|
28
|
-
export declare function addSeconds<GenericInput extends TheDate, GenericSecond extends number>(second: GenericSecond): (input: GenericInput) => TheDate;
|
|
29
|
-
export declare function addSeconds<GenericInput extends TheDate, GenericSecond extends number>(input: GenericInput, second: GenericSecond): TheDate;
|
|
31
|
+
export declare function addSeconds<GenericInput extends TheDate | SerializedTheDate, GenericSecond extends number>(second: GenericSecond): (input: GenericInput) => TheDate;
|
|
32
|
+
export declare function addSeconds<GenericInput extends TheDate | SerializedTheDate, GenericSecond extends number>(input: GenericInput, second: GenericSecond): TheDate;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { millisecondsInOneSecond } from '../constants.mjs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { TheDate } from '../theDate.mjs';
|
|
3
|
+
import { toTimestamp } from '../toTimestamp.mjs';
|
|
4
4
|
|
|
5
5
|
function addSeconds(...args) {
|
|
6
6
|
if (args.length === 1) {
|
|
@@ -8,9 +8,7 @@ function addSeconds(...args) {
|
|
|
8
8
|
return (input) => addSeconds(input, second);
|
|
9
9
|
}
|
|
10
10
|
const [input, second] = args;
|
|
11
|
-
|
|
12
|
-
date.setTime(date.getTime() + (second * millisecondsInOneSecond));
|
|
13
|
-
return createTheDate(date.getTime());
|
|
11
|
+
return TheDate.new(toTimestamp(input) + (second * millisecondsInOneSecond));
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
export { addSeconds };
|