@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
|
@@ -6,15 +6,15 @@ var toNative = require('../toNative.cjs');
|
|
|
6
6
|
* {@include date/getMinute/index.md}
|
|
7
7
|
*/
|
|
8
8
|
function getMinute(input, timezone = "UTC") {
|
|
9
|
-
const
|
|
9
|
+
const date = toNative.toNative(input);
|
|
10
10
|
if (timezone === "UTC") {
|
|
11
|
-
return
|
|
11
|
+
return date.getUTCMinutes();
|
|
12
12
|
}
|
|
13
13
|
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
14
14
|
timeZone: timezone,
|
|
15
15
|
minute: "numeric",
|
|
16
16
|
});
|
|
17
|
-
return Number(formatter.format(
|
|
17
|
+
return Number(formatter.format(date));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
exports.getMinute = getMinute;
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { SerializedTheDate } from "../types";
|
|
2
|
+
import { type TheDate } from "../theDate";
|
|
3
|
+
import { type Timezone } from "../timezone";
|
|
2
4
|
/**
|
|
3
|
-
* Returns the minute
|
|
5
|
+
* Returns the minute (`0` to `59`) for a date in a target timezone.
|
|
4
6
|
*
|
|
5
|
-
* Signature: `getMinute(input, timezone)` →
|
|
7
|
+
* Signature: `getMinute(input, timezone?)` → `number`
|
|
6
8
|
*
|
|
7
|
-
* If timezone is omitted, UTC is used.
|
|
8
|
-
*
|
|
9
|
-
* The input value is not mutated.
|
|
9
|
+
* `input` accepts `TheDate` or `SerializedTheDate`. If `timezone` is omitted, UTC is used.
|
|
10
10
|
*
|
|
11
11
|
* ```ts
|
|
12
|
-
* const input = D.create("2024-06-20"
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* const input = D.create("2024-06-20", {
|
|
13
|
+
* hour: "00",
|
|
14
|
+
* minute: "30",
|
|
15
|
+
* });
|
|
16
|
+
* const utcMinute = D.getMinute(input);
|
|
17
|
+
* // utcMinute: 30
|
|
15
18
|
*
|
|
16
|
-
* const
|
|
17
|
-
* //
|
|
19
|
+
* const tokyoMinute = D.getMinute(input, "Asia/Tokyo");
|
|
20
|
+
* // tokyoMinute: 30
|
|
18
21
|
*
|
|
19
22
|
* pipe(
|
|
20
23
|
* input,
|
|
21
|
-
* D.getMinute,
|
|
22
|
-
* ); //
|
|
23
|
-
*
|
|
24
|
+
* (value) => D.getMinute(value, "UTC"),
|
|
25
|
+
* ); // 30
|
|
24
26
|
* ```
|
|
25
27
|
*
|
|
26
28
|
* @see https://utils.duplojs.dev/en/v1/api/date/getMinute
|
|
@@ -28,4 +30,4 @@ import { type TheDate, type Timezone } from "..";
|
|
|
28
30
|
* @namespace D
|
|
29
31
|
*
|
|
30
32
|
*/
|
|
31
|
-
export declare function getMinute<GenericInput extends TheDate>(input: GenericInput, timezone?: Timezone): number;
|
|
33
|
+
export declare function getMinute<GenericInput extends TheDate | SerializedTheDate>(input: GenericInput, timezone?: Timezone): number;
|
|
@@ -4,15 +4,15 @@ import { toNative } from '../toNative.mjs';
|
|
|
4
4
|
* {@include date/getMinute/index.md}
|
|
5
5
|
*/
|
|
6
6
|
function getMinute(input, timezone = "UTC") {
|
|
7
|
-
const
|
|
7
|
+
const date = toNative(input);
|
|
8
8
|
if (timezone === "UTC") {
|
|
9
|
-
return
|
|
9
|
+
return date.getUTCMinutes();
|
|
10
10
|
}
|
|
11
11
|
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
12
12
|
timeZone: timezone,
|
|
13
13
|
minute: "numeric",
|
|
14
14
|
});
|
|
15
|
-
return Number(formatter.format(
|
|
15
|
+
return Number(formatter.format(date));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export { getMinute };
|
|
@@ -6,15 +6,15 @@ var toNative = require('../toNative.cjs');
|
|
|
6
6
|
* {@include date/getMonth/index.md}
|
|
7
7
|
*/
|
|
8
8
|
function getMonth(input, timezone = "UTC") {
|
|
9
|
-
const
|
|
9
|
+
const date = toNative.toNative(input);
|
|
10
10
|
if (timezone === "UTC") {
|
|
11
|
-
return
|
|
11
|
+
return date.getUTCMonth() + 1;
|
|
12
12
|
}
|
|
13
13
|
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
14
14
|
timeZone: timezone,
|
|
15
15
|
month: "numeric",
|
|
16
16
|
});
|
|
17
|
-
return Number(formatter.format(
|
|
17
|
+
return Number(formatter.format(date));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
exports.getMonth = getMonth;
|
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { SerializedTheDate } from "../types";
|
|
2
|
+
import { type TheDate } from "../theDate";
|
|
3
|
+
import type { Timezone } from "../timezone";
|
|
2
4
|
/**
|
|
3
|
-
* Returns the month
|
|
5
|
+
* Returns the month number (`1` to `12`) for a date in a target timezone.
|
|
4
6
|
*
|
|
5
|
-
* Signature: `getMonth(input, timezone)` →
|
|
7
|
+
* Signature: `getMonth(input, timezone?)` → `number`
|
|
6
8
|
*
|
|
7
|
-
* If timezone is omitted, UTC is used.
|
|
8
|
-
*
|
|
9
|
-
* The input value is not mutated.
|
|
9
|
+
* `input` accepts `TheDate` or `SerializedTheDate`. If `timezone` is omitted, UTC is used.
|
|
10
10
|
*
|
|
11
11
|
* ```ts
|
|
12
|
-
* const input = D.create("2024-12-31"
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* const input = D.create("2024-12-31", {
|
|
13
|
+
* hour: "23",
|
|
14
|
+
* minute: "30",
|
|
15
|
+
* });
|
|
16
|
+
* const utcMonth = D.getMonth(input);
|
|
17
|
+
* // utcMonth: 12
|
|
15
18
|
*
|
|
16
|
-
* const
|
|
17
|
-
* //
|
|
19
|
+
* const tokyoMonth = D.getMonth(input, "Asia/Tokyo");
|
|
20
|
+
* // tokyoMonth: 1
|
|
18
21
|
*
|
|
19
22
|
* pipe(
|
|
20
23
|
* input,
|
|
21
|
-
* D.getMonth,
|
|
22
|
-
* ); //
|
|
23
|
-
*
|
|
24
|
+
* (value) => D.getMonth(value, "UTC"),
|
|
25
|
+
* ); // 12
|
|
24
26
|
* ```
|
|
25
27
|
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* - Unlike native `Date#getMonth`, this getter is 1-based.
|
|
30
|
+
*
|
|
26
31
|
* @see https://utils.duplojs.dev/en/v1/api/date/getMonth
|
|
27
32
|
*
|
|
28
33
|
* @namespace D
|
|
29
34
|
*
|
|
30
35
|
*/
|
|
31
|
-
export declare function getMonth<GenericInput extends TheDate>(input: GenericInput, timezone?: Timezone): number;
|
|
36
|
+
export declare function getMonth<GenericInput extends TheDate | SerializedTheDate>(input: GenericInput, timezone?: Timezone): number;
|
|
@@ -4,15 +4,15 @@ import { toNative } from '../toNative.mjs';
|
|
|
4
4
|
* {@include date/getMonth/index.md}
|
|
5
5
|
*/
|
|
6
6
|
function getMonth(input, timezone = "UTC") {
|
|
7
|
-
const
|
|
7
|
+
const date = toNative(input);
|
|
8
8
|
if (timezone === "UTC") {
|
|
9
|
-
return
|
|
9
|
+
return date.getUTCMonth() + 1;
|
|
10
10
|
}
|
|
11
11
|
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
12
12
|
timeZone: timezone,
|
|
13
13
|
month: "numeric",
|
|
14
14
|
});
|
|
15
|
-
return Number(formatter.format(
|
|
15
|
+
return Number(formatter.format(date));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export { getMonth };
|
|
@@ -6,15 +6,15 @@ var toNative = require('../toNative.cjs');
|
|
|
6
6
|
* {@include date/getSecond/index.md}
|
|
7
7
|
*/
|
|
8
8
|
function getSecond(input, timezone = "UTC") {
|
|
9
|
-
const
|
|
9
|
+
const date = toNative.toNative(input);
|
|
10
10
|
if (timezone === "UTC") {
|
|
11
|
-
return
|
|
11
|
+
return date.getUTCSeconds();
|
|
12
12
|
}
|
|
13
13
|
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
14
14
|
timeZone: timezone,
|
|
15
15
|
second: "numeric",
|
|
16
16
|
});
|
|
17
|
-
return Number(formatter.format(
|
|
17
|
+
return Number(formatter.format(date));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
exports.getSecond = getSecond;
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { SerializedTheDate } from "../types";
|
|
2
|
+
import type { TheDate } from "../theDate";
|
|
3
|
+
import type { Timezone } from "../timezone";
|
|
2
4
|
/**
|
|
3
|
-
* Returns the second
|
|
5
|
+
* Returns the second (`0` to `59`) for a date in a target timezone.
|
|
4
6
|
*
|
|
5
|
-
* Signature: `getSecond(input, timezone)` →
|
|
7
|
+
* Signature: `getSecond(input, timezone?)` → `number`
|
|
6
8
|
*
|
|
7
|
-
* If timezone is omitted, UTC is used.
|
|
8
|
-
*
|
|
9
|
-
* The input value is not mutated.
|
|
9
|
+
* `input` accepts `TheDate` or `SerializedTheDate`. If `timezone` is omitted, UTC is used.
|
|
10
10
|
*
|
|
11
11
|
* ```ts
|
|
12
|
-
* const input = D.create("2024-06-20"
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* const input = D.create("2024-06-20", {
|
|
13
|
+
* hour: "00",
|
|
14
|
+
* minute: "00",
|
|
15
|
+
* second: "45",
|
|
16
|
+
* });
|
|
17
|
+
* const utcSecond = D.getSecond(input);
|
|
18
|
+
* // utcSecond: 45
|
|
15
19
|
*
|
|
16
|
-
* const
|
|
17
|
-
* //
|
|
20
|
+
* const londonSecond = D.getSecond(input, "Europe/London");
|
|
21
|
+
* // londonSecond: 45
|
|
18
22
|
*
|
|
19
23
|
* pipe(
|
|
20
24
|
* input,
|
|
21
|
-
* D.getSecond,
|
|
22
|
-
* ); // result: 0
|
|
23
|
-
*
|
|
25
|
+
* (value) => D.getSecond(value, "UTC"),
|
|
24
26
|
* ```
|
|
25
27
|
*
|
|
26
28
|
* @see https://utils.duplojs.dev/en/v1/api/date/getSecond
|
|
@@ -28,4 +30,4 @@ import { type TheDate, type Timezone } from "..";
|
|
|
28
30
|
* @namespace D
|
|
29
31
|
*
|
|
30
32
|
*/
|
|
31
|
-
export declare function getSecond<GenericInput extends TheDate>(input: GenericInput, timezone?: Timezone): number;
|
|
33
|
+
export declare function getSecond<GenericInput extends TheDate | SerializedTheDate>(input: GenericInput, timezone?: Timezone): number;
|
|
@@ -4,15 +4,15 @@ import { toNative } from '../toNative.mjs';
|
|
|
4
4
|
* {@include date/getSecond/index.md}
|
|
5
5
|
*/
|
|
6
6
|
function getSecond(input, timezone = "UTC") {
|
|
7
|
-
const
|
|
7
|
+
const date = toNative(input);
|
|
8
8
|
if (timezone === "UTC") {
|
|
9
|
-
return
|
|
9
|
+
return date.getUTCSeconds();
|
|
10
10
|
}
|
|
11
11
|
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
12
12
|
timeZone: timezone,
|
|
13
13
|
second: "numeric",
|
|
14
14
|
});
|
|
15
|
-
return Number(formatter.format(
|
|
15
|
+
return Number(formatter.format(date));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export { getSecond };
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var toNative = require('../toNative.cjs');
|
|
4
|
+
var constants = require('../constants.cjs');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* {@include date/getWeekOfYear/index.md}
|
|
7
8
|
*/
|
|
8
9
|
function getWeekOfYear(input, timezone = "UTC") {
|
|
9
|
-
const
|
|
10
|
+
const date = toNative.toNative(input);
|
|
10
11
|
let year = 0;
|
|
11
12
|
let month = 0;
|
|
12
13
|
let day = 0;
|
|
13
14
|
if (timezone === "UTC") {
|
|
14
|
-
year =
|
|
15
|
-
month =
|
|
16
|
-
day =
|
|
15
|
+
year = date.getUTCFullYear();
|
|
16
|
+
month = date.getUTCMonth();
|
|
17
|
+
day = date.getUTCDate();
|
|
17
18
|
}
|
|
18
19
|
else {
|
|
19
20
|
const parts = new Intl.DateTimeFormat("en-US", {
|
|
@@ -21,19 +22,19 @@ function getWeekOfYear(input, timezone = "UTC") {
|
|
|
21
22
|
day: "numeric",
|
|
22
23
|
year: "numeric",
|
|
23
24
|
month: "numeric",
|
|
24
|
-
}).formatToParts(
|
|
25
|
+
}).formatToParts(date);
|
|
25
26
|
const partsMap = new Map(parts.map((part) => [part.type, part.value]));
|
|
26
27
|
year = Number(partsMap.get("year"));
|
|
27
28
|
month = Number(partsMap.get("month")) - 1;
|
|
28
29
|
day = Number(partsMap.get("day"));
|
|
29
30
|
}
|
|
30
|
-
const
|
|
31
|
-
const dayOfWeek =
|
|
31
|
+
const nativeDate = new Date(Date.UTC(year, month, day));
|
|
32
|
+
const dayOfWeek = nativeDate.getUTCDay() || 7;
|
|
32
33
|
const nearestThursday = day + 4 - dayOfWeek;
|
|
33
|
-
|
|
34
|
-
const thursYearStart = Date.UTC(
|
|
35
|
-
const millisecondsDiff =
|
|
36
|
-
const daysDiff = Math.floor(millisecondsDiff /
|
|
34
|
+
nativeDate.setUTCDate(nearestThursday);
|
|
35
|
+
const thursYearStart = Date.UTC(nativeDate.getUTCFullYear(), 0, 1);
|
|
36
|
+
const millisecondsDiff = nativeDate.getTime() - thursYearStart;
|
|
37
|
+
const daysDiff = Math.floor(millisecondsDiff / constants.millisecondsInOneDay);
|
|
37
38
|
return Math.ceil((daysDiff + 1) / 7);
|
|
38
39
|
}
|
|
39
40
|
|
|
@@ -1,28 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { SerializedTheDate } from "../types";
|
|
2
|
+
import type { TheDate } from "../theDate";
|
|
3
|
+
import type { Timezone } from "../timezone";
|
|
2
4
|
/**
|
|
3
|
-
* Returns the week
|
|
5
|
+
* Returns the ISO week number (`1` to `53`) for a date in a target timezone.
|
|
4
6
|
*
|
|
5
|
-
* Signature: `getWeekOfYear(input, timezone)` →
|
|
7
|
+
* Signature: `getWeekOfYear(input, timezone?)` → `number`
|
|
6
8
|
*
|
|
7
|
-
* If timezone is omitted, UTC is used.
|
|
8
|
-
*
|
|
9
|
-
* The input value is not mutated.
|
|
9
|
+
* `input` accepts `TheDate` or `SerializedTheDate`. If `timezone` is omitted, UTC is used.
|
|
10
10
|
*
|
|
11
11
|
* ```ts
|
|
12
12
|
* const input = D.create("2024-01-04");
|
|
13
|
-
* const
|
|
14
|
-
* //
|
|
13
|
+
* const utcWeek = D.getWeekOfYear(input);
|
|
14
|
+
* // utcWeek: 1
|
|
15
|
+
*
|
|
16
|
+
* const berlinWeek = D.getWeekOfYear(input, "Europe/Berlin");
|
|
17
|
+
* // berlinWeek: 1
|
|
15
18
|
*
|
|
16
19
|
* pipe(
|
|
17
20
|
* input,
|
|
18
|
-
* (value) => D.getWeekOfYear(value, "
|
|
19
|
-
* ); //
|
|
21
|
+
* (value) => D.getWeekOfYear(value, "UTC"),
|
|
22
|
+
* ); // 1
|
|
20
23
|
*
|
|
21
24
|
* ```
|
|
22
25
|
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* - Uses ISO-8601 week rules (week aligned around Thursday logic).
|
|
28
|
+
*
|
|
23
29
|
* @see https://utils.duplojs.dev/en/v1/api/date/getWeekOfYear
|
|
24
30
|
*
|
|
25
31
|
* @namespace D
|
|
26
32
|
*
|
|
27
33
|
*/
|
|
28
|
-
export declare function getWeekOfYear<GenericInput extends TheDate>(input: GenericInput, timezone?: Timezone): number;
|
|
34
|
+
export declare function getWeekOfYear<GenericInput extends TheDate | SerializedTheDate>(input: GenericInput, timezone?: Timezone): number;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { toNative } from '../toNative.mjs';
|
|
2
|
+
import { millisecondsInOneDay } from '../constants.mjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* {@include date/getWeekOfYear/index.md}
|
|
5
6
|
*/
|
|
6
7
|
function getWeekOfYear(input, timezone = "UTC") {
|
|
7
|
-
const
|
|
8
|
+
const date = toNative(input);
|
|
8
9
|
let year = 0;
|
|
9
10
|
let month = 0;
|
|
10
11
|
let day = 0;
|
|
11
12
|
if (timezone === "UTC") {
|
|
12
|
-
year =
|
|
13
|
-
month =
|
|
14
|
-
day =
|
|
13
|
+
year = date.getUTCFullYear();
|
|
14
|
+
month = date.getUTCMonth();
|
|
15
|
+
day = date.getUTCDate();
|
|
15
16
|
}
|
|
16
17
|
else {
|
|
17
18
|
const parts = new Intl.DateTimeFormat("en-US", {
|
|
@@ -19,19 +20,19 @@ function getWeekOfYear(input, timezone = "UTC") {
|
|
|
19
20
|
day: "numeric",
|
|
20
21
|
year: "numeric",
|
|
21
22
|
month: "numeric",
|
|
22
|
-
}).formatToParts(
|
|
23
|
+
}).formatToParts(date);
|
|
23
24
|
const partsMap = new Map(parts.map((part) => [part.type, part.value]));
|
|
24
25
|
year = Number(partsMap.get("year"));
|
|
25
26
|
month = Number(partsMap.get("month")) - 1;
|
|
26
27
|
day = Number(partsMap.get("day"));
|
|
27
28
|
}
|
|
28
|
-
const
|
|
29
|
-
const dayOfWeek =
|
|
29
|
+
const nativeDate = new Date(Date.UTC(year, month, day));
|
|
30
|
+
const dayOfWeek = nativeDate.getUTCDay() || 7;
|
|
30
31
|
const nearestThursday = day + 4 - dayOfWeek;
|
|
31
|
-
|
|
32
|
-
const thursYearStart = Date.UTC(
|
|
33
|
-
const millisecondsDiff =
|
|
34
|
-
const daysDiff = Math.floor(millisecondsDiff /
|
|
32
|
+
nativeDate.setUTCDate(nearestThursday);
|
|
33
|
+
const thursYearStart = Date.UTC(nativeDate.getUTCFullYear(), 0, 1);
|
|
34
|
+
const millisecondsDiff = nativeDate.getTime() - thursYearStart;
|
|
35
|
+
const daysDiff = Math.floor(millisecondsDiff / millisecondsInOneDay);
|
|
35
36
|
return Math.ceil((daysDiff + 1) / 7);
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -6,15 +6,15 @@ var toNative = require('../toNative.cjs');
|
|
|
6
6
|
* {@include date/getYear/index.md}
|
|
7
7
|
*/
|
|
8
8
|
function getYear(input, timezone = "UTC") {
|
|
9
|
-
const
|
|
9
|
+
const date = toNative.toNative(input);
|
|
10
10
|
if (timezone === "UTC") {
|
|
11
|
-
return
|
|
11
|
+
return date.getUTCFullYear();
|
|
12
12
|
}
|
|
13
13
|
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
14
14
|
timeZone: timezone,
|
|
15
15
|
year: "numeric",
|
|
16
16
|
});
|
|
17
|
-
return Number(formatter.format(
|
|
17
|
+
return Number(formatter.format(date));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
exports.getYear = getYear;
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { SerializedTheDate } from "../types";
|
|
2
|
+
import { type TheDate } from "../theDate";
|
|
3
|
+
import type { Timezone } from "../timezone";
|
|
2
4
|
/**
|
|
3
|
-
* Returns the year
|
|
5
|
+
* Returns the year for a date in a target timezone.
|
|
4
6
|
*
|
|
5
|
-
* Signature: `getYear(input, timezone)` →
|
|
7
|
+
* Signature: `getYear(input, timezone?)` → `number`
|
|
6
8
|
*
|
|
7
|
-
* If timezone is omitted, UTC is used.
|
|
8
|
-
*
|
|
9
|
-
* The input value is not mutated.
|
|
9
|
+
* `input` accepts `TheDate` or `SerializedTheDate`. If `timezone` is omitted, UTC is used.
|
|
10
10
|
*
|
|
11
11
|
* ```ts
|
|
12
|
-
* const input = D.create("2024-
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* const input = D.create("2024-12-31", {
|
|
13
|
+
* hour: "23",
|
|
14
|
+
* minute: "30",
|
|
15
|
+
* });
|
|
16
|
+
* const utcYear = D.getYear(input);
|
|
17
|
+
* // utcYear: 2024
|
|
15
18
|
*
|
|
16
|
-
* const
|
|
17
|
-
* //
|
|
19
|
+
* const tokyoYear = D.getYear(input, "Asia/Tokyo");
|
|
20
|
+
* // tokyoYear: 2025
|
|
18
21
|
*
|
|
19
22
|
* pipe(
|
|
20
23
|
* input,
|
|
21
|
-
* D.getYear,
|
|
22
|
-
* ); // result: 2024
|
|
23
|
-
*
|
|
24
|
+
* (value) => D.getYear(value, "UTC"),
|
|
24
25
|
* ```
|
|
25
26
|
*
|
|
26
27
|
* @see https://utils.duplojs.dev/en/v1/api/date/getYear
|
|
@@ -28,4 +29,4 @@ import { type TheDate, type Timezone } from "..";
|
|
|
28
29
|
* @namespace D
|
|
29
30
|
*
|
|
30
31
|
*/
|
|
31
|
-
export declare function getYear<GenericInput extends TheDate>(input: GenericInput, timezone?: Timezone): number;
|
|
32
|
+
export declare function getYear<GenericInput extends TheDate | SerializedTheDate>(input: GenericInput, timezone?: Timezone): number;
|
|
@@ -4,15 +4,15 @@ import { toNative } from '../toNative.mjs';
|
|
|
4
4
|
* {@include date/getYear/index.md}
|
|
5
5
|
*/
|
|
6
6
|
function getYear(input, timezone = "UTC") {
|
|
7
|
-
const
|
|
7
|
+
const date = toNative(input);
|
|
8
8
|
if (timezone === "UTC") {
|
|
9
|
-
return
|
|
9
|
+
return date.getUTCFullYear();
|
|
10
10
|
}
|
|
11
11
|
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
12
12
|
timeZone: timezone,
|
|
13
13
|
year: "numeric",
|
|
14
14
|
});
|
|
15
|
-
return Number(formatter.format(
|
|
15
|
+
return Number(formatter.format(date));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export { getYear };
|
package/dist/date/index.cjs
CHANGED
|
@@ -30,11 +30,14 @@ var applyTimezone = require('./applyTimezone.cjs');
|
|
|
30
30
|
var format = require('./format.cjs');
|
|
31
31
|
var formatTime = require('./formatTime.cjs');
|
|
32
32
|
var makeSafeTimestamp = require('./makeSafeTimestamp.cjs');
|
|
33
|
-
var createTheDate = require('./createTheDate.cjs');
|
|
34
|
-
var createTheTime = require('./createTheTime.cjs');
|
|
35
33
|
var createTime = require('./createTime.cjs');
|
|
36
34
|
var createTimeOrThrow = require('./createTimeOrThrow.cjs');
|
|
37
35
|
var makeSafeTimeValue = require('./makeSafeTimeValue.cjs');
|
|
36
|
+
var theDate = require('./theDate.cjs');
|
|
37
|
+
var theTime = require('./theTime.cjs');
|
|
38
|
+
var isSerializedTheDate = require('./isSerializedTheDate.cjs');
|
|
39
|
+
var isSerializedTheTime = require('./isSerializedTheTime.cjs');
|
|
40
|
+
var serialize = require('./serialize.cjs');
|
|
38
41
|
var getDayOfMonth = require('./getters/getDayOfMonth.cjs');
|
|
39
42
|
var getDayOfWeek = require('./getters/getDayOfWeek.cjs');
|
|
40
43
|
var getFirstDayOfWeek = require('./getters/getFirstDayOfWeek.cjs');
|
|
@@ -100,8 +103,8 @@ exports.minTimestamp = constants.minTimestamp;
|
|
|
100
103
|
exports.minutesInOneHour = constants.minutesInOneHour;
|
|
101
104
|
exports.monthsInOneYear = constants.monthsInOneYear;
|
|
102
105
|
exports.secondsInOneMinute = constants.secondsInOneMinute;
|
|
103
|
-
exports.
|
|
104
|
-
exports.
|
|
106
|
+
exports.serializeTheDateRegex = constants.serializeTheDateRegex;
|
|
107
|
+
exports.serializeTheTimeRegex = constants.serializeTheTimeRegex;
|
|
105
108
|
exports.create = create.create;
|
|
106
109
|
exports.now = now.now;
|
|
107
110
|
exports.today = today.today;
|
|
@@ -132,12 +135,15 @@ exports.applyTimezone = applyTimezone.applyTimezone;
|
|
|
132
135
|
exports.format = format.format;
|
|
133
136
|
exports.formatTime = formatTime.formatTime;
|
|
134
137
|
exports.makeSafeTimestamp = makeSafeTimestamp.makeSafeTimestamp;
|
|
135
|
-
exports.createTheDate = createTheDate.createTheDate;
|
|
136
|
-
exports.createTheTime = createTheTime.createTheTime;
|
|
137
138
|
exports.createTime = createTime.createTime;
|
|
138
139
|
exports.CreateTheTimeError = createTimeOrThrow.CreateTheTimeError;
|
|
139
140
|
exports.createTimeOrThrow = createTimeOrThrow.createTimeOrThrow;
|
|
140
141
|
exports.makeSafeTimeValue = makeSafeTimeValue.makeSafeTimeValue;
|
|
142
|
+
exports.TheDate = theDate.TheDate;
|
|
143
|
+
exports.TheTime = theTime.TheTime;
|
|
144
|
+
exports.isSerializedTheDate = isSerializedTheDate.isSerializedTheDate;
|
|
145
|
+
exports.isSerializedTheTime = isSerializedTheTime.isSerializedTheTime;
|
|
146
|
+
exports.serialize = serialize.serialize;
|
|
141
147
|
exports.getDayOfMonth = getDayOfMonth.getDayOfMonth;
|
|
142
148
|
exports.getDayOfWeek = getDayOfWeek.getDayOfWeek;
|
|
143
149
|
exports.getFirstDayOfWeek = getFirstDayOfWeek.getFirstDayOfWeek;
|
package/dist/date/index.d.ts
CHANGED
|
@@ -64,8 +64,11 @@ export * from "./applyTimezone";
|
|
|
64
64
|
export * from "./format";
|
|
65
65
|
export * from "./formatTime";
|
|
66
66
|
export * from "./makeSafeTimestamp";
|
|
67
|
-
export * from "./createTheDate";
|
|
68
|
-
export * from "./createTheTime";
|
|
69
67
|
export * from "./createTime";
|
|
70
68
|
export * from "./createTimeOrThrow";
|
|
71
69
|
export * from "./makeSafeTimeValue";
|
|
70
|
+
export * from "./theDate";
|
|
71
|
+
export * from "./theTime";
|
|
72
|
+
export * from "./isSerializedTheDate";
|
|
73
|
+
export * from "./isSerializedTheTime";
|
|
74
|
+
export * from "./serialize";
|
package/dist/date/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { daysInOneWeek, hoursInOneDay, isoDateRegex, isoTimeRegex, maxTimeValue, maxTimestamp, millisecondInOneHour, millisecondInOneMinute, millisecondInOneWeek, millisecondsInOneDay, millisecondsInOneSecond, minTimeValue, minTimestamp, minutesInOneHour, monthsInOneYear, secondsInOneMinute,
|
|
1
|
+
export { daysInOneWeek, hoursInOneDay, isoDateRegex, isoTimeRegex, maxTimeValue, maxTimestamp, millisecondInOneHour, millisecondInOneMinute, millisecondInOneWeek, millisecondsInOneDay, millisecondsInOneSecond, minTimeValue, minTimestamp, minutesInOneHour, monthsInOneYear, secondsInOneMinute, serializeTheDateRegex, serializeTheTimeRegex } from './constants.mjs';
|
|
2
2
|
export { create } from './create.mjs';
|
|
3
3
|
export { now } from './now.mjs';
|
|
4
4
|
export { today } from './today.mjs';
|
|
@@ -28,11 +28,14 @@ export { applyTimezone } from './applyTimezone.mjs';
|
|
|
28
28
|
export { format } from './format.mjs';
|
|
29
29
|
export { formatTime } from './formatTime.mjs';
|
|
30
30
|
export { makeSafeTimestamp } from './makeSafeTimestamp.mjs';
|
|
31
|
-
export { createTheDate } from './createTheDate.mjs';
|
|
32
|
-
export { createTheTime } from './createTheTime.mjs';
|
|
33
31
|
export { createTime } from './createTime.mjs';
|
|
34
32
|
export { CreateTheTimeError, createTimeOrThrow } from './createTimeOrThrow.mjs';
|
|
35
33
|
export { makeSafeTimeValue } from './makeSafeTimeValue.mjs';
|
|
34
|
+
export { TheDate } from './theDate.mjs';
|
|
35
|
+
export { TheTime } from './theTime.mjs';
|
|
36
|
+
export { isSerializedTheDate } from './isSerializedTheDate.mjs';
|
|
37
|
+
export { isSerializedTheTime } from './isSerializedTheTime.mjs';
|
|
38
|
+
export { serialize } from './serialize.mjs';
|
|
36
39
|
export { getDayOfMonth } from './getters/getDayOfMonth.mjs';
|
|
37
40
|
export { getDayOfWeek } from './getters/getDayOfWeek.mjs';
|
|
38
41
|
export { getFirstDayOfWeek } from './getters/getFirstDayOfWeek.mjs';
|
package/dist/date/is.cjs
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var isSafeTimestamp = require('./isSafeTimestamp.cjs');
|
|
3
|
+
var theDate = require('./theDate.cjs');
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* {@include date/is/index.md}
|
|
8
7
|
*/
|
|
9
8
|
function is(input) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const { value, sign } = theDateMatch.groups;
|
|
13
|
-
return isSafeTimestamp.isSafeTimestamp(Number(sign === "-"
|
|
14
|
-
? `-${value}`
|
|
15
|
-
: value));
|
|
9
|
+
if (input instanceof theDate.TheDate) {
|
|
10
|
+
return true;
|
|
16
11
|
}
|
|
17
12
|
return false;
|
|
18
13
|
}
|
package/dist/date/is.d.ts
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TheDate } from "./theDate";
|
|
2
2
|
/**
|
|
3
|
-
* Checks whether a value is
|
|
3
|
+
* Checks whether a value is an instance of `TheDate`.
|
|
4
4
|
*
|
|
5
|
-
* Signature: `is(input)` →
|
|
6
|
-
*
|
|
7
|
-
* The input value is not mutated.
|
|
5
|
+
* Signature: `is(input)` → `input is TheDate`
|
|
8
6
|
*
|
|
9
7
|
* ```ts
|
|
10
|
-
* const input = D.now() as
|
|
8
|
+
* const input = D.now() as AnyValue;
|
|
11
9
|
*
|
|
12
10
|
* if (D.is(input)) {
|
|
13
|
-
* // input
|
|
11
|
+
* // input: TheDate
|
|
14
12
|
* }
|
|
15
13
|
*
|
|
16
14
|
* pipe(
|
|
17
15
|
* input,
|
|
18
|
-
* when(
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* // value is TheDate
|
|
22
|
-
* },
|
|
23
|
-
* ),
|
|
16
|
+
* when(D.is, (value) => {
|
|
17
|
+
* // value: TheDate
|
|
18
|
+
* }),
|
|
24
19
|
* );
|
|
25
20
|
* ```
|
|
26
21
|
*
|
|
@@ -29,4 +24,4 @@ import { type TheDate } from "./types";
|
|
|
29
24
|
* @namespace D
|
|
30
25
|
*
|
|
31
26
|
*/
|
|
32
|
-
export declare function is(input:
|
|
27
|
+
export declare function is(input: unknown): input is TheDate;
|