@intech-software/chronera 0.1.5 → 0.1.7

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/dist/index.d.ts CHANGED
@@ -3,10 +3,12 @@ export { compareInstants, compareLocalDates, sameAbsoluteDate, sameCalendarDate,
3
3
  export { getAbsoluteDay, isBefore, isAfter, isEqual, isSameDay, isBetween, isToday, addDays, subtractDays, addMonths, subtractMonths, addYears, subtractYears, diffInDays, startOfMonth, endOfMonth, startOfYear, endOfYear, } from "./operations/convenience.js";
4
4
  export { startOfDay, endOfDay, isPast, isFuture, addHours, subtractHours, addMinutes, subtractMinutes, addSeconds, subtractSeconds, } from "./operations/time-convenience.js";
5
5
  export { isWeekend, isWeekday, isBusinessDay, addBusinessDays, subtractBusinessDays, diffInBusinessDays, } from "./operations/business-days.js";
6
+ export { isBusinessHour, addBusinessHours, subtractBusinessHours, diffInBusinessHours, nextBusinessShift, startOfBusinessDay, endOfBusinessDay, } from "./operations/business-hours.js";
6
7
  export { isPublicHoliday, getPublicHolidays, getHolidayDetails, } from "./operations/holidays.js";
7
8
  export { registerHolidayCalendar, getHolidayCalendar, resolveAnnualHolidays, calculateEasterSunday, calculateGoodFriday, calculateEasterMonday, calculateAscensionDay, calculateWhitMonday, BUILT_IN_HOLIDAYS, thailandHolidays, japanHolidays, saudiArabiaHolidays, uaeHolidays, iranHolidays, taiwanHolidays, indiaHolidays, singaporeHolidays, unitedStatesHolidays, unitedKingdomHolidays, germanyHolidays, franceHolidays, australiaHolidays, chinaHolidays, hongKongHolidays, } from "./holidays/index.js";
8
9
  export type { CountryCode, PublicHoliday, HolidayCalendar, HolidayRule, HolidayOptions, ObservedRollRule, } from "./holidays/types.js";
9
10
  export type { BusinessDaysOptions } from "./operations/business-days.js";
11
+ export type { ShiftWindow, BusinessSchedule, NormalizedShift, BusinessTimeInput, NextBusinessShiftOptions, NextBusinessShiftResult, } from "./operations/business-hours.js";
10
12
  export { formatInTimeZone, getTimeZoneOffset, isSameTimeZone, } from "./operations/timezone.js";
11
13
  export { convertCalendarDate } from "./operations/convert-calendar-date.js";
12
14
  export { daysInMonth, getCalendarCapabilities, isLeapYear, isValidCalendarDate, } from "./operations/validate.js";
@@ -24,4 +26,8 @@ export { localTime } from "./core/local-time.js";
24
26
  export { localDateTime } from "./core/local-date-time.js";
25
27
  export { dateRange } from "./core/range.js";
26
28
  export { ChroneraError, ChroneraParseError, ChroneraRangeError, ChroneraUnsupportedError, } from "./errors/index.js";
29
+ export { rangeContains, rangeOverlaps, rangeIntersection, rangeUnion, rangeLengthInDays, eachDayOfInterval, eachWeekOfInterval, eachMonthOfInterval, splitByDay, splitByWeek, splitByMonth, } from "./operations/interval.js";
30
+ export { parseDuration, durationToISO, durationToHuman, addDuration, subtractDuration, diffAsDuration, addDurations, scaleDuration, durationTotalDays, } from "./operations/duration-ops.js";
31
+ export { recur, getOccurrences, isOccurrence, } from "./operations/recurrence.js";
32
+ export type { RecurrenceFrequency, DayOfWeek, RecurrenceRule, RecurrenceBuilder, FrequencySelector, RecurrenceRuleBuilder, } from "./operations/recurrence.js";
27
33
  export type { BuiltInCalendarId, CalendarPlugin, CalendarCapabilities, CalendarConversionMetadata, CalendarConversionResult, CalendarDate, CalendarId, ChroneraErrorCode, ChroneraConfig, ChroneraInstance, ChroneraIssue, Comparison, ConvertCalendarOptions, DateOrCalendarDate, DateRange, DayOfYearFields, Duration, EraId, FiscalFields, FiscalOptions, FormatDateBaseOptions, FormatDateInput, FormatDateOptions, FormatDateRangeOptions, FormatDateTimeOptions, FormatInTimeZoneOptions, FormatRelativeOptions, FormatTimeOptions, Instant, IntervalInclusivity, IsoWeekFields, LocalDate, LocalDateTime, LocalTime, LocaleId, MonthCode, NumberingSystemId, PatternFormatOptions, ParseInstantOptions, ParseLocalDateOptions, PresetName, QuarterNumber, ResolvedChroneraOptions, Rfc2822Options, RuntimeCapabilities, SafeParseResult, SameTimeZoneOptions, TimeZoneId, TimeZoneOffsetFormat, TimeZoneOffsetInfo, TimeOrDateTimeOrInstant, ZonedDateTime, } from "./public-types.js";
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ export { compareInstants, compareLocalDates, sameAbsoluteDate, sameCalendarDate,
3
3
  export { getAbsoluteDay, isBefore, isAfter, isEqual, isSameDay, isBetween, isToday, addDays, subtractDays, addMonths, subtractMonths, addYears, subtractYears, diffInDays, startOfMonth, endOfMonth, startOfYear, endOfYear, } from "./operations/convenience.js";
4
4
  export { startOfDay, endOfDay, isPast, isFuture, addHours, subtractHours, addMinutes, subtractMinutes, addSeconds, subtractSeconds, } from "./operations/time-convenience.js";
5
5
  export { isWeekend, isWeekday, isBusinessDay, addBusinessDays, subtractBusinessDays, diffInBusinessDays, } from "./operations/business-days.js";
6
+ export { isBusinessHour, addBusinessHours, subtractBusinessHours, diffInBusinessHours, nextBusinessShift, startOfBusinessDay, endOfBusinessDay, } from "./operations/business-hours.js";
6
7
  export { isPublicHoliday, getPublicHolidays, getHolidayDetails, } from "./operations/holidays.js";
7
8
  export { registerHolidayCalendar, getHolidayCalendar, resolveAnnualHolidays, calculateEasterSunday, calculateGoodFriday, calculateEasterMonday, calculateAscensionDay, calculateWhitMonday, BUILT_IN_HOLIDAYS, thailandHolidays, japanHolidays, saudiArabiaHolidays, uaeHolidays, iranHolidays, taiwanHolidays, indiaHolidays, singaporeHolidays, unitedStatesHolidays, unitedKingdomHolidays, germanyHolidays, franceHolidays, australiaHolidays, chinaHolidays, hongKongHolidays, } from "./holidays/index.js";
8
9
  export { formatInTimeZone, getTimeZoneOffset, isSameTimeZone, } from "./operations/timezone.js";
@@ -22,4 +23,7 @@ export { localTime } from "./core/local-time.js";
22
23
  export { localDateTime } from "./core/local-date-time.js";
23
24
  export { dateRange } from "./core/range.js";
24
25
  export { ChroneraError, ChroneraParseError, ChroneraRangeError, ChroneraUnsupportedError, } from "./errors/index.js";
26
+ export { rangeContains, rangeOverlaps, rangeIntersection, rangeUnion, rangeLengthInDays, eachDayOfInterval, eachWeekOfInterval, eachMonthOfInterval, splitByDay, splitByWeek, splitByMonth, } from "./operations/interval.js";
27
+ export { parseDuration, durationToISO, durationToHuman, addDuration, subtractDuration, diffAsDuration, addDurations, scaleDuration, durationTotalDays, } from "./operations/duration-ops.js";
28
+ export { recur, getOccurrences, isOccurrence, } from "./operations/recurrence.js";
25
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,cAAc,EACd,QAAQ,EACR,OAAO,EACP,OAAO,EACP,SAAS,EACT,SAAS,EACT,OAAO,EACP,OAAO,EACP,YAAY,EACZ,SAAS,EACT,cAAc,EACd,QAAQ,EACR,aAAa,EACb,UAAU,EACV,YAAY,EACZ,UAAU,EACV,WAAW,EACX,SAAS,GACV,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,UAAU,EACV,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,UAAU,EACV,eAAe,EACf,UAAU,EACV,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,SAAS,EACT,SAAS,EACT,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,E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AC;AAE3B,OAAO,EACL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,eAAe,EACf,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC","sourcesContent":["export { createChronera } from \"./create-chronera.js\";\n\nexport {\n compareInstants,\n compareLocalDates,\n sameAbsoluteDate,\n sameCalendarDate,\n} from \"./operations/compare.js\";\n\nexport {\n getAbsoluteDay,\n isBefore,\n isAfter,\n isEqual,\n isSameDay,\n isBetween,\n isToday,\n addDays,\n subtractDays,\n addMonths,\n subtractMonths,\n addYears,\n subtractYears,\n diffInDays,\n startOfMonth,\n endOfMonth,\n startOfYear,\n endOfYear,\n} from \"./operations/convenience.js\";\n\nexport {\n startOfDay,\n endOfDay,\n isPast,\n isFuture,\n addHours,\n subtractHours,\n addMinutes,\n subtractMinutes,\n addSeconds,\n subtractSeconds,\n} from \"./operations/time-convenience.js\";\n\nexport {\n isWeekend,\n isWeekday,\n isBusinessDay,\n addBusinessDays,\n subtractBusinessDays,\n diffInBusinessDays,\n} from \"./operations/business-days.js\";\n\nexport {\n isPublicHoliday,\n getPublicHolidays,\n getHolidayDetails,\n} from \"./operations/holidays.js\";\n\nexport {\n registerHolidayCalendar,\n getHolidayCalendar,\n resolveAnnualHolidays,\n calculateEasterSunday,\n calculateGoodFriday,\n calculateEasterMonday,\n calculateAscensionDay,\n calculateWhitMonday,\n BUILT_IN_HOLIDAYS,\n thailandHolidays,\n japanHolidays,\n saudiArabiaHolidays,\n uaeHolidays,\n iranHolidays,\n taiwanHolidays,\n indiaHolidays,\n singaporeHolidays,\n unitedStatesHolidays,\n unitedKingdomHolidays,\n germanyHolidays,\n franceHolidays,\n australiaHolidays,\n chinaHolidays,\n hongKongHolidays,\n} from \"./holidays/index.js\";\n\nexport type {\n CountryCode,\n PublicHoliday,\n HolidayCalendar,\n HolidayRule,\n HolidayOptions,\n ObservedRollRule,\n} from \"./holidays/types.js\";\n\nexport type { BusinessDaysOptions } from \"./operations/business-days.js\";\n\nexport {\n formatInTimeZone,\n getTimeZoneOffset,\n isSameTimeZone,\n} from \"./operations/timezone.js\";\n\nexport { convertCalendarDate } from \"./operations/convert-calendar-date.js\";\n\nexport {\n daysInMonth,\n getCalendarCapabilities,\n isLeapYear,\n isValidCalendarDate,\n} from \"./operations/validate.js\";\n\nexport { getIsoWeek, formatIsoWeek } from \"./operations/iso-week.js\";\n\nexport {\n getDayOfYear,\n getDayOfYearWithRegistry,\n formatOrdinalDate,\n} from \"./operations/day-of-year.js\";\n\nexport {\n toJulianDayNumber,\n toModifiedJulianDay,\n localDateFromJulianDayNumber,\n localDateFromModifiedJulianDay,\n} from \"./operations/julian-day.js\";\n\nexport { getQuarter, getFiscalYear } from \"./operations/fiscal.js\";\n\nexport {\n formatDate,\n formatDateRange,\n formatDateTime,\n formatRelative,\n formatTime,\n formatWithPattern,\n formatRfc2822,\n formatJapaneseOfficialPreset,\n formatJapaneseOfficialWithWeekdayPreset,\n formatTaiwanOfficialPreset,\n formatThaiOfficialPreset,\n formatArabicGregorianPreset,\n formatArabicHijriPreset,\n formatChineseShortPreset,\n formatChineseStandardPreset,\n formatChineseWithWeekdayPreset,\n formatFrenchLongPreset,\n formatFrenchStandardPreset,\n formatFrenchWithWeekdayPreset,\n formatGermanDinStandardPreset,\n formatGermanLongPreset,\n formatGermanWithWeekdayPreset,\n formatJapaneseEraShortPreset,\n formatJapaneseSeirekiPreset,\n formatSpanishLongPreset,\n formatSpanishStandardPreset,\n formatSpanishWithWeekdayPreset,\n formatThaiShortDatePreset,\n formatThaiSlashDatePreset,\n formatUkLongPreset,\n formatUkStandardPreset,\n formatUkWithWeekdayPreset,\n formatUsLongPreset,\n formatUsStandardPreset,\n formatUsWithWeekdayPreset,\n} from \"./format/index.js\";\n\nexport {\n parseInstant,\n parseLocalDate,\n safeParseInstant,\n safeParseLocalDate,\n} from \"./parse/index.js\";\n\nexport {\n instantFromDate,\n instantFromEpochMilliseconds,\n instantFromEpochSeconds,\n} from \"./core/instant.js\";\n\nexport { getRuntimeCapabilities } from \"./runtime/capabilities.js\";\n\nexport { calendarDate } from \"./core/calendar-date.js\";\n\nexport { localDate, createLocalDate } from \"./core/local-date.js\";\n\nexport { localTime } from \"./core/local-time.js\";\n\nexport { localDateTime } from \"./core/local-date-time.js\";\n\nexport { dateRange } from \"./core/range.js\";\n\nexport {\n ChroneraError,\n ChroneraParseError,\n ChroneraRangeError,\n ChroneraUnsupportedError,\n} from \"./errors/index.js\";\n\nexport type {\n BuiltInCalendarId,\n CalendarPlugin,\n CalendarCapabilities,\n CalendarConversionMetadata,\n CalendarConversionResult,\n CalendarDate,\n CalendarId,\n ChroneraErrorCode,\n ChroneraConfig,\n ChroneraInstance,\n ChroneraIssue,\n Comparison,\n ConvertCalendarOptions,\n DateOrCalendarDate,\n DateRange,\n DayOfYearFields,\n Duration,\n EraId,\n FiscalFields,\n FiscalOptions,\n FormatDateBaseOptions,\n FormatDateInput,\n FormatDateOptions,\n FormatDateRangeOptions,\n FormatDateTimeOptions,\n FormatInTimeZoneOptions,\n FormatRelativeOptions,\n FormatTimeOptions,\n Instant,\n IntervalInclusivity,\n IsoWeekFields,\n LocalDate,\n LocalDateTime,\n LocalTime,\n LocaleId,\n MonthCode,\n NumberingSystemId,\n PatternFormatOptions,\n ParseInstantOptions,\n ParseLocalDateOptions,\n PresetName,\n QuarterNumber,\n ResolvedChroneraOptions,\n Rfc2822Options,\n RuntimeCapabilities,\n SafeParseResult,\n SameTimeZoneOptions,\n TimeZoneId,\n TimeZoneOffsetFormat,\n TimeZoneOffsetInfo,\n TimeOrDateTimeOrInstant,\n ZonedDateTime,\n} from \"./public-types.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,cAAc,EACd,QAAQ,EACR,OAAO,EACP,OAAO,EACP,SAAS,EACT,SAAS,EACT,OAAO,EACP,OAAO,EACP,YAAY,EACZ,SAAS,EACT,cAAc,EACd,QAAQ,EACR,aAAa,EACb,UAAU,EACV,YAAY,EACZ,UAAU,EACV,WAAW,EACX,SAAS,GACV,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,UAAU,EACV,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,UAAU,EACV,eAAe,EACf,UAAU,EACV,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,SAAS,EACT,SAAS,EACT,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACr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EACzB,yBAAyB,EACzB,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,EACzB,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,eAAe,EACf,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,YAAY,GACb,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,KAAK,EACL,cAAc,EACd,YAAY,GACb,MAAM,4BAA4B,CAAC","sourcesContent":["export { createChronera } from \"./create-chronera.js\";\n\nexport {\n compareInstants,\n compareLocalDates,\n sameAbsoluteDate,\n sameCalendarDate,\n} from \"./operations/compare.js\";\n\nexport {\n getAbsoluteDay,\n isBefore,\n isAfter,\n isEqual,\n isSameDay,\n isBetween,\n isToday,\n addDays,\n subtractDays,\n addMonths,\n subtractMonths,\n addYears,\n subtractYears,\n diffInDays,\n startOfMonth,\n endOfMonth,\n startOfYear,\n endOfYear,\n} from \"./operations/convenience.js\";\n\nexport {\n startOfDay,\n endOfDay,\n isPast,\n isFuture,\n addHours,\n subtractHours,\n addMinutes,\n subtractMinutes,\n addSeconds,\n subtractSeconds,\n} from \"./operations/time-convenience.js\";\n\nexport {\n isWeekend,\n isWeekday,\n isBusinessDay,\n addBusinessDays,\n subtractBusinessDays,\n diffInBusinessDays,\n} from \"./operations/business-days.js\";\n\nexport {\n isBusinessHour,\n addBusinessHours,\n subtractBusinessHours,\n diffInBusinessHours,\n nextBusinessShift,\n startOfBusinessDay,\n endOfBusinessDay,\n} from \"./operations/business-hours.js\";\n\nexport {\n isPublicHoliday,\n getPublicHolidays,\n getHolidayDetails,\n} from \"./operations/holidays.js\";\n\nexport {\n registerHolidayCalendar,\n getHolidayCalendar,\n resolveAnnualHolidays,\n calculateEasterSunday,\n calculateGoodFriday,\n calculateEasterMonday,\n calculateAscensionDay,\n calculateWhitMonday,\n BUILT_IN_HOLIDAYS,\n thailandHolidays,\n japanHolidays,\n saudiArabiaHolidays,\n uaeHolidays,\n iranHolidays,\n taiwanHolidays,\n indiaHolidays,\n singaporeHolidays,\n unitedStatesHolidays,\n unitedKingdomHolidays,\n germanyHolidays,\n franceHolidays,\n australiaHolidays,\n chinaHolidays,\n hongKongHolidays,\n} from \"./holidays/index.js\";\n\nexport type {\n CountryCode,\n PublicHoliday,\n HolidayCalendar,\n HolidayRule,\n HolidayOptions,\n ObservedRollRule,\n} from \"./holidays/types.js\";\n\nexport type { BusinessDaysOptions } from \"./operations/business-days.js\";\nexport type {\n ShiftWindow,\n BusinessSchedule,\n NormalizedShift,\n BusinessTimeInput,\n NextBusinessShiftOptions,\n NextBusinessShiftResult,\n} from \"./operations/business-hours.js\";\n\nexport {\n formatInTimeZone,\n getTimeZoneOffset,\n isSameTimeZone,\n} from \"./operations/timezone.js\";\n\nexport { convertCalendarDate } from \"./operations/convert-calendar-date.js\";\n\nexport {\n daysInMonth,\n getCalendarCapabilities,\n isLeapYear,\n isValidCalendarDate,\n} from \"./operations/validate.js\";\n\nexport { getIsoWeek, formatIsoWeek } from \"./operations/iso-week.js\";\n\nexport {\n getDayOfYear,\n getDayOfYearWithRegistry,\n formatOrdinalDate,\n} from \"./operations/day-of-year.js\";\n\nexport {\n toJulianDayNumber,\n toModifiedJulianDay,\n localDateFromJulianDayNumber,\n localDateFromModifiedJulianDay,\n} from \"./operations/julian-day.js\";\n\nexport { getQuarter, getFiscalYear } from \"./operations/fiscal.js\";\n\nexport {\n formatDate,\n formatDateRange,\n formatDateTime,\n formatRelative,\n formatTime,\n formatWithPattern,\n formatRfc2822,\n formatJapaneseOfficialPreset,\n formatJapaneseOfficialWithWeekdayPreset,\n formatTaiwanOfficialPreset,\n formatThaiOfficialPreset,\n formatArabicGregorianPreset,\n formatArabicHijriPreset,\n formatChineseShortPreset,\n formatChineseStandardPreset,\n formatChineseWithWeekdayPreset,\n formatFrenchLongPreset,\n formatFrenchStandardPreset,\n formatFrenchWithWeekdayPreset,\n formatGermanDinStandardPreset,\n formatGermanLongPreset,\n formatGermanWithWeekdayPreset,\n formatJapaneseEraShortPreset,\n formatJapaneseSeirekiPreset,\n formatSpanishLongPreset,\n formatSpanishStandardPreset,\n formatSpanishWithWeekdayPreset,\n formatThaiShortDatePreset,\n formatThaiSlashDatePreset,\n formatUkLongPreset,\n formatUkStandardPreset,\n formatUkWithWeekdayPreset,\n formatUsLongPreset,\n formatUsStandardPreset,\n formatUsWithWeekdayPreset,\n} from \"./format/index.js\";\n\nexport {\n parseInstant,\n parseLocalDate,\n safeParseInstant,\n safeParseLocalDate,\n} from \"./parse/index.js\";\n\nexport {\n instantFromDate,\n instantFromEpochMilliseconds,\n instantFromEpochSeconds,\n} from \"./core/instant.js\";\n\nexport { getRuntimeCapabilities } from \"./runtime/capabilities.js\";\n\nexport { calendarDate } from \"./core/calendar-date.js\";\n\nexport { localDate, createLocalDate } from \"./core/local-date.js\";\n\nexport { localTime } from \"./core/local-time.js\";\n\nexport { localDateTime } from \"./core/local-date-time.js\";\n\nexport { dateRange } from \"./core/range.js\";\n\nexport {\n ChroneraError,\n ChroneraParseError,\n ChroneraRangeError,\n ChroneraUnsupportedError,\n} from \"./errors/index.js\";\n\nexport {\n rangeContains,\n rangeOverlaps,\n rangeIntersection,\n rangeUnion,\n rangeLengthInDays,\n eachDayOfInterval,\n eachWeekOfInterval,\n eachMonthOfInterval,\n splitByDay,\n splitByWeek,\n splitByMonth,\n} from \"./operations/interval.js\";\n\nexport {\n parseDuration,\n durationToISO,\n durationToHuman,\n addDuration,\n subtractDuration,\n diffAsDuration,\n addDurations,\n scaleDuration,\n durationTotalDays,\n} from \"./operations/duration-ops.js\";\n\nexport {\n recur,\n getOccurrences,\n isOccurrence,\n} from \"./operations/recurrence.js\";\n\nexport type {\n RecurrenceFrequency,\n DayOfWeek,\n RecurrenceRule,\n RecurrenceBuilder,\n FrequencySelector,\n RecurrenceRuleBuilder,\n} from \"./operations/recurrence.js\";\n\nexport type {\n BuiltInCalendarId,\n CalendarPlugin,\n CalendarCapabilities,\n CalendarConversionMetadata,\n CalendarConversionResult,\n CalendarDate,\n CalendarId,\n ChroneraErrorCode,\n ChroneraConfig,\n ChroneraInstance,\n ChroneraIssue,\n Comparison,\n ConvertCalendarOptions,\n DateOrCalendarDate,\n DateRange,\n DayOfYearFields,\n Duration,\n EraId,\n FiscalFields,\n FiscalOptions,\n FormatDateBaseOptions,\n FormatDateInput,\n FormatDateOptions,\n FormatDateRangeOptions,\n FormatDateTimeOptions,\n FormatInTimeZoneOptions,\n FormatRelativeOptions,\n FormatTimeOptions,\n Instant,\n IntervalInclusivity,\n IsoWeekFields,\n LocalDate,\n LocalDateTime,\n LocalTime,\n LocaleId,\n MonthCode,\n NumberingSystemId,\n PatternFormatOptions,\n ParseInstantOptions,\n ParseLocalDateOptions,\n PresetName,\n QuarterNumber,\n ResolvedChroneraOptions,\n Rfc2822Options,\n RuntimeCapabilities,\n SafeParseResult,\n SameTimeZoneOptions,\n TimeZoneId,\n TimeZoneOffsetFormat,\n TimeZoneOffsetInfo,\n TimeOrDateTimeOrInstant,\n ZonedDateTime,\n} from \"./public-types.js\";\n"]}
@@ -0,0 +1,60 @@
1
+ import type { DateOrCalendarDate, LocalDate } from "../public-types.js";
2
+ export interface AgeResult {
3
+ readonly years: number;
4
+ readonly months: number;
5
+ readonly days: number;
6
+ readonly totalDays: number;
7
+ }
8
+ /**
9
+ * Calculates the age between a birth date and a reference date (default: today).
10
+ * Returns { years, months, days, totalDays }.
11
+ *
12
+ * @example
13
+ * calculateAge(localDate(2000, 1, 15)) // → { years: 26, months: 7, days: 27, totalDays: 9736 }
14
+ */
15
+ export declare function calculateAge(birthDate: DateOrCalendarDate, asOf?: DateOrCalendarDate): AgeResult;
16
+ /**
17
+ * Returns the next birthday after the reference date (exclusive).
18
+ *
19
+ * @example
20
+ * nextBirthday(localDate(1990, 6, 15)) // → upcoming June 15
21
+ */
22
+ export declare function nextBirthday(birthDate: DateOrCalendarDate, asOf?: DateOrCalendarDate): LocalDate;
23
+ /**
24
+ * Returns number of days until the next birthday (0 = today).
25
+ */
26
+ export declare function daysUntilBirthday(birthDate: DateOrCalendarDate, asOf?: DateOrCalendarDate): number;
27
+ /**
28
+ * Returns whether today (or asOf date) is the birthday.
29
+ */
30
+ export declare function isBirthday(birthDate: DateOrCalendarDate, asOf?: DateOrCalendarDate): boolean;
31
+ /**
32
+ * Returns true if the age is a milestone (1, 5, 10, 18, 21, 25, 30, ...).
33
+ */
34
+ export declare function isMilestoneAge(birthDate: DateOrCalendarDate, milestones: number[], asOf?: DateOrCalendarDate): boolean;
35
+ export interface CountdownResult {
36
+ readonly days: number;
37
+ readonly hours: number;
38
+ readonly minutes: number;
39
+ readonly seconds: number;
40
+ readonly totalMilliseconds: number;
41
+ readonly isPast: boolean;
42
+ }
43
+ /**
44
+ * Returns the countdown from now to a future date.
45
+ * For dates in the past, isPast = true and all values are 0.
46
+ *
47
+ * @example
48
+ * countdown(localDate(2026, 12, 31)) // → { days: 111, hours: 0, minutes: 0, seconds: 0, ... }
49
+ */
50
+ export declare function countdown(targetDate: DateOrCalendarDate, fromDate?: DateOrCalendarDate): CountdownResult;
51
+ /**
52
+ * Time elapsed from a past date to now (in days, months, years).
53
+ */
54
+ export interface ElapsedResult {
55
+ readonly years: number;
56
+ readonly months: number;
57
+ readonly days: number;
58
+ readonly totalDays: number;
59
+ }
60
+ export declare function timeElapsed(pastDate: DateOrCalendarDate, asOf?: DateOrCalendarDate): ElapsedResult;
@@ -0,0 +1,199 @@
1
+ import { absoluteDayFromGregorianFields, gregorianFieldsFromAbsoluteDay, } from "../core/absolute-day.js";
2
+ import { daysInGregorianMonth } from "../core/gregorian-math.js";
3
+ import { addMonths, addYears, getAbsoluteDay } from "./convenience.js";
4
+ function toLocalDate(date) {
5
+ if (date.kind === "local-date")
6
+ return date;
7
+ // For CalendarDate, use absolute day to convert back to Gregorian LocalDate
8
+ const abs = getAbsoluteDay(date);
9
+ const f = gregorianFieldsFromAbsoluteDay(abs);
10
+ return { kind: "local-date", year: f.year, month: f.month, day: f.day };
11
+ }
12
+ /**
13
+ * Calculates the age between a birth date and a reference date (default: today).
14
+ * Returns { years, months, days, totalDays }.
15
+ *
16
+ * @example
17
+ * calculateAge(localDate(2000, 1, 15)) // → { years: 26, months: 7, days: 27, totalDays: 9736 }
18
+ */
19
+ export function calculateAge(birthDate, asOf) {
20
+ const birth = toLocalDate(birthDate);
21
+ const ref = asOf
22
+ ? toLocalDate(asOf)
23
+ : (() => {
24
+ const now = new Date();
25
+ return {
26
+ kind: "local-date",
27
+ year: now.getFullYear(),
28
+ month: now.getMonth() + 1,
29
+ day: now.getDate(),
30
+ };
31
+ })();
32
+ const birthAbs = absoluteDayFromGregorianFields(birth.year, birth.month, birth.day);
33
+ const refAbs = absoluteDayFromGregorianFields(ref.year, ref.month, ref.day);
34
+ const totalDays = Math.max(0, refAbs - birthAbs);
35
+ // Compute years
36
+ let years = ref.year - birth.year;
37
+ // Check if birthday hasn't occurred this year yet
38
+ const hadBirthdayThisYear = ref.month > birth.month ||
39
+ (ref.month === birth.month && ref.day >= birth.day);
40
+ if (!hadBirthdayThisYear)
41
+ years--;
42
+ // Compute remaining months
43
+ const afterYears = addYears({ ...birth, kind: "local-date" }, years, "constrain");
44
+ let months = 0;
45
+ let cursor = afterYears;
46
+ while (true) {
47
+ const next = addMonths(cursor, 1, "constrain");
48
+ const nextAbs = absoluteDayFromGregorianFields(next.year, next.month, next.day);
49
+ if (nextAbs > refAbs)
50
+ break;
51
+ months++;
52
+ cursor = next;
53
+ }
54
+ // Remaining days
55
+ const cursorAbs = absoluteDayFromGregorianFields(cursor.year, cursor.month, cursor.day);
56
+ const days = refAbs - cursorAbs;
57
+ return { years, months, days, totalDays };
58
+ }
59
+ /**
60
+ * Returns the next birthday after the reference date (exclusive).
61
+ *
62
+ * @example
63
+ * nextBirthday(localDate(1990, 6, 15)) // → upcoming June 15
64
+ */
65
+ export function nextBirthday(birthDate, asOf) {
66
+ const birth = toLocalDate(birthDate);
67
+ const ref = asOf
68
+ ? toLocalDate(asOf)
69
+ : (() => {
70
+ const now = new Date();
71
+ return {
72
+ kind: "local-date",
73
+ year: now.getFullYear(),
74
+ month: now.getMonth() + 1,
75
+ day: now.getDate(),
76
+ };
77
+ })();
78
+ // Try this year's birthday
79
+ const maxDay = daysInGregorianMonth(ref.year, birth.month);
80
+ const birthdayDay = Math.min(birth.day, maxDay);
81
+ const thisYear = {
82
+ kind: "local-date",
83
+ year: ref.year,
84
+ month: birth.month,
85
+ day: birthdayDay,
86
+ };
87
+ const thisYearAbs = absoluteDayFromGregorianFields(thisYear.year, thisYear.month, thisYear.day);
88
+ const refAbs = absoluteDayFromGregorianFields(ref.year, ref.month, ref.day);
89
+ if (thisYearAbs > refAbs)
90
+ return thisYear;
91
+ // Next year's birthday
92
+ const nextYear = ref.year + 1;
93
+ const maxDayNext = daysInGregorianMonth(nextYear, birth.month);
94
+ return {
95
+ kind: "local-date",
96
+ year: nextYear,
97
+ month: birth.month,
98
+ day: Math.min(birth.day, maxDayNext),
99
+ };
100
+ }
101
+ /**
102
+ * Returns number of days until the next birthday (0 = today).
103
+ */
104
+ export function daysUntilBirthday(birthDate, asOf) {
105
+ const ref = asOf
106
+ ? toLocalDate(asOf)
107
+ : (() => {
108
+ const now = new Date();
109
+ return {
110
+ kind: "local-date",
111
+ year: now.getFullYear(),
112
+ month: now.getMonth() + 1,
113
+ day: now.getDate(),
114
+ };
115
+ })();
116
+ const next = nextBirthday(birthDate, ref);
117
+ const refAbs = absoluteDayFromGregorianFields(ref.year, ref.month, ref.day);
118
+ const nextAbs = absoluteDayFromGregorianFields(next.year, next.month, next.day);
119
+ return nextAbs - refAbs;
120
+ }
121
+ /**
122
+ * Returns whether today (or asOf date) is the birthday.
123
+ */
124
+ export function isBirthday(birthDate, asOf) {
125
+ const birth = toLocalDate(birthDate);
126
+ const ref = asOf
127
+ ? toLocalDate(asOf)
128
+ : (() => {
129
+ const now = new Date();
130
+ return {
131
+ kind: "local-date",
132
+ year: now.getFullYear(),
133
+ month: now.getMonth() + 1,
134
+ day: now.getDate(),
135
+ };
136
+ })();
137
+ const maxDay = daysInGregorianMonth(ref.year, birth.month);
138
+ return ref.month === birth.month && ref.day === Math.min(birth.day, maxDay);
139
+ }
140
+ /**
141
+ * Returns true if the age is a milestone (1, 5, 10, 18, 21, 25, 30, ...).
142
+ */
143
+ export function isMilestoneAge(birthDate, milestones, asOf) {
144
+ const age = calculateAge(birthDate, asOf);
145
+ return milestones.includes(age.years);
146
+ }
147
+ /**
148
+ * Returns the countdown from now to a future date.
149
+ * For dates in the past, isPast = true and all values are 0.
150
+ *
151
+ * @example
152
+ * countdown(localDate(2026, 12, 31)) // → { days: 111, hours: 0, minutes: 0, seconds: 0, ... }
153
+ */
154
+ export function countdown(targetDate, fromDate) {
155
+ const target = toLocalDate(targetDate);
156
+ const now = fromDate
157
+ ? toLocalDate(fromDate)
158
+ : (() => {
159
+ const d = new Date();
160
+ return {
161
+ kind: "local-date",
162
+ year: d.getFullYear(),
163
+ month: d.getMonth() + 1,
164
+ day: d.getDate(),
165
+ };
166
+ })();
167
+ const targetAbs = absoluteDayFromGregorianFields(target.year, target.month, target.day);
168
+ const nowAbs = absoluteDayFromGregorianFields(now.year, now.month, now.day);
169
+ const diffDays = targetAbs - nowAbs;
170
+ if (diffDays < 0) {
171
+ return {
172
+ days: 0,
173
+ hours: 0,
174
+ minutes: 0,
175
+ seconds: 0,
176
+ totalMilliseconds: 0,
177
+ isPast: true,
178
+ };
179
+ }
180
+ const totalMs = diffDays * 86_400_000;
181
+ return {
182
+ days: diffDays,
183
+ hours: 0,
184
+ minutes: 0,
185
+ seconds: 0,
186
+ totalMilliseconds: totalMs,
187
+ isPast: false,
188
+ };
189
+ }
190
+ export function timeElapsed(pastDate, asOf) {
191
+ const age = calculateAge(pastDate, asOf);
192
+ return {
193
+ years: age.years,
194
+ months: age.months,
195
+ days: age.days,
196
+ totalDays: age.totalDays,
197
+ };
198
+ }
199
+ //# sourceMappingURL=age-countdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"age-countdown.js","sourceRoot":"","sources":["../../src/operations/age-countdown.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,GAC/B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcvE,SAAS,WAAW,CAAC,IAAwB;IAC3C,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,IAAI,CAAC;IAC5C,4EAA4E;IAC5E,MAAM,GAAG,GAAG,cAAc,CAA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AE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5E,MAAM,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;IAEpC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QACjB,OAAO;YACL,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,CAAC;YACR,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,CAAC;YACV,iBAAiB,EAAE,CAAC;YACpB,MAAM,EAAE,IAAI;SACb,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;IACtC,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,iBAAiB,EAAE,OAAO;QAC1B,MAAM,EAAE,KAAK;KACd,CAAC;AACJ,CAAC;AAYD,MAAM,UAAU,WAAW,CACzB,QAA4B,EAC5B,IAAyB;IAEzB,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACzC,OAAO;QACL,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,SAAS,EAAE,GAAG,CAAC,SAAS;KACzB,CAAC;AACJ,CAAC","sourcesContent":["import {\n absoluteDayFromGregorianFields,\n gregorianFieldsFromAbsoluteDay,\n} from \"../core/absolute-day.js\";\nimport { daysInGregorianMonth } from \"../core/gregorian-math.js\";\nimport { addMonths, addYears, getAbsoluteDay } from \"./convenience.js\";\nimport type { DateOrCalendarDate, LocalDate } from \"../public-types.js\";\n\n// ---------------------------------------------------------------------------\n// Age & Birthday Engine\n// ---------------------------------------------------------------------------\n\nexport interface AgeResult {\n readonly years: number;\n readonly months: number;\n readonly days: number;\n readonly totalDays: number;\n}\n\nfunction toLocalDate(date: DateOrCalendarDate): LocalDate {\n if (date.kind === \"local-date\") return date;\n // For CalendarDate, use absolute day to convert back to Gregorian LocalDate\n const abs = getAbsoluteDay(date);\n const f = gregorianFieldsFromAbsoluteDay(abs);\n return { kind: \"local-date\", year: f.year, month: f.month, day: f.day };\n}\n\n/**\n * Calculates the age between a birth date and a reference date (default: today).\n * Returns { years, months, days, totalDays }.\n *\n * @example\n * calculateAge(localDate(2000, 1, 15)) // → { years: 26, months: 7, days: 27, totalDays: 9736 }\n */\nexport function calculateAge(\n birthDate: DateOrCalendarDate,\n asOf?: DateOrCalendarDate,\n): AgeResult {\n const birth = toLocalDate(birthDate);\n const ref = asOf\n ? toLocalDate(asOf)\n : (() => {\n const now = new Date();\n return {\n kind: \"local-date\" as const,\n year: now.getFullYear(),\n month: now.getMonth() + 1,\n day: now.getDate(),\n };\n })();\n\n const birthAbs = absoluteDayFromGregorianFields(\n birth.year,\n birth.month,\n birth.day,\n );\n const refAbs = absoluteDayFromGregorianFields(ref.year, ref.month, ref.day);\n const totalDays = Math.max(0, refAbs - birthAbs);\n\n // Compute years\n let years = ref.year - birth.year;\n // Check if birthday hasn't occurred this year yet\n const hadBirthdayThisYear =\n ref.month > birth.month ||\n (ref.month === birth.month && ref.day >= birth.day);\n if (!hadBirthdayThisYear) years--;\n\n // Compute remaining months\n const afterYears = addYears(\n { ...birth, kind: \"local-date\" },\n years,\n \"constrain\",\n ) as LocalDate;\n let months = 0;\n let cursor = afterYears;\n while (true) {\n const next = addMonths(cursor, 1, \"constrain\") as LocalDate;\n const nextAbs = absoluteDayFromGregorianFields(\n next.year,\n next.month,\n next.day,\n );\n if (nextAbs > refAbs) break;\n months++;\n cursor = next;\n }\n\n // Remaining days\n const cursorAbs = absoluteDayFromGregorianFields(\n cursor.year,\n cursor.month,\n cursor.day,\n );\n const days = refAbs - cursorAbs;\n\n return { years, months, days, totalDays };\n}\n\n/**\n * Returns the next birthday after the reference date (exclusive).\n *\n * @example\n * nextBirthday(localDate(1990, 6, 15)) // → upcoming June 15\n */\nexport function nextBirthday(\n birthDate: DateOrCalendarDate,\n asOf?: DateOrCalendarDate,\n): LocalDate {\n const birth = toLocalDate(birthDate);\n const ref = asOf\n ? toLocalDate(asOf)\n : (() => {\n const now = new Date();\n return {\n kind: \"local-date\" as const,\n year: now.getFullYear(),\n month: now.getMonth() + 1,\n day: now.getDate(),\n };\n })();\n\n // Try this year's birthday\n const maxDay = daysInGregorianMonth(ref.year, birth.month);\n const birthdayDay = Math.min(birth.day, maxDay);\n const thisYear: LocalDate = {\n kind: \"local-date\",\n year: ref.year,\n month: birth.month,\n day: birthdayDay,\n };\n const thisYearAbs = absoluteDayFromGregorianFields(\n thisYear.year,\n thisYear.month,\n thisYear.day,\n );\n const refAbs = absoluteDayFromGregorianFields(ref.year, ref.month, ref.day);\n\n if (thisYearAbs > refAbs) return thisYear;\n\n // Next year's birthday\n const nextYear = ref.year + 1;\n const maxDayNext = daysInGregorianMonth(nextYear, birth.month);\n return {\n kind: \"local-date\",\n year: nextYear,\n month: birth.month,\n day: Math.min(birth.day, maxDayNext),\n };\n}\n\n/**\n * Returns number of days until the next birthday (0 = today).\n */\nexport function daysUntilBirthday(\n birthDate: DateOrCalendarDate,\n asOf?: DateOrCalendarDate,\n): number {\n const ref = asOf\n ? toLocalDate(asOf)\n : (() => {\n const now = new Date();\n return {\n kind: \"local-date\" as const,\n year: now.getFullYear(),\n month: now.getMonth() + 1,\n day: now.getDate(),\n };\n })();\n\n const next = nextBirthday(birthDate, ref);\n const refAbs = absoluteDayFromGregorianFields(ref.year, ref.month, ref.day);\n const nextAbs = absoluteDayFromGregorianFields(\n next.year,\n next.month,\n next.day,\n );\n return nextAbs - refAbs;\n}\n\n/**\n * Returns whether today (or asOf date) is the birthday.\n */\nexport function isBirthday(\n birthDate: DateOrCalendarDate,\n asOf?: DateOrCalendarDate,\n): boolean {\n const birth = toLocalDate(birthDate);\n const ref = asOf\n ? toLocalDate(asOf)\n : (() => {\n const now = new Date();\n return {\n kind: \"local-date\" as const,\n year: now.getFullYear(),\n month: now.getMonth() + 1,\n day: now.getDate(),\n };\n })();\n\n const maxDay = daysInGregorianMonth(ref.year, birth.month);\n return ref.month === birth.month && ref.day === Math.min(birth.day, maxDay);\n}\n\n/**\n * Returns true if the age is a milestone (1, 5, 10, 18, 21, 25, 30, ...).\n */\nexport function isMilestoneAge(\n birthDate: DateOrCalendarDate,\n milestones: number[],\n asOf?: DateOrCalendarDate,\n): boolean {\n const age = calculateAge(birthDate, asOf);\n return milestones.includes(age.years);\n}\n\n// ---------------------------------------------------------------------------\n// Countdown Engine\n// ---------------------------------------------------------------------------\n\nexport interface CountdownResult {\n readonly days: number;\n readonly hours: number;\n readonly minutes: number;\n readonly seconds: number;\n readonly totalMilliseconds: number;\n readonly isPast: boolean;\n}\n\n/**\n * Returns the countdown from now to a future date.\n * For dates in the past, isPast = true and all values are 0.\n *\n * @example\n * countdown(localDate(2026, 12, 31)) // → { days: 111, hours: 0, minutes: 0, seconds: 0, ... }\n */\nexport function countdown(\n targetDate: DateOrCalendarDate,\n fromDate?: DateOrCalendarDate,\n): CountdownResult {\n const target = toLocalDate(targetDate);\n const now = fromDate\n ? toLocalDate(fromDate)\n : (() => {\n const d = new Date();\n return {\n kind: \"local-date\" as const,\n year: d.getFullYear(),\n month: d.getMonth() + 1,\n day: d.getDate(),\n };\n })();\n\n const targetAbs = absoluteDayFromGregorianFields(\n target.year,\n target.month,\n target.day,\n );\n const nowAbs = absoluteDayFromGregorianFields(now.year, now.month, now.day);\n const diffDays = targetAbs - nowAbs;\n\n if (diffDays < 0) {\n return {\n days: 0,\n hours: 0,\n minutes: 0,\n seconds: 0,\n totalMilliseconds: 0,\n isPast: true,\n };\n }\n\n const totalMs = diffDays * 86_400_000;\n return {\n days: diffDays,\n hours: 0,\n minutes: 0,\n seconds: 0,\n totalMilliseconds: totalMs,\n isPast: false,\n };\n}\n\n/**\n * Time elapsed from a past date to now (in days, months, years).\n */\nexport interface ElapsedResult {\n readonly years: number;\n readonly months: number;\n readonly days: number;\n readonly totalDays: number;\n}\n\nexport function timeElapsed(\n pastDate: DateOrCalendarDate,\n asOf?: DateOrCalendarDate,\n): ElapsedResult {\n const age = calculateAge(pastDate, asOf);\n return {\n years: age.years,\n months: age.months,\n days: age.days,\n totalDays: age.totalDays,\n };\n}\n"]}
@@ -0,0 +1,137 @@
1
+ import type { CountryCode, HolidayCalendar } from "../holidays/types.js";
2
+ import type { BusinessDaysOptions } from "./business-days.js";
3
+ import type { Instant, LocalDate, LocalDateTime, LocalTime, TimeZoneId } from "../public-types.js";
4
+ /**
5
+ * Defines an active working shift window within a day.
6
+ */
7
+ export interface ShiftWindow {
8
+ /**
9
+ * Shift start time as "HH:mm", "HH:mm:ss", or a LocalTime object (e.g. "08:30").
10
+ */
11
+ readonly start: string | LocalTime;
12
+ /**
13
+ * Shift end time as "HH:mm", "HH:mm:ss", or a LocalTime object (e.g. "17:30").
14
+ */
15
+ readonly end: string | LocalTime;
16
+ }
17
+ /**
18
+ * Business schedule configuration for working hours, shifts, weekends, and holidays.
19
+ */
20
+ export interface BusinessSchedule {
21
+ /**
22
+ * Working days of the week as ISO weekday numbers (1 = Monday, 7 = Sunday).
23
+ * Defaults to [1, 2, 3, 4, 5] (Monday to Friday), or country weekend defaults.
24
+ */
25
+ readonly workDays?: readonly number[];
26
+ /**
27
+ * Standard daily shifts. Defaults to a single shift 09:00 - 17:00.
28
+ */
29
+ readonly shifts?: readonly ShiftWindow[];
30
+ /**
31
+ * Day-of-week specific shift overrides (e.g. `{ 5: [{ start: "08:30", end: "12:00" }] }` for Friday half-day).
32
+ */
33
+ readonly dayShifts?: Partial<Record<number, readonly ShiftWindow[]>>;
34
+ /**
35
+ * Country code (e.g. "th", "jp", "us", "gb", "de") or custom HolidayCalendar for automatic holiday exclusion.
36
+ */
37
+ readonly country?: CountryCode | string | HolidayCalendar;
38
+ /**
39
+ * Custom holiday list, holiday predicate, or holiday calendar.
40
+ */
41
+ readonly holidays?: BusinessDaysOptions["holidays"];
42
+ /**
43
+ * Custom weekend days (e.g. [6, 7] for Sat-Sun, or [4, 5] for Iran).
44
+ */
45
+ readonly weekendDays?: readonly number[];
46
+ /**
47
+ * TimeZone identifier (e.g. "Asia/Bangkok", "America/New_York", "UTC").
48
+ * Required when evaluating Instant or Date across specific local working hours.
49
+ */
50
+ readonly timeZone?: TimeZoneId;
51
+ }
52
+ /**
53
+ * Normalized shift representation in milliseconds from midnight [0, 86_400_000].
54
+ */
55
+ export interface NormalizedShift {
56
+ readonly startMs: number;
57
+ readonly endMs: number;
58
+ readonly durationMs: number;
59
+ }
60
+ /**
61
+ * Result representing an upcoming or active business shift window.
62
+ */
63
+ export interface NextBusinessShiftResult<T> {
64
+ readonly start: T;
65
+ readonly end: T;
66
+ }
67
+ export type BusinessTimeInput = LocalDateTime | Instant | Date | LocalDate;
68
+ /**
69
+ * Checks whether the given timestamp falls inside an active working shift on a working day.
70
+ * Returns false during non-working days, holidays, weekends, lunch breaks, or outside shift hours.
71
+ *
72
+ * @param input - LocalDateTime, Instant, Date, or LocalDate to check.
73
+ * @param schedule - Working schedule, shift windows, and holiday configuration.
74
+ */
75
+ export declare function isBusinessHour(input: BusinessTimeInput, schedule?: BusinessSchedule): boolean;
76
+ /**
77
+ * Adds business hours to a timestamp, skipping non-working hours, breaks, weekends, and statutory holidays.
78
+ * If the starting timestamp falls outside business hours (e.g. at night or during lunch),
79
+ * the SLA calculation automatically starts ticking from the start of the next active shift.
80
+ *
81
+ * @param input - The starting LocalDateTime, Instant, Date, or LocalDate.
82
+ * @param hours - Number of business hours to add (supports fractional hours like 2.5).
83
+ * @param schedule - Business schedule defining shift windows, weekends, holidays, and timezone.
84
+ * @returns The resulting deadline in the same type as the input.
85
+ */
86
+ export declare function addBusinessHours(input: LocalDate, hours: number, schedule?: BusinessSchedule): LocalDateTime;
87
+ export declare function addBusinessHours<T extends LocalDateTime | Instant | Date>(input: T, hours: number, schedule?: BusinessSchedule): T;
88
+ export declare function addBusinessHours(input: BusinessTimeInput, hours: number, schedule?: BusinessSchedule): LocalDateTime | Instant | Date;
89
+ /**
90
+ * Subtracts business hours from a timestamp backwards, skipping non-working hours, breaks, weekends, and holidays.
91
+ *
92
+ * @param input - The starting LocalDateTime, Instant, Date, or LocalDate.
93
+ * @param hours - Number of business hours to subtract (supports fractional hours).
94
+ * @param schedule - Business schedule configuration.
95
+ * @returns The resulting earlier timestamp in the same type as the input.
96
+ */
97
+ export declare function subtractBusinessHours(input: LocalDate, hours: number, schedule?: BusinessSchedule): LocalDateTime;
98
+ export declare function subtractBusinessHours<T extends LocalDateTime | Instant | Date>(input: T, hours: number, schedule?: BusinessSchedule): T;
99
+ export declare function subtractBusinessHours(input: BusinessTimeInput, hours: number, schedule?: BusinessSchedule): LocalDateTime | Instant | Date;
100
+ /**
101
+ * Computes the exact signed number of business hours elapsed between two timestamps (left - right).
102
+ * Non-working hours, lunch breaks, weekends, and statutory holidays are excluded.
103
+ *
104
+ * @param left - The later or earlier timestamp.
105
+ * @param right - The reference timestamp.
106
+ * @param schedule - Business schedule configuration.
107
+ * @returns Fractional business hours elapsed (positive if left > right, negative if left < right, 0 if equal).
108
+ */
109
+ export declare function diffInBusinessHours(left: BusinessTimeInput, right: BusinessTimeInput, schedule?: BusinessSchedule): number;
110
+ /**
111
+ * Options for resolving the next business shift window.
112
+ */
113
+ export interface NextBusinessShiftOptions {
114
+ /**
115
+ * If true (default), returns the currently ongoing shift if the timestamp falls inside it.
116
+ * If false, strictly returns the next upcoming shift after the timestamp.
117
+ */
118
+ readonly includeCurrent?: boolean;
119
+ }
120
+ /**
121
+ * Resolves the next upcoming (or currently active) business shift window.
122
+ *
123
+ * @param input - The reference timestamp.
124
+ * @param schedule - Business schedule configuration.
125
+ * @param options - Options for including the currently active shift.
126
+ */
127
+ export declare function nextBusinessShift(input: LocalDate, schedule?: BusinessSchedule, options?: NextBusinessShiftOptions): NextBusinessShiftResult<LocalDateTime>;
128
+ export declare function nextBusinessShift<T extends LocalDateTime | Instant | Date>(input: T, schedule?: BusinessSchedule, options?: NextBusinessShiftOptions): NextBusinessShiftResult<T>;
129
+ export declare function nextBusinessShift(input: BusinessTimeInput, schedule?: BusinessSchedule, options?: NextBusinessShiftOptions): NextBusinessShiftResult<LocalDateTime | Instant | Date>;
130
+ /**
131
+ * Returns the earliest shift start time for a given date as a LocalDateTime.
132
+ */
133
+ export declare function startOfBusinessDay(date: LocalDate | LocalDateTime | Date, schedule?: BusinessSchedule): LocalDateTime;
134
+ /**
135
+ * Returns the latest shift end time for a given date as a LocalDateTime.
136
+ */
137
+ export declare function endOfBusinessDay(date: LocalDate | LocalDateTime | Date, schedule?: BusinessSchedule): LocalDateTime;