superjs-core 0.4.4 → 0.6.0

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.
@@ -269,5 +269,320 @@ declare function toTimezone(date: Date, offsetHours: number): Date;
269
269
  * @returns The formatted date string.
270
270
  */
271
271
  declare function formatInTimezone(date: Date, format: string, offsetHours: number): string;
272
+ /**
273
+ * Checks if a date is today.
274
+ *
275
+ * @param date - The date to check.
276
+ * @returns Whether the date is today.
277
+ * @throws {InvalidDateError} If the input date is invalid.
278
+ *
279
+ * @example
280
+ * isToday(new Date()) // true
281
+ */
282
+ declare function isToday(date: Date): boolean;
283
+ /**
284
+ * Checks if a date is yesterday.
285
+ *
286
+ * @param date - The date to check.
287
+ * @returns Whether the date is yesterday.
288
+ * @throws {InvalidDateError} If the input date is invalid.
289
+ *
290
+ * @example
291
+ * isYesterday(new Date(Date.now() - 86400000)) // true
292
+ */
293
+ declare function isYesterday(date: Date): boolean;
294
+ /**
295
+ * Checks if a date is tomorrow.
296
+ *
297
+ * @param date - The date to check.
298
+ * @returns Whether the date is tomorrow.
299
+ * @throws {InvalidDateError} If the input date is invalid.
300
+ *
301
+ * @example
302
+ * isTomorrow(new Date(Date.now() + 86400000)) // true
303
+ */
304
+ declare function isTomorrow(date: Date): boolean;
305
+ /**
306
+ * Checks if a date is in the past (before now).
307
+ *
308
+ * @param date - The date to check.
309
+ * @returns Whether the date is in the past.
310
+ * @throws {InvalidDateError} If the input date is invalid.
311
+ *
312
+ * @example
313
+ * isPast(new Date('2020-01-01')) // true
314
+ */
315
+ declare function isPast(date: Date): boolean;
316
+ /**
317
+ * Checks if a date is in the future (after now).
318
+ *
319
+ * @param date - The date to check.
320
+ * @returns Whether the date is in the future.
321
+ * @throws {InvalidDateError} If the input date is invalid.
322
+ *
323
+ * @example
324
+ * isFuture(new Date('2099-01-01')) // true
325
+ */
326
+ declare function isFuture(date: Date): boolean;
327
+ /**
328
+ * Checks if two dates fall on the same calendar day.
329
+ *
330
+ * @param date1 - First date.
331
+ * @param date2 - Second date.
332
+ * @returns Whether the dates are the same day.
333
+ * @throws {InvalidDateError} If either date is invalid.
334
+ *
335
+ * @example
336
+ * isSameDay(new Date('2024-01-01'), new Date('2024-01-01')) // true
337
+ */
338
+ declare function isSameDay(date1: Date, date2: Date): boolean;
339
+ /**
340
+ * Returns the number of days in the month of the given date.
341
+ *
342
+ * @param date - The date.
343
+ * @returns Number of days in the month (28–31).
344
+ * @throws {InvalidDateError} If the input date is invalid.
345
+ *
346
+ * @example
347
+ * daysInMonth(new Date('2024-02-01')) // 29 (leap year)
348
+ */
349
+ declare function daysInMonth(date: Date): number;
350
+ /**
351
+ * Returns the day of the year (1–366).
352
+ *
353
+ * @param date - The date.
354
+ * @returns Day of the year (1-indexed).
355
+ * @throws {InvalidDateError} If the input date is invalid.
356
+ *
357
+ * @example
358
+ * dayOfYear(new Date('2024-01-01')) // 1
359
+ */
360
+ declare function dayOfYear(date: Date): number;
361
+ /**
362
+ * Returns the ISO week number (1–53).
363
+ *
364
+ * The algorithm uses the Thursday of the same week as the reference
365
+ * to determine which year the week belongs to, per ISO 8601.
366
+ *
367
+ * @param date - The date.
368
+ * @returns The ISO week number.
369
+ * @throws {InvalidDateError} If the input date is invalid.
370
+ *
371
+ * @example
372
+ * weekOfYear(new Date('2024-01-01')) // 1
373
+ */
374
+ declare function weekOfYear(date: Date): number;
375
+ /**
376
+ * Returns the quarter of the year (1–4).
377
+ *
378
+ * @param date - The date.
379
+ * @returns The quarter (1 for Jan–Mar, 2 for Apr–Jun, etc.).
380
+ * @throws {InvalidDateError} If the input date is invalid.
381
+ *
382
+ * @example
383
+ * quarter(new Date('2024-04-01')) // 2
384
+ */
385
+ declare function quarter(date: Date): number;
386
+ /**
387
+ * Returns the latest (maximum) date from an array of dates.
388
+ *
389
+ * @param dates - Array of Date objects.
390
+ * @returns The latest date.
391
+ * @throws {Error} If the array is empty.
392
+ * @throws {InvalidDateError} If any date is invalid.
393
+ *
394
+ * @example
395
+ * maxDate([new Date('2024-01-01'), new Date('2025-01-01')]) // 2025-01-01
396
+ */
397
+ declare function maxDate(dates: Date[]): Date;
398
+ /**
399
+ * Returns the earliest (minimum) date from an array of dates.
400
+ *
401
+ * @param dates - Array of Date objects.
402
+ * @returns The earliest date.
403
+ * @throws {Error} If the array is empty.
404
+ * @throws {InvalidDateError} If any date is invalid.
405
+ *
406
+ * @example
407
+ * minDate([new Date('2024-01-01'), new Date('2025-01-01')]) // 2024-01-01
408
+ */
409
+ declare function minDate(dates: Date[]): Date;
410
+ /**
411
+ * Returns the next Monday from the given date.
412
+ *
413
+ * @param date - Reference date.
414
+ * @returns The next Monday.
415
+ * @throws {InvalidDateError} If the input date is invalid.
416
+ *
417
+ * @example
418
+ * nextMonday(new Date('2024-01-01')) // 2024-01-08 (Monday)
419
+ */
420
+ declare function nextMonday(date: Date): Date;
421
+ /**
422
+ * Returns the next Tuesday from the given date.
423
+ *
424
+ * @param date - Reference date.
425
+ * @returns The next Tuesday.
426
+ * @throws {InvalidDateError} If the input date is invalid.
427
+ *
428
+ * @example
429
+ * nextTuesday(new Date('2024-01-01')) // 2024-01-02 (Tuesday)
430
+ */
431
+ declare function nextTuesday(date: Date): Date;
432
+ /**
433
+ * Returns the next Wednesday from the given date.
434
+ *
435
+ * @param date - Reference date.
436
+ * @returns The next Wednesday.
437
+ * @throws {InvalidDateError} If the input date is invalid.
438
+ */
439
+ declare function nextWednesday(date: Date): Date;
440
+ /**
441
+ * Returns the next Thursday from the given date.
442
+ *
443
+ * @param date - Reference date.
444
+ * @returns The next Thursday.
445
+ * @throws {InvalidDateError} If the input date is invalid.
446
+ */
447
+ declare function nextThursday(date: Date): Date;
448
+ /**
449
+ * Returns the next Friday from the given date.
450
+ *
451
+ * @param date - Reference date.
452
+ * @returns The next Friday.
453
+ * @throws {InvalidDateError} If the input date is invalid.
454
+ */
455
+ declare function nextFriday(date: Date): Date;
456
+ /**
457
+ * Returns the next Saturday from the given date.
458
+ *
459
+ * @param date - Reference date.
460
+ * @returns The next Saturday.
461
+ * @throws {InvalidDateError} If the input date is invalid.
462
+ */
463
+ declare function nextSaturday(date: Date): Date;
464
+ /**
465
+ * Returns the next Sunday from the given date.
466
+ *
467
+ * @param date - Reference date.
468
+ * @returns The next Sunday.
469
+ * @throws {InvalidDateError} If the input date is invalid.
470
+ */
471
+ declare function nextSunday(date: Date): Date;
472
+ /**
473
+ * Returns the last (previous) Monday from the given date.
474
+ *
475
+ * @param date - Reference date.
476
+ * @returns The last Monday.
477
+ * @throws {InvalidDateError} If the input date is invalid.
478
+ *
479
+ * @example
480
+ * lastMonday(new Date('2024-01-03')) // 2024-01-01 (Monday)
481
+ */
482
+ declare function lastMonday(date: Date): Date;
483
+ /**
484
+ * Returns the last (previous) Tuesday from the given date.
485
+ *
486
+ * @param date - Reference date.
487
+ * @returns The last Tuesday.
488
+ * @throws {InvalidDateError} If the input date is invalid.
489
+ */
490
+ declare function lastTuesday(date: Date): Date;
491
+ /**
492
+ * Returns the last (previous) Wednesday from the given date.
493
+ *
494
+ * @param date - Reference date.
495
+ * @returns The last Wednesday.
496
+ * @throws {InvalidDateError} If the input date is invalid.
497
+ */
498
+ declare function lastWednesday(date: Date): Date;
499
+ /**
500
+ * Returns the last (previous) Thursday from the given date.
501
+ *
502
+ * @param date - Reference date.
503
+ * @returns The last Thursday.
504
+ * @throws {InvalidDateError} If the input date is invalid.
505
+ */
506
+ declare function lastThursday(date: Date): Date;
507
+ /**
508
+ * Returns the last (previous) Friday from the given date.
509
+ *
510
+ * @param date - Reference date.
511
+ * @returns The last Friday.
512
+ * @throws {InvalidDateError} If the input date is invalid.
513
+ *
514
+ * @example
515
+ * lastFriday(new Date('2024-01-03')) // 2023-12-29 (Friday)
516
+ */
517
+ declare function lastFriday(date: Date): Date;
518
+ /**
519
+ * Returns the last (previous) Saturday from the given date.
520
+ *
521
+ * @param date - Reference date.
522
+ * @returns The last Saturday.
523
+ * @throws {InvalidDateError} If the input date is invalid.
524
+ */
525
+ declare function lastSaturday(date: Date): Date;
526
+ /**
527
+ * Returns the last (previous) Sunday from the given date.
528
+ *
529
+ * @param date - Reference date.
530
+ * @returns The last Sunday.
531
+ * @throws {InvalidDateError} If the input date is invalid.
532
+ */
533
+ declare function lastSunday(date: Date): Date;
534
+ /**
535
+ * Parses a human-readable duration string into milliseconds.
536
+ *
537
+ * Supported units:
538
+ * - `w` — weeks
539
+ * - `d` — days
540
+ * - `h` — hours
541
+ * - `m` — minutes
542
+ * - `s` — seconds
543
+ *
544
+ * @param input - Duration string (e.g. `"1h30m"`, `"2d"`, `"1w2d6h"`).
545
+ * @returns Total milliseconds.
546
+ *
547
+ * @example
548
+ * parseDuration('1h30m') // 5400000
549
+ * parseDuration('2d') // 172800000
550
+ * parseDuration('1w') // 604800000
551
+ */
552
+ declare function parseDuration(input: string): number;
553
+ /**
554
+ * Checks if a date is an Indonesian public holiday.
555
+ *
556
+ * Includes fixed-date holidays (New Year, Labor Day, Pancasila Day,
557
+ * Independence Day, National Awakening Day, National Heroes Day, Christmas),
558
+ * Easter-based holidays (Good Friday, Easter, Ascension), and lookup-based
559
+ * movable holidays (Chinese New Year, Nyepi, Vesak, Eid al-Fitr,
560
+ * Eid al-Adha, Islamic New Year, Prophet's Birthday, Isra' Mi'raj).
561
+ *
562
+ * Movable holidays (Chinese New Year, Nyepi, Vesak, Islamic holidays) are
563
+ * precomputed for years 2024–2030. Dates outside this range may return
564
+ * `false` for those holidays.
565
+ *
566
+ * @param date - The date to check.
567
+ * @returns Whether the date is an Indonesian public holiday.
568
+ * @throws {InvalidDateError} If the input date is invalid.
569
+ *
570
+ * @example
571
+ * isHolidayIndonesia(new Date('2024-08-17')) // true (Independence Day)
572
+ * isHolidayIndonesia(new Date('2024-12-25')) // true (Christmas)
573
+ */
574
+ declare function isHolidayIndonesia(date: Date): boolean;
575
+ /**
576
+ * Returns the name(s) of Indonesian public holidays for a given date, or an
577
+ * empty array if the date is not a holiday.
578
+ *
579
+ * @param date - The date to check.
580
+ * @returns Array of holiday names.
581
+ * @throws {InvalidDateError} If the input date is invalid.
582
+ *
583
+ * @example
584
+ * getIndonesianHolidayNames(new Date('2024-08-17')) // ['Independence Day']
585
+ */
586
+ declare function getIndonesianHolidayNames(date: Date): string[];
272
587
 
