@zelgadis87/utils-core 5.2.11 → 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 +1 -1
- package/dist/time/TimeInstant.d.ts +1 -1
- package/dist/time/TimeInstantBuilder.d.ts +2 -2
- package/dist/time/types.d.ts +2 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/esbuild/index.cjs.map +2 -2
- package/esbuild/index.mjs.map +2 -2
- package/package.json +1 -1
- package/src/time/TimeInstant.ts +5 -5
- package/src/time/TimeInstantBuilder.ts +2 -2
- package/src/time/types.ts +2 -1
package/package.json
CHANGED
package/src/time/TimeInstant.ts
CHANGED
|
@@ -4,7 +4,7 @@ import TimeBase from "./TimeBase";
|
|
|
4
4
|
import TimeDuration from "./TimeDuration";
|
|
5
5
|
import { TTimeInstantBuilder, TTimeInstantCreationParameters, createTimeInstantFromParameters, timeInstantBuilder, type TTimeInstantParameters } from "./TimeInstantBuilder.js";
|
|
6
6
|
import { TimeUnit } from "./TimeUnit";
|
|
7
|
-
import { TDayOfMonth, TDayOfWeek, THourOfDay, TIso8601DateString, TIso8601DateUtcString, TMillisecondOfSecond, TMinuteOfHour, TMonth, TSecondOfMinute, TWeekNumber } from "./types";
|
|
7
|
+
import { TDayOfMonth, TDayOfWeek, THourOfDay, TIso8601DateString, TIso8601DateUtcString, TMillisecondOfSecond, TMinuteOfHour, TMonth, TSecondOfMinute, TWeekNumber, type TFourDigitsYear, type TYear } from "./types";
|
|
8
8
|
|
|
9
9
|
export class TimeInstant extends TimeBase<TimeInstant> {
|
|
10
10
|
|
|
@@ -170,7 +170,7 @@ export class TimeInstant extends TimeBase<TimeInstant> {
|
|
|
170
170
|
return parseTimeInstant( dateString, pattern, base, config );
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
public static parse( dateString: string, pattern: string, config: { locale?: string, timeZone?: string } = {} ): Partial<
|
|
173
|
+
public static parse( dateString: string, pattern: string, config: { locale?: string, timeZone?: string } = {} ): Partial<TTimeInstantParameters> {
|
|
174
174
|
return parseTimeInstantComponents( dateString, pattern, config );
|
|
175
175
|
}
|
|
176
176
|
|
|
@@ -428,9 +428,7 @@ export default TimeInstant;
|
|
|
428
428
|
// Utility functions for date formatting and parsing
|
|
429
429
|
|
|
430
430
|
// Standalone validation functions
|
|
431
|
-
|
|
432
|
-
// (e.g., reject February 30th, April 31st, February 29th in non-leap years)
|
|
433
|
-
function isValidYear( num: number ): boolean {
|
|
431
|
+
function isValidYear( num: number ): num is TYear {
|
|
434
432
|
return num >= 0 && num <= 9999;
|
|
435
433
|
}
|
|
436
434
|
|
|
@@ -438,6 +436,8 @@ function isValidMonth( num: number ): num is TMonth {
|
|
|
438
436
|
return num >= 1 && num <= 12;
|
|
439
437
|
}
|
|
440
438
|
|
|
439
|
+
// TODO: Add calendar-aware validation to check month-specific day limits
|
|
440
|
+
// (e.g., reject February 30th, April 31st, February 29th in non-leap years)
|
|
441
441
|
function isValidDayOfMonth( num: number ): num is TDayOfMonth {
|
|
442
442
|
return num >= 1 && num <= 31;
|
|
443
443
|
}
|
|
@@ -3,14 +3,14 @@ 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
12
|
export type TTimeInstantParameters = {
|
|
13
|
-
year:
|
|
13
|
+
year: TYear;
|
|
14
14
|
month: TMonth;
|
|
15
15
|
date: TDayOfMonth;
|
|
16
16
|
hours: THourOfDay;
|
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
|
|