@zelgadis87/utils-core 5.2.10 → 5.2.12
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/CHANGELOG.md +8 -0
- package/dist/time/TimeInstant.d.ts +9 -9
- package/dist/time/TimeInstantBuilder.d.ts +24 -15
- package/dist/time/types.d.ts +2 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/esbuild/index.cjs +196 -184
- package/esbuild/index.cjs.map +3 -3
- package/esbuild/index.mjs +196 -184
- package/esbuild/index.mjs.map +3 -3
- package/package.json +1 -1
- package/src/time/TimeInstant.ts +275 -204
- package/src/time/TimeInstantBuilder.ts +18 -8
- package/src/time/types.ts +2 -1
|
@@ -3,20 +3,30 @@ import { TFunction } from "../utils/functions.js";
|
|
|
3
3
|
import { ensureDefined } from "../utils/nulls.js";
|
|
4
4
|
import { monthNames } from "./constants.js";
|
|
5
5
|
import { TimeInstant, isTimeInstant } from "./TimeInstant.js";
|
|
6
|
-
import { TDayOfMonth, THourOfDay, TMillisecondOfSecond, TMinuteOfHour, TMonth, TSecondOfMinute, TUpToTwoDigits, type TMonthName } from "./types.js";
|
|
6
|
+
import { TDayOfMonth, THourOfDay, TMillisecondOfSecond, TMinuteOfHour, TMonth, TSecondOfMinute, TUpToTwoDigits, type TMonthName, type TYear } from "./types.js";
|
|
7
7
|
|
|
8
8
|
type TRelativeSignum = '+' | '-';
|
|
9
9
|
type TRelativeNumber = `${TRelativeSignum}${TUpToTwoDigits}`;
|
|
10
10
|
const isRelativeNumber = ( x: string ): x is TRelativeNumber => x !== undefined && x.length > 0 && ( x[ 0 ] === '+' || x[ 0 ] === '-' );
|
|
11
11
|
|
|
12
|
+
export type TTimeInstantParameters = {
|
|
13
|
+
year: TYear;
|
|
14
|
+
month: TMonth;
|
|
15
|
+
date: TDayOfMonth;
|
|
16
|
+
hours: THourOfDay;
|
|
17
|
+
minutes: TMinuteOfHour
|
|
18
|
+
seconds: TSecondOfMinute;
|
|
19
|
+
milliseconds: TMillisecondOfSecond;
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
export type TTimeInstantCreationParameters = {
|
|
13
|
-
year:
|
|
14
|
-
month:
|
|
15
|
-
date:
|
|
16
|
-
hours:
|
|
17
|
-
minutes:
|
|
18
|
-
seconds:
|
|
19
|
-
milliseconds:
|
|
23
|
+
year: TTimeInstantParameters[ "year" ] | { absolute: TTimeInstantParameters[ "year" ] } | TRelativeNumber | { relative: number, relativeTo: 'now' | TimeInstant } | 'next' | 'last' | 'current' | undefined;
|
|
24
|
+
month: TTimeInstantParameters[ "month" ] | { absolute: TTimeInstantParameters[ "month" ] } | TMonthName | TRelativeNumber | { relative: number, relativeTo: 'now' | TimeInstant } | 'next' | 'last' | 'current' | undefined;
|
|
25
|
+
date: TTimeInstantParameters[ "date" ] | { absolute: TTimeInstantParameters[ "date" ] } | TRelativeNumber | { relative: number, relativeTo: 'now' | TimeInstant } | 'next' | 'last' | 'current' | undefined;
|
|
26
|
+
hours: TTimeInstantParameters[ "hours" ] | { absolute: TTimeInstantParameters[ "hours" ] } | TRelativeNumber | { relative: number, relativeTo: 'now' | TimeInstant } | 'next' | 'last' | 'current' | undefined;
|
|
27
|
+
minutes: TTimeInstantParameters[ "minutes" ] | { absolute: TTimeInstantParameters[ "minutes" ] } | TRelativeNumber | { relative: number, relativeTo: 'now' | TimeInstant } | 'next' | 'last' | 'current' | undefined;
|
|
28
|
+
seconds: TTimeInstantParameters[ "seconds" ] | { absolute: TTimeInstantParameters[ "seconds" ] } | TRelativeNumber | { relative: number, relativeTo: 'now' | TimeInstant } | 'next' | 'last' | 'current' | undefined;
|
|
29
|
+
milliseconds: TTimeInstantParameters[ "milliseconds" ] | { absolute: TTimeInstantParameters[ "milliseconds" ] } | TRelativeNumber | { relative: number, relativeTo: 'now' | TimeInstant } | 'next' | 'last' | 'current' | undefined;
|
|
20
30
|
}
|
|
21
31
|
|
|
22
32
|
const defaultTimeInstantCreationParameters: TTimeInstantCreationParameters = {
|
package/src/time/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TDigit, TDigit1_9, TNumber0_1000, TParseableInt } from "../utils/_index";
|
|
1
|
+
import { TDigit, TDigit1_9, TNumber0_1000, TParseableInt, type TPositiveNumber } from "../utils/_index";
|
|
2
2
|
import type { monthNames } from "./constants.ts";
|
|
3
3
|
|
|
4
4
|
export type TOneDigit = `${TDigit}`;
|
|
@@ -19,6 +19,7 @@ export type TThreeDigitsMillisecond = TThreeDigits;
|
|
|
19
19
|
export type TFourDigitsYear = TFourDigits;
|
|
20
20
|
export type TFourDigitsMillisecond = `${'+' | '-'}${TThreeDigits}`;
|
|
21
21
|
|
|
22
|
+
export type TYear = TPositiveNumber;
|
|
22
23
|
export type TMonth = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
23
24
|
export type TMonthName = keyof typeof monthNames;
|
|
24
25
|
|