@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@zelgadis87/utils-core",
4
- "version": "5.2.11",
4
+ "version": "5.2.12",
5
5
  "author": "Zelgadis87",
6
6
  "license": "ISC",
7
7
  "private": false,
@@ -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<TTimeInstantCreationParameters> {
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
- // TODO: Add calendar-aware validation to check month-specific day limits
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: number;
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