@intech-software/chronera 0.1.6 → 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 +4 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/operations/age-countdown.d.ts +60 -0
- package/dist/operations/age-countdown.js +199 -0
- package/dist/operations/age-countdown.js.map +1 -0
- package/dist/operations/duration-ops.d.ts +43 -0
- package/dist/operations/duration-ops.js +393 -0
- package/dist/operations/duration-ops.js.map +1 -0
- package/dist/operations/interval.d.ts +55 -0
- package/dist/operations/interval.js +253 -0
- package/dist/operations/interval.js.map +1 -0
- package/dist/operations/natural-language.d.ts +13 -0
- package/dist/operations/natural-language.js +428 -0
- package/dist/operations/natural-language.js.map +1 -0
- package/dist/operations/recurrence.d.ts +48 -0
- package/dist/operations/recurrence.js +279 -0
- package/dist/operations/recurrence.js.map +1 -0
- package/dist/operations/time-series.d.ts +58 -0
- package/dist/operations/time-series.js +153 -0
- package/dist/operations/time-series.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -26,4 +26,8 @@ export { localTime } from "./core/local-time.js";
|
|
|
26
26
|
export { localDateTime } from "./core/local-date-time.js";
|
|
27
27
|
export { dateRange } from "./core/range.js";
|
|
28
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";
|
|
29
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
|
@@ -23,4 +23,7 @@ export { localTime } from "./core/local-time.js";
|
|
|
23
23
|
export { localDateTime } from "./core/local-date-time.js";
|
|
24
24
|
export { dateRange } from "./core/range.js";
|
|
25
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";
|
|
26
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,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,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,cA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O,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 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 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,gCAAg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,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,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,CAAC,GAAG,8BAA8B,CAAC,GAAG,CAAC,CAAC;IAC9C,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;AAC1E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,SAA6B,EAC7B,IAAyB;IAEzB,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI;QACd,CAAC,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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,43 @@
|
|
|
1
|
+
import type { DateOrCalendarDate, Duration } from "../public-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Parses an ISO 8601 duration string into a `Duration` object.
|
|
4
|
+
* Examples: `'P1Y2M3DT4H5M6.789S'`, `'P1Y'`, `'-P1Y'`, `'P-1Y'`
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseDuration(iso: string): Duration;
|
|
7
|
+
/**
|
|
8
|
+
* Converts a `Duration` object to an ISO 8601 duration string.
|
|
9
|
+
* Example: `{ years: 1, months: 2, days: 3 }` → `'P1Y2M3D'`
|
|
10
|
+
*/
|
|
11
|
+
export declare function durationToISO(dur: Duration): string;
|
|
12
|
+
/**
|
|
13
|
+
* Returns a human-readable string for the duration in the given locale.
|
|
14
|
+
* Example (en): `{ days: 5, hours: 3, minutes: 30 }` → `'5 days, 3 hours, 30 minutes'`
|
|
15
|
+
*/
|
|
16
|
+
export declare function durationToHuman(dur: Duration, locale?: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Adds a duration to a date (applies years, months, weeks, days in order).
|
|
19
|
+
* Time fields (hours, minutes, seconds, milliseconds) are ignored for date-only types.
|
|
20
|
+
*/
|
|
21
|
+
export declare function addDuration<T extends DateOrCalendarDate>(date: T, dur: Duration): T;
|
|
22
|
+
/**
|
|
23
|
+
* Subtracts a duration from a date.
|
|
24
|
+
*/
|
|
25
|
+
export declare function subtractDuration<T extends DateOrCalendarDate>(date: T, dur: Duration): T;
|
|
26
|
+
/**
|
|
27
|
+
* Computes the duration between two dates. Always returns positive field values.
|
|
28
|
+
* Returns `{ years, months, days }` representing the full decomposed diff.
|
|
29
|
+
*/
|
|
30
|
+
export declare function diffAsDuration(start: DateOrCalendarDate, end: DateOrCalendarDate): Duration;
|
|
31
|
+
/**
|
|
32
|
+
* Sums two durations by adding corresponding fields.
|
|
33
|
+
*/
|
|
34
|
+
export declare function addDurations(a: Duration, b: Duration): Duration;
|
|
35
|
+
/**
|
|
36
|
+
* Scales a duration by a numeric factor. Non-integer results are truncated.
|
|
37
|
+
*/
|
|
38
|
+
export declare function scaleDuration(dur: Duration, factor: number): Duration;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the approximate total number of days for a duration.
|
|
41
|
+
* Uses approximations: 1 year = 365 days, 1 month = 30 days.
|
|
42
|
+
*/
|
|
43
|
+
export declare function durationTotalDays(dur: Duration): number;
|