@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/esbuild/index.mjs CHANGED
@@ -1891,13 +1891,18 @@ var TimeInstant = class _TimeInstant extends TimeBase {
1891
1891
  return TimeDuration_default.fromMs(Math.max(distance, 0));
1892
1892
  }
1893
1893
  distanceFromStartOfDay() {
1894
- return this.distanceFrom(this.atStartOfDay());
1894
+ const params = this.toParameters();
1895
+ const msInDay = params.hours * 36e5 + params.minutes * 6e4 + params.seconds * 1e3 + params.milliseconds;
1896
+ return TimeDuration_default.fromMs(msInDay);
1895
1897
  }
1896
1898
  atStartOfDay() {
1897
1899
  return this.atTime({ hours: 0, minutes: 0, seconds: 0, milliseconds: 0 });
1898
1900
  }
1899
1901
  distanceFromEndOfDay() {
1900
- return this.distanceFrom(this.atEndOfDay());
1902
+ const params = this.toParameters();
1903
+ const msInDay = params.hours * 36e5 + params.minutes * 6e4 + params.seconds * 1e3 + params.milliseconds;
1904
+ const msUntilEndOfDay = 86399999 - msInDay;
1905
+ return TimeDuration_default.fromMs(msUntilEndOfDay);
1901
1906
  }