273
- export { type DateDiff, type Duration, InvalidDateError, TIMEZONE_WIB, TIMEZONE_WIT, TIMEZONE_WITA, addBusinessDays, addDays, addMonths, addYears, calculateAge, dateDiff, endOfDay, endOfMonth, endOfYear, formatDate, formatDuration, formatInTimezone, isAfter, isBefore, isBetween, isBusinessDay, isLeapYear, isWeekend, parseDate, startOfDay, startOfMonth, startOfYear, timeAgo, timeRemaining, toTimezone };
588
+ export { type DateDiff, type Duration, InvalidDateError, TIMEZONE_WIB, TIMEZONE_WIT, TIMEZONE_WITA, addBusinessDays, addDays, addMonths, addYears, calculateAge, dateDiff, dayOfYear, daysInMonth, endOfDay, endOfMonth, endOfYear, formatDate, formatDuration, formatInTimezone, getIndonesianHolidayNames, isAfter, isBefore, isBetween, isBusinessDay, isFuture, isHolidayIndonesia, isLeapYear, isPast, isSameDay, isToday, isTomorrow, isWeekend, isYesterday, lastFriday, lastMonday, lastSaturday, lastSunday, lastThursday, lastTuesday, lastWednesday, maxDate, minDate, nextFriday, nextMonday, nextSaturday, nextSunday, nextThursday, nextTuesday, nextWednesday, parseDate, parseDuration, quarter, startOfDay, startOfMonth, startOfYear, timeAgo, timeRemaining, toTimezone, weekOfYear };
@@ -365,6 +365,315 @@ function toTimezone(date, offsetHours) {
365
365
  function formatInTimezone(date, format, offsetHours) {
366
366
  return formatDate(toTimezone(date, offsetHours), format);
367
367
  }
368
+ function isToday(date) {
369
+ if (!isValidDate(date)) throw new InvalidDateError(date);
370
+ const now = /* @__PURE__ */ new Date();
371
+ return date.getFullYear() === now.getFullYear() && date.getMonth() === now.getMonth() && date.getDate() === now.getDate();
372
+ }
373
+ function isYesterday(date) {
374
+ if (!isValidDate(date)) throw new InvalidDateError(date);
375
+ const yesterday = /* @__PURE__ */ new Date();
376
+ yesterday.setDate(yesterday.getDate() - 1);
377
+ return date.getFullYear() === yesterday.getFullYear() && date.getMonth() === yesterday.getMonth() && date.getDate() === yesterday.getDate();
378
+ }
379
+ function isTomorrow(date) {
380
+ if (!isValidDate(date)) throw new InvalidDateError(date);
381
+ const tomorrow = /* @__PURE__ */ new Date();
382
+ tomorrow.setDate(tomorrow.getDate() + 1);
383
+ return date.getFullYear() === tomorrow.getFullYear() && date.getMonth() === tomorrow.getMonth() && date.getDate() === tomorrow.getDate();
384
+ }
385
+ function isPast(date) {
386
+ if (!isValidDate(date)) throw new InvalidDateError(date);
387
+ return date.getTime() < Date.now();
388
+ }
389
+ function isFuture(date) {
390
+ if (!isValidDate(date)) throw new InvalidDateError(date);
391
+ return date.getTime() > Date.now();
392
+ }
393
+ function isSameDay(date1, date2) {
394
+ if (!isValidDate(date1) || !isValidDate(date2)) {
395
+ throw new InvalidDateError("Invalid date provided to isSameDay");
396
+ }
397
+ return date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() === date2.getDate();
398
+ }
399
+ function daysInMonth(date) {
400
+ if (!isValidDate(date)) throw new InvalidDateError(date);
401
+ return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
402
+ }
403
+ function dayOfYear(date) {
404
+ if (!isValidDate(date)) throw new InvalidDateError(date);
405
+ const start = new Date(date.getFullYear(), 0, 0);
406
+ return Math.floor((date.getTime() - start.getTime()) / MS_IN_DAY);
407
+ }
408
+ function weekOfYear(date) {
409
+ if (!isValidDate(date)) throw new InvalidDateError(date);
410
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
411
+ const dayNum = d.getUTCDay() || 7;
412
+ d.setUTCDate(d.getUTCDate() + 4 - dayNum);
413
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
414
+ const weekNum = Math.ceil(((d.getTime() - yearStart.getTime()) / 864e5 + 1) / 7);
415
+ return weekNum;
416
+ }
417
+ function quarter(date) {
418
+ if (!isValidDate(date)) throw new InvalidDateError(date);
419
+ return Math.floor(date.getMonth() / 3) + 1;
420
+ }
421
+ function maxDate(dates) {
422
+ if (dates.length === 0) throw new Error("maxDate requires at least one date");
423
+ const ms = Math.max(...dates.map((d) => {
424
+ if (!isValidDate(d)) throw new InvalidDateError(d);
425
+ return d.getTime();
426
+ }));
427
+ return new Date(ms);
428
+ }
429
+ function minDate(dates) {
430
+ if (dates.length === 0) throw new Error("minDate requires at least one date");
431
+ const ms = Math.min(...dates.map((d) => {
432
+ if (!isValidDate(d)) throw new InvalidDateError(d);
433
+ return d.getTime();
434
+ }));
435
+ return new Date(ms);
436
+ }
437
+ function getNextWeekday(date, targetDay) {
438
+ if (!isValidDate(date)) throw new InvalidDateError(date);
439
+ const result = new Date(date);
440
+ const currentDay = result.getDay();
441
+ let diff = targetDay - currentDay;
442
+ if (diff <= 0) diff += 7;
443
+ result.setDate(result.getDate() + diff);
444
+ return result;
445
+ }
446
+ function getLastWeekday(date, targetDay) {
447
+ if (!isValidDate(date)) throw new InvalidDateError(date);
448
+ const result = new Date(date);
449
+ const currentDay = result.getDay();
450
+ let diff = currentDay - targetDay;
451
+ if (diff <= 0) diff += 7;
452
+ result.setDate(result.getDate() - diff);
453
+ return result;
454
+ }
455
+ function nextMonday(date) {
456
+ return getNextWeekday(date, 1);
457
+ }
458
+ function nextTuesday(date) {
459
+ return getNextWeekday(date, 2);
460
+ }
461
+ function nextWednesday(date) {
462
+ return getNextWeekday(date, 3);
463
+ }
464
+ function nextThursday(date) {
465
+ return getNextWeekday(date, 4);
466
+ }
467
+ function nextFriday(date) {
468
+ return getNextWeekday(date, 5);
469
+ }
470
+ function nextSaturday(date) {
471
+ return getNextWeekday(date, 6);
472
+ }
473
+ function nextSunday(date) {
474
+ return getNextWeekday(date, 0);
475
+ }
476
+ function lastMonday(date) {
477
+ return getLastWeekday(date, 1);
478
+ }
479
+ function lastTuesday(date) {
480
+ return getLastWeekday(date, 2);
481
+ }
482
+ function lastWednesday(date) {
483
+ return getLastWeekday(date, 3);
484
+ }
485
+ function lastThursday(date) {
486
+ return getLastWeekday(date, 4);
487
+ }
488
+ function lastFriday(date) {
489
+ return getLastWeekday(date, 5);
490
+ }
491
+ function lastSaturday(date) {
492
+ return getLastWeekday(date, 6);
493
+ }
494
+ function lastSunday(date) {
495
+ return getLastWeekday(date, 0);
496
+ }
497
+ function parseDuration(input) {
498
+ const regex = /(\d+)\s*([wdhms])/g;
499
+ let ms = 0;
500
+ let match;
501
+ while ((match = regex.exec(input)) !== null) {
502
+ const val = parseInt(match[1], 10);
503
+ switch (match[2]) {
504
+ case "w":
505
+ ms += val * 7 * MS_IN_DAY;
506
+ break;
507
+ case "d":
508
+ ms += val * MS_IN_DAY;
509
+ break;
510
+ case "h":
511
+ ms += val * MS_IN_HOUR;
512
+ break;
513
+ case "m":
514
+ ms += val * MS_IN_MINUTE;
515
+ break;
516
+ case "s":
517
+ ms += val * MS_IN_SECOND;
518
+ break;
519
+ }
520
+ }
521
+ return ms;
522
+ }
523
+ var INDONESIAN_FIXED_HOLIDAYS = [
524
+ { name: "New Year", month: 0, day: 1 },
525
+ { name: "Labor Day", month: 4, day: 1 },
526
+ { name: "Pancasila Day", month: 5, day: 1 },
527
+ { name: "Independence Day", month: 7, day: 17 },
528
+ { name: "National Awakening Day", month: 4, day: 20 },
529
+ { name: "National Heroes Day", month: 10, day: 10 },
530
+ { name: "Christmas", month: 11, day: 25 }
531
+ ];
532
+ function computeEaster(year) {
533
+ const a = year % 19;
534
+ const b = Math.floor(year / 100);
535
+ const c = year % 100;
536
+ const d = Math.floor(b / 4);
537
+ const e = b % 4;
538
+ const f = Math.floor((b + 8) / 25);
539
+ const g = Math.floor((b - f + 1) / 3);
540
+ const h = (19 * a + b - d - g + 15) % 30;
541
+ const i = Math.floor(c / 4);
542
+ const k = c % 4;
543
+ const l = (32 + 2 * e + 2 * i - h - k) % 7;
544
+ const m = Math.floor((a + 11 * h + 22 * l) / 451);
545
+ const month = Math.floor((h + l - 7 * m + 114) / 31);
546
+ const day = (h + l - 7 * m + 114) % 31 + 1;
547
+ return new Date(year, month - 1, day);
548
+ }
549
+ var CHINESE_NEW_YEAR = {
550
+ 2024: { month: 1, day: 10 },
551
+ 2025: { month: 0, day: 29 },
552
+ 2026: { month: 1, day: 17 },
553
+ 2027: { month: 1, day: 6 },
554
+ 2028: { month: 0, day: 26 },
555
+ 2029: { month: 1, day: 13 },
556
+ 2030: { month: 2, day: 3 }
557
+ };
558
+ var NYEPI = {
559
+ 2024: { month: 2, day: 11 },
560
+ 2025: { month: 2, day: 29 },
561
+ 2026: { month: 2, day: 19 },
562
+ 2027: { month: 2, day: 7 },
563
+ 2028: { month: 2, day: 26 },
564
+ 2029: { month: 2, day: 15 },
565
+ 2030: { month: 2, day: 5 }
566
+ };
567
+ var VESAK = {
568
+ 2024: { month: 4, day: 23 },
569
+ 2025: { month: 4, day: 12 },
570
+ 2026: { month: 4, day: 31 },
571
+ 2027: { month: 4, day: 20 },
572
+ 2028: { month: 4, day: 9 },
573
+ 2029: { month: 4, day: 28 },
574
+ 2030: { month: 4, day: 18 }
575
+ };
576
+ var EID_AL_FITR = {
577
+ 2024: [{ month: 3, day: 10 }, { month: 3, day: 11 }],
578
+ 2025: [{ month: 2, day: 31 }, { month: 3, day: 1 }],
579
+ 2026: [{ month: 2, day: 21 }, { month: 2, day: 22 }],
580
+ 2027: [{ month: 2, day: 10 }, { month: 2, day: 11 }],
581
+ 2028: [{ month: 2, day: 28 }, { month: 2, day: 29 }],
582
+ 2029: [{ month: 2, day: 17 }, { month: 2, day: 18 }],
583
+ 2030: [{ month: 2, day: 7 }, { month: 2, day: 8 }]
584
+ };
585
+ var EID_AL_ADHA = {
586
+ 2024: { month: 5, day: 17 },
587
+ 2025: { month: 5, day: 7 },
588
+ 2026: { month: 4, day: 27 },
589
+ 2027: { month: 4, day: 17 },
590
+ 2028: { month: 5, day: 5 },
591
+ 2029: { month: 4, day: 25 },
592
+ 2030: { month: 4, day: 15 }
593
+ };
594
+ var ISLAMIC_NEW_YEAR = {
595
+ 2024: { month: 6, day: 7 },
596
+ 2025: { month: 5, day: 27 },
597
+ 2026: { month: 5, day: 16 },
598
+ 2027: { month: 5, day: 6 },
599
+ 2028: { month: 6, day: 24 },
600
+ 2029: { month: 6, day: 13 },
601
+ 2030: { month: 6, day: 3 }
602
+ };
603
+ var PROPHETS_BIRTHDAY = {
604
+ 2024: { month: 8, day: 16 },
605
+ 2025: { month: 8, day: 5 },
606
+ 2026: { month: 7, day: 26 },
607
+ 2027: { month: 7, day: 16 },
608
+ 2028: { month: 8, day: 3 },
609
+ 2029: { month: 7, day: 23 },
610
+ 2030: { month: 7, day: 13 }
611
+ };
612
+ var ISRA_MIRAJ = {
613
+ 2024: { month: 1, day: 8 },
614
+ 2025: { month: 0, day: 28 },
615
+ 2026: { month: 0, day: 17 },
616
+ 2027: { month: 0, day: 6 },
617
+ 2028: { month: 0, day: 26 },
618
+ 2029: { month: 1, day: 14 },
619
+ 2030: { month: 1, day: 3 }
620
+ };
621
+ function addHolidayEntry(entries, name, month, day) {
622
+ entries.push({ name, month, day });
623
+ }
624
+ function getIndonesianHolidaysForYear(year) {
625
+ const holidays = [...INDONESIAN_FIXED_HOLIDAYS];
626
+ const easter = computeEaster(year);
627
+ addHolidayEntry(holidays, "Good Friday", easter.getMonth(), easter.getDate() - 2);
628
+ addHolidayEntry(holidays, "Easter", easter.getMonth(), easter.getDate());
629
+ const ascension = new Date(easter);
630
+ ascension.setDate(ascension.getDate() + 39);
631
+ addHolidayEntry(holidays, "Ascension of Jesus Christ", ascension.getMonth(), ascension.getDate());
632
+ const cny = CHINESE_NEW_YEAR[year];
633
+ if (cny) addHolidayEntry(holidays, "Chinese New Year", cny.month, cny.day);
634
+ const nyepi = NYEPI[year];
635
+ if (nyepi) addHolidayEntry(holidays, "Nyepi (Day of Silence)", nyepi.month, nyepi.day);
636
+ const vesak = VESAK[year];
637
+ if (vesak) addHolidayEntry(holidays, "Vesak (Buddha's Birthday)", vesak.month, vesak.day);
638
+ const eidDays = EID_AL_FITR[year];
639
+ if (eidDays) {
640
+ eidDays.forEach((entry, idx) => {
641
+ addHolidayEntry(holidays, idx === 0 ? "Eid al-Fitr" : "Eid al-Fitr (Day 2)", entry.month, entry.day);
642
+ });
643
+ }
644
+ const eidAdha = EID_AL_ADHA[year];
645
+ if (eidAdha) addHolidayEntry(holidays, "Eid al-Adha", eidAdha.month, eidAdha.day);
646
+ const islNewYear = ISLAMIC_NEW_YEAR[year];
647
+ if (islNewYear) addHolidayEntry(holidays, "Islamic New Year", islNewYear.month, islNewYear.day);
648
+ const prophetBday = PROPHETS_BIRTHDAY[year];
649
+ if (prophetBday) addHolidayEntry(holidays, "Prophet Muhammad's Birthday", prophetBday.month, prophetBday.day);
650
+ const isra = ISRA_MIRAJ[year];
651
+ if (isra) addHolidayEntry(holidays, "Isra' Mi'raj (Ascension of Prophet Muhammad)", isra.month, isra.day);
652
+ return holidays;
653
+ }
654
+ function isHolidayIndonesia(date) {
655
+ if (!isValidDate(date)) throw new InvalidDateError(date);
656
+ const year = date.getFullYear();
657
+ const holidays = getIndonesianHolidaysForYear(year);
658
+ for (const h of holidays) {
659
+ if (h.month === date.getMonth() && h.day === date.getDate()) {
660
+ return true;
661
+ }
662
+ }
663
+ return false;
664
+ }
665
+ function getIndonesianHolidayNames(date) {
666
+ if (!isValidDate(date)) throw new InvalidDateError(date);
667
+ const year = date.getFullYear();
668
+ const holidays = getIndonesianHolidaysForYear(year);
669
+ const names = [];
670
+ for (const h of holidays) {
671
+ if (h.month === date.getMonth() && h.day === date.getDate()) {
672
+ names.push(h.name);
673
+ }
674
+ }
675
+ return names;
676
+ }
368
677
  export {
369
678
  InvalidDateError,
370
679
  TIMEZONE_WIB,
@@ -376,24 +685,53 @@ export {
376
685
  addYears,
377
686
  calculateAge,
378
687
  dateDiff,
688
+ dayOfYear,
689
+ daysInMonth,
379
690
  endOfDay,
380
691
  endOfMonth,
381
692
  endOfYear,
382
693
  formatDate,
383
694
  formatDuration,
384
695
  formatInTimezone,
696
+ getIndonesianHolidayNames,
385
697
  isAfter,
386
698
  isBefore,
387
699
  isBetween,
388
700
  isBusinessDay,
701
+ isFuture,
702
+ isHolidayIndonesia,
389
703
  isLeapYear,
704
+ isPast,
705
+ isSameDay,
706
+ isToday,
707
+ isTomorrow,
390
708
  isWeekend,
709
+ isYesterday,
710
+ lastFriday,
711
+ lastMonday,
712
+ lastSaturday,
713
+ lastSunday,
714
+ lastThursday,
715
+ lastTuesday,
716
+ lastWednesday,
717
+ maxDate,
718
+ minDate,
719
+ nextFriday,
720
+ nextMonday,
721
+ nextSaturday,
722
+ nextSunday,
723
+ nextThursday,
724
+ nextTuesday,
725
+ nextWednesday,
391
726
  parseDate,
727
+ parseDuration,
728
+ quarter,
392
729
  startOfDay,
393
730
  startOfMonth,
394
731
  startOfYear,
395
732
  timeAgo,
396
733
  timeRemaining,
397
- toTimezone
734
+ toTimezone,
735
+ weekOfYear
398
736
  };
399
737
  //# sourceMappingURL=index.js.map