1902
1907
  atEndOfDay() {
1903
1908
  return this.atTime({ hours: 23, minutes: 59, seconds: 59, milliseconds: 999 });
@@ -1923,7 +1928,7 @@ var TimeInstant = class _TimeInstant extends TimeBase {
1923
1928
  throw new Error("Instant is not in the past");
1924
1929
  }
1925
1930
  isToday() {
1926
- return Math.floor(this.days) === Math.floor(_TimeInstant.now().days);
1931
+ return Math.floor(this.ms / 864e5) === Math.floor(Date.now() / 864e5);
1927
1932
  }
1928
1933
  /**
1929
1934
  * Formats this instant using the given pattern. The pattern can contain the following tokens:
@@ -1990,9 +1995,12 @@ var TimeInstant = class _TimeInstant extends TimeBase {
1990
1995
  * @throws Error if the string doesn't match the pattern or contains invalid basic values
1991
1996
  * @todo Add calendar-aware validation to reject dates like February 30th, April 31st
1992
1997
  */
1993
- static parse(dateString, pattern, base = _TimeInstant.now(), config = {}) {
1998
+ static fromString(dateString, pattern, base = _TimeInstant.now(), config = {}) {
1994
1999
  return parseTimeInstant(dateString, pattern, base, config);
1995
2000
  }
2001
+ static parse(dateString, pattern, config = {}) {
2002
+ return parseTimeInstantComponents(dateString, pattern, config);
2003
+ }
1996
2004
  /**
1997
2005
  * @returns this instant, in ISO 8601 format (eg, 2024-11-01T15:49:22.024Z). The format is meant to always be realiable.
1998
2006
  */
@@ -2011,8 +2019,17 @@ var TimeInstant = class _TimeInstant extends TimeBase {
2011
2019
  toDate() {
2012
2020
  return new Date(this.ms);
2013
2021
  }
2014
- toDateUTC() {
2015
- return new Date(this.ms + (/* @__PURE__ */ new Date()).getTimezoneOffset() * 60 * 1e3);
2022
+ toParameters() {
2023
+ const d = this.toDate();
2024
+ return {
2025
+ year: d.getUTCFullYear(),
2026
+ month: d.getUTCMonth() + 1,
2027
+ date: d.getUTCDate(),
2028
+ hours: d.getUTCHours(),
2029
+ minutes: d.getUTCMinutes(),
2030
+ seconds: d.getUTCSeconds(),
2031
+ milliseconds: d.getUTCMilliseconds()
2032
+ };
2016
2033
  }
2017
2034
  /**
2018
2035
  * @returns true if the instant is in the past, false otherwise
@@ -2143,30 +2160,21 @@ var TimeInstant = class _TimeInstant extends TimeBase {
2143
2160
  const timestamp2 = Math.round(this.ms / unitMs) * unitMs;
2144
2161
  return _TimeInstant.fromUnixTimestamp(timestamp2);
2145
2162
  }
2146
- get dayOfMonth() {
2147
- return this.toDate().getUTCDate();
2148
- }
2149
- get dayOfWeek() {
2150
- return this.toDate().getUTCDay() + 1;
2151
- }
2152
- get month() {
2153
- return this.toDate().getUTCMonth() + 1;
2154
- }
2155
- get year() {
2156
- return this.toDate().getUTCFullYear();
2157
- }
2158
2163
  /**
2159
2164
  * Returns the week number represented by this instant, according to the ISO 8601 standard.
2160
- * Please note that the instant and the week number could be of two different years, eg the friday 1st january is actually part of week 52 of the previous year.
2165
+ * Please note that the instant and the week number could be of two different years, eg the friday 1st january is actually part of week 52 of the previous year.
2161
2166
  */
2162
2167
  get weekNumber() {
2163
2168
  const date = this.toDate();
2164
2169
  const oneDay = 1e3 * 60 * 60 * 24;
2165
- const thursdayOfThisWeek = new Date(date.getFullYear(), date.getMonth(), date.getDate() + 4 - (date.getDay() || 7), 14, 0, 0);
2166
- const firstOfJanuary = new Date(thursdayOfThisWeek.getFullYear(), 0, 1, 14, 0, 0);
2167
- const dayOfTheYear = Math.round((thursdayOfThisWeek.getTime() - firstOfJanuary.getTime()) / oneDay);
2170
+ const dayOfWeek = date.getUTCDay() || 7;
2171
+ const thursdayMs = this.ms + (4 - dayOfWeek) * oneDay;
2172
+ const thursdayDate = new Date(thursdayMs);
2173
+ const thursdayYear = thursdayDate.getUTCFullYear();
2174
+ const firstOfJanMs = Date.UTC(thursdayYear, 0, 1, 12, 0, 0);
2175
+ const dayOfTheYear = Math.round((thursdayMs - firstOfJanMs) / oneDay);
2168
2176
  const weekNumber = Math.floor(dayOfTheYear / 7) + 1;
2169
- return { weekNumber, year: thursdayOfThisWeek.getFullYear() };
2177
+ return { weekNumber, year: thursdayYear };
2170
2178
  }
2171
2179
  /**
2172
2180
  * This method is used to provide a better DX when inspecting a TimeInstant object in DevTools.
@@ -2207,111 +2215,118 @@ function isValidSecond(num) {
2207
2215
  function isValidMillisecond(num) {
2208
2216
  return num >= 0 && num <= 999;
2209
2217
  }
2218
+ var monthNamesCache = /* @__PURE__ */ new Map();
2219
+ function getMonthNames(locale = "en") {
2220
+ const cached = monthNamesCache.get(locale);
2221
+ if (cached) {
2222
+ return cached;
2223
+ }
2224
+ const shortFormatter = new Intl.DateTimeFormat(locale, { month: "short" });
2225
+ const longFormatter = new Intl.DateTimeFormat(locale, { month: "long" });
2226
+ const short = [];
2227
+ const long = [];
2228
+ for (let month = 0; month < 12; month++) {
2229
+ const date = new Date(2e3, month, 1);
2230
+ short.push(normalizeMonthName(shortFormatter.format(date)));
2231
+ long.push(normalizeMonthName(longFormatter.format(date)));
2232
+ }
2233
+ const result = { short, long };
2234
+ monthNamesCache.set(locale, result);
2235
+ return result;
2236
+ }
2237
+ function normalizeMonthName(name) {
2238
+ return name.replace(/[.,;:!?]/g, "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").trim();
2239
+ }
2210
2240
  var PATTERN_REGEX = /(M|y|d|D|h|H|m|s|S|G|Z|P|a)+/g;
2211
2241
  var ESCAPE_REGEX = /\\"|"((?:\\"|[^"])*)"/g;
2212
- var optionNames = {
2213
- y: "year",
2214
- M: "month",
2215
- d: "day",
2216
- D: "weekday",
2217
- S: "fractionalSecondDigits",
2218
- G: "era",
2219
- Z: "timeZoneName",
2220
- P: "dayPeriod",
2221
- a: "hour12",
2222
- h: "hour",
2223
- H: "hour",
2224
- m: "minute",
2225
- s: "second"
2226
- };
2227
- var values = {
2228
- y: ["numeric", "2-digit", void 0, "numeric"],
2229
- M: ["narrow", "2-digit", "short", "long"],
2230
- d: ["numeric", "2-digit"],
2231
- D: ["narrow", "short", "long"],
2232
- S: [1, 2, 3],
2233
- G: ["narrow", "short", "long"],
2234
- Z: ["short", "long"],
2235
- P: ["narrow", "short", "long"],
2236
- a: [true],
2237
- h: ["numeric", "2-digit"],
2238
- H: ["numeric", "2-digit"],
2239
- m: ["numeric", "2-digit"],
2240
- s: ["numeric", "2-digit"]
2242
+ var formatterConfigs = {
2243
+ // Year
2244
+ "y": { options: { year: "numeric" } },
2245
+ "yy": { options: { year: "2-digit" } },
2246
+ "yyyy": { options: { year: "numeric" } },
2247
+ // Month
2248
+ "M": { options: { month: "numeric" } },
2249
+ "MM": { options: { month: "2-digit" } },
2250
+ "MMM": { options: { month: "short" } },
2251
+ "MMMM": { options: { month: "long" } },
2252
+ // Day
2253
+ "d": { options: { day: "numeric" } },
2254
+ "dd": { options: { day: "2-digit" } },
2255
+ // Hours (24-hour) - extract and pad manually due to Intl quirk
2256
+ "H": { options: { hour: "numeric", hour12: false }, extract: { partType: "hour" } },
2257
+ "HH": { options: { hour: "2-digit", hour12: false }, extract: { partType: "hour", transform: (v) => v.padStart(2, "0") } },
2258
+ // Hours (12-hour) - extract and pad manually due to Intl quirk
2259
+ "h": { options: { hour: "numeric", hour12: true }, extract: { partType: "hour" } },
2260
+ "hh": { options: { hour: "2-digit", hour12: true }, extract: { partType: "hour", transform: (v) => v.padStart(2, "0") } },
2261
+ // Minutes - extract and pad manually due to Intl quirk
2262
+ "m": { options: { minute: "numeric" }, extract: { partType: "minute" } },
2263
+ "mm": { options: { minute: "2-digit" }, extract: { partType: "minute", transform: (v) => v.padStart(2, "0") } },
2264
+ // Seconds - extract and pad manually due to Intl quirk
2265
+ "s": { options: { second: "numeric" }, extract: { partType: "second" } },
2266
+ "ss": { options: { second: "2-digit" }, extract: { partType: "second", transform: (v) => v.padStart(2, "0") } },
2267
+ // Milliseconds - extract manually
2268
+ "S": { options: { fractionalSecondDigits: 1 }, extract: { partType: "fractionalSecond" } },
2269
+ "SS": { options: { fractionalSecondDigits: 2 }, extract: { partType: "fractionalSecond" } },
2270
+ "SSS": { options: { fractionalSecondDigits: 3 }, extract: { partType: "fractionalSecond" } },
2271
+ // Weekday
2272
+ "D": { options: { weekday: "narrow" } },
2273
+ "DD": { options: { weekday: "short" } },
2274
+ "DDD": { options: { weekday: "long" } },
2275
+ // Era
2276
+ "G": { options: { era: "narrow" } },
2277
+ "GG": { options: { era: "short" } },
2278
+ "GGG": { options: { era: "long" } },
2279
+ // Timezone
2280
+ "Z": { options: { timeZoneName: "short" } },
2281
+ "ZZ": { options: { timeZoneName: "long" } },
2282
+ // Day period
2283
+ "P": { options: { dayPeriod: "narrow" } },
2284
+ "PP": { options: { dayPeriod: "short" } },
2285
+ "PPP": { options: { dayPeriod: "long" } },
2286
+ // Meridiem - extract dayPeriod and lowercase it
2287
+ "a": { options: { hour: "numeric", hour12: true }, extract: { partType: "dayPeriod", transform: (v) => v.toLowerCase() } }
2241
2288
  };
2242
- function formatType(instant, type, length, { locale, timeZone } = {}) {
2243
- if (type === "y") {
2244
- const year = instant.year;
2245
- if (length === 2) {
2246
- return String(year).slice(-2);
2247
- }
2248
- return String(year);
2249
- }
2250
- if (type === "M" && (length === 1 || length === 2)) {
2251
- const month = instant.month;
2252
- return length === 2 && month < 10 ? "0" + month : String(month);
2253
- }
2254
- if (type === "d" && (length === 1 || length === 2)) {
2255
- const day = instant.dayOfMonth;
2256
- return length === 2 && day < 10 ? "0" + day : String(day);
2257
- }
2258
- if (type === "H" && (length === 1 || length === 2)) {
2259
- const hours = instant.toDate().getUTCHours();
2260
- return length === 2 && hours < 10 ? "0" + hours : String(hours);
2261
- }
2262
- if (type === "h" && (length === 1 || length === 2)) {
2263
- let hours = instant.toDate().getUTCHours();
2264
- hours = hours === 0 ? 12 : hours > 12 ? hours - 12 : hours;
2265
- return length === 2 && hours < 10 ? "0" + hours : String(hours);
2266
- }
2267
- if (type === "m" && (length === 1 || length === 2)) {
2268
- const minutes = instant.toDate().getUTCMinutes();
2269
- return length === 2 && minutes < 10 ? "0" + minutes : String(minutes);
2270
- }
2271
- if (type === "s" && (length === 1 || length === 2)) {
2272
- const seconds = instant.toDate().getUTCSeconds();
2273
- return length === 2 && seconds < 10 ? "0" + seconds : String(seconds);
2274
- }
2275
- if (type === "S") {
2276
- const ms = instant.toDate().getUTCMilliseconds();
2277
- if (length === 1) return String(Math.floor(ms / 100));
2278
- if (length === 2) return String(Math.floor(ms / 10)).padStart(2, "0");
2279
- if (length === 3) return String(ms).padStart(3, "0");
2280
- return String(ms);
2281
- }
2282
- const date = instant.toDate();
2283
- const option = optionNames[type];
2284
- const value = values[type][length - 1];
2285
- if (!value) {
2286
- return;
2287
- }
2288
- const options = {
2289
- [option]: value,
2290
- timeZone
2291
- };
2292
- if (type === "a") {
2293
- return Intl.DateTimeFormat(locale, {
2294
- ...options,
2295
- hour: "numeric"
2296
- }).formatToParts(date).pop()?.value;
2297
- }
2298
- if (type === "G" || type === "Z") {
2299
- return Intl.DateTimeFormat(locale, options).formatToParts(date).pop()?.value;
2289
+ function formatType(type, length, date, locale = "en", timeZone = "UTC") {
2290
+ const tokenKey = type.repeat(length);
2291
+ const config = formatterConfigs[tokenKey];
2292
+ if (!config) {
2293
+ return void 0;
2294
+ }
2295
+ const formatter = new Intl.DateTimeFormat(locale, { ...config.options, timeZone });
2296
+ if (config.extract) {
2297
+ const part = formatter.formatToParts(date).find((p) => p.type === config.extract.partType);
2298
+ const value = part?.value;
2299
+ if (!value) {
2300
+ return void 0;
2301
+ }
2302
+ return config.extract.transform ? config.extract.transform(value) : value;
2300
2303
  }
2301
- return Intl.DateTimeFormat(locale, options).format(date);
2304
+ return formatter.format(date);
2302
2305
  }
2303
2306
  function formatTimeInstant(instant, pattern, config = {}) {
2307
+ const date = instant.toDate();
2308
+ const locale = config.locale || "en";
2309
+ const timeZone = config.timeZone || "UTC";
2304
2310
  return pattern.split(ESCAPE_REGEX).filter((sub) => sub !== void 0).map((sub, index) => {
2305
2311
  if (index % 2 !== 0) {
2306
2312
  return sub;
2307
2313
  }
2308
2314
  return sub.replace(PATTERN_REGEX, (match) => {
2309
2315
  const type = match.charAt(0);
2310
- return formatType(instant, type, match.length, config) || match;
2316
+ const length = match.length;
2317
+ return formatType(type, length, date, locale, timeZone) || match;
2311
2318
  });
2312
2319
  }).join("");
2313
2320
  }
2314
2321
  function parseTimeInstant(dateString, pattern, base, config = {}) {
2322
+ const parsed = parseTimeInstantComponents(dateString, pattern, config);
2323
+ const params = {
2324
+ ...base.toParameters(),
2325
+ ...parsed
2326
+ };
2327
+ return TimeInstant.fromParameters(params);
2328
+ }
2329
+ function parseTimeInstantComponents(dateString, pattern, config = {}) {
2315
2330
  let regexPattern = pattern;
2316
2331
  const tokens = [];
2317
2332
  let position = 0;
@@ -2329,7 +2344,7 @@ function parseTimeInstant(dateString, pattern, base, config = {}) {
2329
2344
  case "M":
2330
2345
  if (match.length === 1) return "(\\d{1,2})";
2331
2346
  if (match.length === 2) return "(\\d{2})";
2332
- if (match.length === 3) return "([A-Za-z]{3})";
2347
+ if (match.length === 3) return "([A-Za-z.]{1,7})";
2333
2348
  return "([A-Za-z]+)";
2334
2349
  case "d":
2335
2350
  return match.length === 1 ? "(\\d{1,2})" : "(\\d{2})";
@@ -2365,113 +2380,110 @@ function parseTimeInstant(dateString, pattern, base, config = {}) {
2365
2380
  if (!matches) {
2366
2381
  throw new Error(`Date string "${dateString}" does not match pattern "${pattern}"`);
2367
2382
  }
2368
- let year = base.year;
2369
- let month = base.month;
2370
- let day = base.dayOfMonth;
2371
- let hour = base.toDate().getUTCHours();
2372
- let minute = base.toDate().getUTCMinutes();
2373
- let second = base.toDate().getUTCSeconds();
2374
- let millisecond = base.toDate().getUTCMilliseconds();
2383
+ const result = {};
2384
+ const locale = config.locale || "en";
2375
2385
  let isPM = false;
2376
2386
  let is12Hour = false;
2387
+ let hourValue;
2377
2388
  tokens.forEach((token, index) => {
2378
2389
  const value = matches[index + 1];
2379
2390
  switch (token.type) {
2380
2391
  case "y":
2381
2392
  if (token.length === 2) {
2382
2393
  const shortYear = parseInt(value, 10);
2383
- year = shortYear < 50 ? 2e3 + shortYear : 1900 + shortYear;
2394
+ result.year = shortYear < 50 ? 2e3 + shortYear : 1900 + shortYear;
2384
2395
  } else {
2385
- year = parseInt(value, 10);
2396
+ result.year = parseInt(value, 10);
2386
2397
  }
2387
2398
  break;
2388
2399
  case "M":
2389
- if (token.length <= 2) {
2390
- month = parseInt(value, 10);
2391
- } else {
2392
- const monthNames2 = [
2393
- "Jan",
2394
- "Feb",
2395
- "Mar",
2396
- "Apr",
2397
- "May",
2398
- "Jun",
2399
- "Jul",
2400
- "Aug",
2401
- "Sep",
2402
- "Oct",
2403
- "Nov",
2404
- "Dec"
2405
- ];
2406
- const longMonthNames = [
2407
- "January",
2408
- "February",
2409
- "March",
2410
- "April",
2411
- "May",
2412
- "June",
2413
- "July",
2414
- "August",
2415
- "September",
2416
- "October",
2417
- "November",
2418
- "December"
2419
- ];
2420
- let monthIndex = monthNames2.findIndex((name) => name.toLowerCase() === value.toLowerCase());
2421
- if (monthIndex === -1) {
2422
- monthIndex = longMonthNames.findIndex((name) => name.toLowerCase() === value.toLowerCase());
2400
+ switch (token.length) {
2401
+ case 1:
2402
+ case 2:
2403
+ result.month = parseInt(value, 10);
2404
+ break;
2405
+ case 3: {
2406
+ const normalizedValue = normalizeMonthName(value);
2407
+ const monthIndex = getMonthNames(locale).short.findIndex(
2408
+ (name) => name.toLowerCase() === normalizedValue.toLowerCase()
2409
+ );
2410
+ if (monthIndex === -1)
2411
+ throw new Error(`Invalid short month name in date string: ${dateString}`);
2412
+ result.month = monthIndex + 1;
2413
+ break;
2414
+ }
2415
+ case 4: {
2416
+ const normalizedValue = normalizeMonthName(value);
2417
+ const monthIndex = getMonthNames(locale).long.findIndex(
2418
+ (name) => name.toLowerCase() === normalizedValue.toLowerCase()
2419
+ );
2420
+ if (monthIndex === -1)
2421
+ throw new Error(`Invalid full month name in date string: ${dateString}`);
2422
+ result.month = monthIndex + 1;
2423
+ break;
2423
2424
  }
2424
- month = monthIndex !== -1 ? monthIndex + 1 : 1;
2425
+ default:
2426
+ throw new Error(`Invalid month pattern: ${token}`);
2425
2427
  }
2426
2428
  break;
2427
2429
  case "d":
2428
- day = parseInt(value, 10);
2430
+ result.date = parseInt(value, 10);
2429
2431
  break;
2430
2432
  case "H":
2431
- hour = parseInt(value, 10);
2433
+ result.hours = parseInt(value, 10);
2432
2434
  break;
2433
2435
  case "h":
2434
- hour = parseInt(value, 10);
2436
+ hourValue = parseInt(value, 10);
2435
2437
  is12Hour = true;
2436
2438
  break;
2437
2439
  case "m":
2438
- minute = parseInt(value, 10);
2440
+ result.minutes = parseInt(value, 10);
2439
2441
  break;
2440
2442
  case "s":
2441
- second = parseInt(value, 10);
2443
+ result.seconds = parseInt(value, 10);
2442
2444
  break;
2443
2445
  case "S":
2444
2446
  let ms = parseInt(value, 10);
2445
2447
  if (token.length === 1) ms *= 100;
2446
2448
  else if (token.length === 2) ms *= 10;
2447
- millisecond = ms;
2449
+ result.milliseconds = ms;
2448
2450
  break;
2449
2451
  case "a":
2450
2452
  isPM = value.toLowerCase().includes("p");
2451
2453
  break;
2452
2454
  }
2453
2455
  });
2454
- if (is12Hour && isPM && hour < 12) {
2455
- hour += 12;
2456
- } else if (is12Hour && !isPM && hour === 12) {
2457
- hour = 0;
2458
- }
2459
- if (!isValidYear(year)) throw new Error(`Invalid year in date string: ${dateString}`);
2460
- if (!isValidMonth(month)) throw new Error(`Invalid month in date string: ${dateString}`);
2461
- if (!isValidDayOfMonth(day)) throw new Error(`Invalid day in date string: ${dateString}`);
2462
- if (!isValidHour(hour)) throw new Error(`Invalid hour in date string: ${dateString}`);
2463
- if (!isValidMinute(minute)) throw new Error(`Invalid minute in date string: ${dateString}`);
2464
- if (!isValidSecond(second)) throw new Error(`Invalid second in date string: ${dateString}`);
2465
- if (!isValidMillisecond(millisecond)) throw new Error(`Invalid millisecond in date string: ${dateString}`);
2466
- return TimeInstant.fromParameters({
2467
- year,
2468
- month,
2469
- date: day,
2470
- hours: hour,
2471
- minutes: minute,
2472
- seconds: second,
2473
- milliseconds: millisecond
2474
- });
2456
+ if (is12Hour && hourValue !== void 0) {
2457
+ if (isPM && hourValue < 12) {
2458
+ result.hours = hourValue + 12;
2459
+ } else if (!isPM && hourValue === 12) {
2460
+ result.hours = 0;
2461
+ } else {
2462
+ result.hours = hourValue;
2463
+ }
2464
+ }
2465
+ if (typeof result.year === "number" && !isValidYear(result.year)) {
2466
+ throw new Error(`Invalid year in date string: ${dateString}`);
2467
+ }
2468
+ if (typeof result.month === "number" && !isValidMonth(result.month)) {
2469
+ throw new Error(`Invalid month in date string: ${dateString}`);
2470
+ }
2471
+ if (typeof result.date === "number" && !isValidDayOfMonth(result.date)) {
2472
+ throw new Error(`Invalid day in date string: ${dateString}`);
2473
+ }
2474
+ if (typeof result.hours === "number" && !isValidHour(result.hours)) {
2475
+ throw new Error(`Invalid hour in date string: ${dateString}`);
2476
+ }
2477
+ if (typeof result.minutes === "number" && !isValidMinute(result.minutes)) {
2478
+ throw new Error(`Invalid minute in date string: ${dateString}`);
2479
+ }
2480
+ if (typeof result.seconds === "number" && !isValidSecond(result.seconds)) {
2481
+ throw new Error(`Invalid second in date string: ${dateString}`);
2482
+ }
2483
+ if (typeof result.milliseconds === "number" && !isValidMillisecond(result.milliseconds)) {
2484
+ throw new Error(`Invalid millisecond in date string: ${dateString}`);
2485
+ }
2486
+ return result;
2475
2487
  }
2476
2488
 
2477
2489
  // src/Logger.ts