temporal-workdays 0.0.0-stage → 0.2.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/epoch.ts","../src/errors.ts","../src/temporal.ts","../src/day-calendar.ts","../src/time.ts","../src/hours.ts","../src/workdays.ts","../src/work-calendar.ts","../src/date-holidays.ts"],"names":[],"mappings":";AAQO,SAAS,eAAA,CAAgB,IAAA,EAAc,KAAA,EAAe,GAAA,EAAqB;AAChF,EAAA,MAAM,CAAA,GAAI,KAAA,IAAS,CAAA,GAAI,IAAA,GAAO,CAAA,GAAI,IAAA;AAClC,EAAA,MAAM,GAAA,GAAM,IAAA,CAAK,KAAA,CAAM,CAAA,GAAI,GAAG,CAAA;AAC9B,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,GAAM,GAAA;AACtB,EAAA,MAAM,EAAA,GAAA,CAAM,QAAQ,CAAA,IAAK,EAAA;AACzB,EAAA,MAAM,GAAA,GAAM,KAAK,KAAA,CAAA,CAAO,GAAA,GAAM,KAAK,CAAA,IAAK,CAAC,IAAI,GAAA,GAAM,CAAA;AACnD,EAAA,MAAM,GAAA,GAAM,GAAA,GAAM,GAAA,GAAM,IAAA,CAAK,KAAA,CAAM,GAAA,GAAM,CAAC,CAAA,GAAI,IAAA,CAAK,KAAA,CAAM,GAAA,GAAM,GAAG,CAAA,GAAI,GAAA;AACtE,EAAA,OAAO,GAAA,GAAM,SAAS,GAAA,GAAM,MAAA;AAC9B;AAGO,SAAS,gBAAgB,QAAA,EAA4C;AAC1E,EAAA,MAAM,IAAI,QAAA,GAAW,MAAA;AACrB,EAAA,MAAM,GAAA,GAAM,IAAA,CAAK,KAAA,CAAM,CAAA,GAAI,MAAM,CAAA;AACjC,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,GAAM,MAAA;AACtB,EAAA,MAAM,MAAM,IAAA,CAAK,KAAA,CAAA,CAAO,MAAM,IAAA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AAA;AAAA,IAC/C,YAAA,EAAc,CAAC,IAAA,EAAM,OAAA,KAAsC;AACzD,MAAA,MAAM,GAAA,GAAM,OAAO,IAAI,CAAA;AACvB,MAAA,IAAI,KAAA,CAAM,IAAA,CAAK,GAAA,CAAI,GAAG,GAAG,OAAO,MAAA;AAChC,MAAA,MAAM,QAAA,GAAW,KAAA,CAAM,OAAA,CAAQ,GAAA,CAAI,GAAG,CAAA;AACtC,MAAA,IAAI,CAAC,UAAU,OAAO,MAAA;AACtB,MAAA,IAAI,IAAA,GAAO,aAAA,CAAc,OAAA,EAAS,eAAe,CAAA;AACjD,MAAA,KAAA,MAAW,CAAC,MAAM,EAAE,CAAA,IAAK,UAAU,IAAA,GAAO,gBAAA,CAAiB,IAAA,EAAM,IAAA,EAAM,EAAE,CAAA;AACzE,MAAA,OAAO,eAAe,IAAI,CAAA;AAAA,IAC5B;AAAA,GACF;AACF","file":"index.js","sourcesContent":["import type { DayOfWeek } from './types.js';\n\n// Pure integer date arithmetic on the proleptic ISO calendar.\n// \"Epoch day\" = number of days since 1970-01-01 (which is day 0).\n// Working on integers keeps the hot loops fast and independent of any\n// particular Temporal implementation (native or polyfill).\n\n/** Days from 1970-01-01 to the given ISO date (Howard Hinnant's algorithm). */\nexport function epochDayFromIso(year: number, month: number, day: number): number {\n const y = month <= 2 ? year - 1 : year;\n const era = Math.floor(y / 400);\n const yoe = y - era * 400;\n const mp = (month + 9) % 12; // March = 0\n const doy = Math.floor((153 * mp + 2) / 5) + day - 1;\n const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;\n return era * 146097 + doe - 719468;\n}\n\n/** Inverse of epochDayFromIso. Returns [year, month, day]. */\nexport function isoFromEpochDay(epochDay: number): [number, number, number] {\n const z = epochDay + 719468;\n const era = Math.floor(z / 146097);\n const doe = z - era * 146097;\n const yoe = Math.floor((doe - Math.floor(doe / 1460) + Math.floor(doe / 36524) - Math.floor(doe / 146096)) / 365);\n const doy = doe - (365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100));\n const mp = Math.floor((5 * doy + 2) / 153);\n const day = doy - Math.floor((153 * mp + 2) / 5) + 1;\n const month = mp < 10 ? mp + 3 : mp - 9;\n const year = yoe + era * 400 + (month <= 2 ? 1 : 0);\n return [year, month, day];\n}\n\n/** ISO day of week: 1 = Monday … 7 = Sunday. 1970-01-01 was a Thursday. */\nexport function dayOfWeekFromEpochDay(epochDay: number): DayOfWeek {\n return (((((epochDay + 3) % 7) + 7) % 7) + 1) as DayOfWeek;\n}\n\nexport function isLeapYear(year: number): boolean {\n return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n}\n\nexport function daysInMonth(year: number, month: number): number {\n if (month === 2) return isLeapYear(year) ? 29 : 28;\n return month === 4 || month === 6 || month === 9 || month === 11 ? 30 : 31;\n}\n\n/** Floor division by a positive bigint (`/` truncates toward zero, which is wrong for negative `a`). */\nexport function floorDiv(a: bigint, b: bigint): bigint {\n const q = a / b;\n return a % b < 0n ? q - 1n : q;\n}\n","const PREFIX = 'temporal-workdays: ';\n\nexport function rangeError(message: string): RangeError {\n return new RangeError(PREFIX + message);\n}\n\nexport function typeError(message: string): TypeError {\n return new TypeError(PREFIX + message);\n}\n\n/** Describes any value for an error message without ever throwing (unlike `String(value)`). */\nexport function describe(value: unknown): string {\n switch (typeof value) {\n case 'string':\n return JSON.stringify(value);\n case 'number':\n case 'boolean':\n case 'bigint':\n case 'undefined':\n return String(value);\n case 'symbol':\n return value.toString();\n case 'function':\n return 'a function';\n case 'object':\n return value === null ? 'null' : Object.prototype.toString.call(value);\n }\n}\n","// Runtime helpers for working with Temporal values from any implementation.\n\nimport { epochDayFromIso } from './epoch.js';\nimport { describe, typeError } from './errors.js';\nimport type { DateInput, PlainDateLike, PlainDateTimeLike, ZonedDateTimeLike } from './types.js';\n\n/** The `Symbol.toStringTag` brand of a Temporal object, e.g. `'Temporal.PlainDate'`. */\nexport function hasBrand(value: unknown, brand: string): boolean {\n return typeof value === 'object' && value !== null && Object.prototype.toString.call(value) === `[object ${brand}]`;\n}\n\nexport function isPlainDate(value: unknown): value is PlainDateLike {\n return hasBrand(value, 'Temporal.PlainDate');\n}\n\nexport function isPlainDateTime(value: unknown): value is PlainDateTimeLike {\n return hasBrand(value, 'Temporal.PlainDateTime');\n}\n\nexport function isZonedDateTime(value: unknown): value is ZonedDateTimeLike {\n return hasBrand(value, 'Temporal.ZonedDateTime');\n}\n\n/** The calendar date of a PlainDate / PlainDateTime / ZonedDateTime input. */\nexport function toPlainDate(date: DateInput): PlainDateLike {\n if (isPlainDate(date)) return date;\n if (isPlainDateTime(date) || isZonedDateTime(date)) {\n return date.toPlainDate();\n }\n throw typeError(`expected a Temporal.PlainDate, PlainDateTime or ZonedDateTime, got ${describe(date)}`);\n}\n\ninterface Calendared<V> {\n readonly calendarId: string;\n withCalendar(calendar: 'iso8601'): V;\n}\n\n/** The same value in the ISO 8601 calendar (a no-op for ISO values). */\nexport function toIso<V extends Calendared<V>>(value: V): V {\n return value.calendarId === 'iso8601' ? value : value.withCalendar('iso8601');\n}\n\n/** `value` (ISO) converted back to `calendarId`. */\nexport function withCalendarId<V extends { withCalendar(calendar: string): V }>(value: V, calendarId: string): V {\n return calendarId === 'iso8601' ? value : value.withCalendar(calendarId);\n}\n\nexport function toIsoDate(date: PlainDateLike): PlainDateLike {\n return toIso(date);\n}\n\n/** Days since 1970-01-01 of the date's ISO calendar date. */\nexport function epochDayOf(date: PlainDateLike): number {\n const iso = toIsoDate(date);\n return epochDayFromIso(iso.year, iso.month, iso.day);\n}\n\n/**\n * Turns epoch days back into ISO `PlainDate`s of the same Temporal implementation as\n * a reference date. Only used when user code (a holiday predicate) needs a real date.\n */\nexport class DateFactory {\n readonly #iso: PlainDateLike;\n readonly #epochDay: number;\n\n constructor(reference: PlainDateLike) {\n this.#iso = toIsoDate(reference);\n this.#epochDay = epochDayFromIso(this.#iso.year, this.#iso.month, this.#iso.day);\n }\n\n get epochDay(): number {\n return this.#epochDay;\n }\n\n at(epochDay: number): PlainDateLike {\n return epochDay === this.#epochDay ? this.#iso : this.#iso.add({ days: epochDay - this.#epochDay });\n }\n}\n","// Compiles `WorkdayOptions` into integer lookups and answers \"is this epoch day a workday?\".\n\nimport { dayOfWeekFromEpochDay, daysInMonth, epochDayFromIso, isoFromEpochDay } from './epoch.js';\nimport { describe, rangeError, typeError } from './errors.js';\nimport { epochDayOf, hasBrand, isPlainDate, type DateFactory } from './temporal.js';\nimport type { DayOfWeek, HolidayInput, HolidayPredicate, PlainMonthDayLike, WorkdayOptions } from './types.js';\n\n/** Longest run of consecutive non-working days searched before giving up (≈ 20 years). */\nexport const MAX_SCAN_DAYS = 366 * 20;\n\nexport interface DayCalendar {\n /** Indexed by ISO day of week 1..7. */\n readonly weekend: readonly boolean[];\n /** Single-date holidays, as epoch days. */\n readonly dates: ReadonlySet<number>;\n /** Annual holidays, as `month * 100 + day`. */\n readonly annual: ReadonlySet<number>;\n readonly predicate: HolidayPredicate | undefined;\n /** Extra workdays, as epoch days. */\n readonly extra: ReadonlySet<number>;\n}\n\nconst DATE_RE = /^([+-]\\d{6}|\\d{4})-(\\d{2})-(\\d{2})$/;\nconst MONTH_DAY_RE = /^(?:--)?(\\d{2})-(\\d{2})$/;\n/** Every option name any function accepts, so one options object can be shared by all of them. */\nexport const OPTION_KEYS: ReadonlySet<string> = new Set([\n 'weekend',\n 'holidays',\n 'extraWorkdays',\n 'hours',\n 'specialHours',\n]);\n\nfunction checkDate(year: number, month: number, day: number, source: unknown): void {\n if (month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month)) {\n throw rangeError(`invalid date ${describe(source)}`);\n }\n}\n\n/** Parses a single calendar date: `'YYYY-MM-DD'` (or extended `±YYYYYY-MM-DD`) or a `Temporal.PlainDate`. */\nexport function parseDate(value: unknown): number {\n if (typeof value === 'string') {\n const m = DATE_RE.exec(value);\n if (!m) throw rangeError(`expected a \"YYYY-MM-DD\" date, got ${describe(value)}`);\n const [year, month, day] = [Number(m[1]), Number(m[2]), Number(m[3])];\n checkDate(year, month, day, value);\n return epochDayFromIso(year, month, day);\n }\n if (isPlainDate(value)) return epochDayOf(value);\n throw typeError(`expected a \"YYYY-MM-DD\" string or Temporal.PlainDate, got ${describe(value)}`);\n}\n\nfunction addHoliday(entry: HolidayInput, dates: Set<number>, annual: Set<number>): void {\n if (typeof entry === 'string') {\n const md = MONTH_DAY_RE.exec(entry);\n if (md) {\n const [month, day] = [Number(md[1]), Number(md[2])];\n checkDate(2000, month, day, entry); // a leap year, so that 02-29 is accepted\n annual.add(month * 100 + day);\n return;\n }\n } else if (hasBrand(entry, 'Temporal.PlainMonthDay')) {\n const pmd = entry as PlainMonthDayLike;\n if (pmd.calendarId !== 'iso8601') {\n throw rangeError('Temporal.PlainMonthDay holidays must use the iso8601 calendar');\n }\n annual.add(Number(pmd.monthCode.slice(1)) * 100 + pmd.day);\n return;\n }\n dates.add(parseDate(entry));\n}\n\nexport function isIterable(value: unknown): value is Iterable<unknown> {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as Partial<Iterable<unknown>>)[Symbol.iterator] === 'function'\n );\n}\n\n/** Throws a TypeError for anything in `options` that is not one of `allowed` (catches typos in JS). */\nexport function checkOptionKeys(options: object, allowed: ReadonlySet<string>): void {\n for (const key of Object.keys(options)) {\n if (!allowed.has(key)) throw typeError(`unknown option ${JSON.stringify(key)}`);\n }\n}\n\nexport function checkOptionsObject(options: unknown): asserts options is object | undefined {\n if (options !== undefined && (typeof options !== 'object' || options === null)) {\n throw typeError(`options must be an object, got ${describe(options)}`);\n }\n}\n\nexport function compileDayCalendar(options: WorkdayOptions = {}): DayCalendar {\n checkOptionsObject(options);\n checkOptionKeys(options, OPTION_KEYS);\n\n const weekend = new Array<boolean>(8).fill(false);\n const weekendDays: unknown = options.weekend ?? [6, 7];\n if (!isIterable(weekendDays)) throw typeError(`weekend must be an array of days, got ${describe(weekendDays)}`);\n for (const d of weekendDays) {\n if (!Number.isInteger(d) || (d as number) < 1 || (d as number) > 7) {\n throw rangeError(`weekend days must be integers 1 (Mon) – 7 (Sun), got ${describe(d)}`);\n }\n weekend[d as DayOfWeek] = true;\n }\n\n const dates = new Set<number>();\n const annual = new Set<number>();\n let predicate: HolidayPredicate | undefined;\n const holidays: unknown = options.holidays;\n if (typeof holidays === 'function') {\n predicate = holidays as HolidayPredicate;\n } else if (holidays !== undefined) {\n if (!isIterable(holidays)) throw typeError(`holidays must be an array or a function, got ${describe(holidays)}`);\n for (const entry of holidays) addHoliday(entry as HolidayInput, dates, annual);\n }\n\n const extra = new Set<number>();\n const extraWorkdays: unknown = options.extraWorkdays;\n if (extraWorkdays !== undefined) {\n if (!isIterable(extraWorkdays)) throw typeError(`extraWorkdays must be an array, got ${describe(extraWorkdays)}`);\n for (const entry of extraWorkdays) extra.add(parseDate(entry));\n }\n\n return { weekend, dates, annual, predicate, extra };\n}\n\nexport function isWeekendDay(cal: DayCalendar, epochDay: number): boolean {\n return cal.weekend[dayOfWeekFromEpochDay(epochDay)] === true;\n}\n\n/** Holiday check that ignores `extraWorkdays`. */\nfunction isListedHoliday(cal: DayCalendar, epochDay: number, dates: DateFactory): boolean {\n if (cal.dates.has(epochDay)) return true;\n if (cal.annual.size > 0) {\n const [, month, day] = isoFromEpochDay(epochDay);\n if (cal.annual.has(month * 100 + day)) return true;\n }\n return Boolean(cal.predicate?.(dates.at(epochDay)));\n}\n\nexport function isHolidayDay(cal: DayCalendar, epochDay: number, dates: DateFactory): boolean {\n return !cal.extra.has(epochDay) && isListedHoliday(cal, epochDay, dates);\n}\n\nexport function isWorkdayDay(cal: DayCalendar, epochDay: number, dates: DateFactory): boolean {\n if (cal.extra.has(epochDay)) return true;\n if (isWeekendDay(cal, epochDay)) return false;\n return !isListedHoliday(cal, epochDay, dates);\n}\n\nexport function noWorkdayError(): RangeError {\n return rangeError(`no workday found within ${MAX_SCAN_DAYS} days — check the weekend/holiday configuration`);\n}\n\n/**\n * The epoch day `count` workdays away from `from` in direction `dir`, not counting `from`.\n * Throws instead of looping forever when a configuration has no workdays.\n */\nexport function stepWorkdays(cal: DayCalendar, from: number, count: number, dir: 1 | -1, dates: DateFactory): number {\n let day = from;\n let remaining = count;\n let gap = 0;\n while (remaining > 0) {\n day += dir;\n if (isWorkdayDay(cal, day, dates)) {\n remaining--;\n gap = 0;\n } else if (++gap > MAX_SCAN_DAYS) {\n throw noWorkdayError();\n }\n }\n return day;\n}\n\n/** Number of workdays in the epoch-day range `(from, to]`; negative when `to < from`. */\nexport function countWorkdays(cal: DayCalendar, from: number, to: number, dates: DateFactory): number {\n const [lo, hi, sign] = from <= to ? [from, to, 1] : [to, from, -1];\n let count = 0;\n for (let day = lo + 1; day <= hi; day++) {\n if (isWorkdayDay(cal, day, dates)) count++;\n }\n return count === 0 ? 0 : sign * count; // never -0\n}\n","// Times of day as integer nanoseconds since midnight, and normalized daily intervals.\n\nimport { describe, rangeError, typeError } from './errors.js';\nimport { hasBrand } from './temporal.js';\nimport type { PlainTimeLike, TimeInput, TimeRange, TimeRangeText } from './types.js';\n\nexport const NS_PER_SECOND = 1_000_000_000;\nexport const NS_PER_MINUTE = 60 * NS_PER_SECOND;\nexport const NS_PER_HOUR = 60 * NS_PER_MINUTE;\nexport const NS_PER_DAY = 24 * NS_PER_HOUR;\n\n/** A half-open interval `[start, end)` within one day, in nanoseconds since midnight. */\nexport type Interval = readonly [start: number, end: number];\n\nconst TIME_RE = /^(\\d{2}):(\\d{2})(?::(\\d{2})(?:[.,](\\d{1,9}))?)?$/;\n\nexport function nsOfDay(hour: number, minute: number, second = 0, subsecondNs = 0): number {\n return hour * NS_PER_HOUR + minute * NS_PER_MINUTE + second * NS_PER_SECOND + subsecondNs;\n}\n\n/** Nanoseconds since midnight of a `Temporal.PlainTime`/`PlainDateTime`/`ZonedDateTime`. */\nexport function nsOfTime(t: PlainTimeLike): number {\n return nsOfDay(t.hour, t.minute, t.second, t.millisecond * 1_000_000 + t.microsecond * 1_000 + t.nanosecond);\n}\n\n/** Parses `'HH:MM'`, `'HH:MM:SS'`, `'HH:MM:SS.fffffffff'` or a `Temporal.PlainTime`. `24:00` is midnight at the end. */\nexport function parseTime(value: TimeInput): number {\n if (typeof value === 'string') {\n const m = TIME_RE.exec(value);\n if (m) {\n const [hour, minute, second] = [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)];\n const subsecond = Number((m[4] ?? '').padEnd(9, '0'));\n const ns = nsOfDay(hour, minute, second, subsecond);\n if (minute < 60 && second < 60 && ns <= NS_PER_DAY) return ns;\n }\n throw rangeError(`expected a time like \"09:30\" (00:00 – 24:00), got ${describe(value)}`);\n }\n if (hasBrand(value, 'Temporal.PlainTime')) return nsOfTime(value);\n throw typeError(`expected a \"HH:MM\" string or Temporal.PlainTime, got ${describe(value)}`);\n}\n\nconst pad = (n: number, width = 2): string => String(n).padStart(width, '0');\n\n/** Shortest of `HH:MM`, `HH:MM:SS`, `HH:MM:SS.fff…` that represents `ns` exactly. */\nexport function formatTime(ns: number): string {\n const hour = Math.floor(ns / NS_PER_HOUR);\n const minute = Math.floor((ns % NS_PER_HOUR) / NS_PER_MINUTE);\n const second = Math.floor((ns % NS_PER_MINUTE) / NS_PER_SECOND);\n const fraction = ns % NS_PER_SECOND;\n let text = `${pad(hour)}:${pad(minute)}`;\n if (second !== 0 || fraction !== 0) text += `:${pad(second)}`;\n if (fraction !== 0) text += `.${pad(fraction, 9).replace(/0+$/, '')}`;\n return text;\n}\n\n/**\n * Validates and normalizes one day's ranges: sorted, non-empty, non-overlapping, with\n * touching ranges merged. Throws on `start >= end` or on overlaps (likely a typo).\n */\nexport function parseDayHours(value: unknown, where: string): readonly Interval[] {\n if (!Array.isArray(value))\n throw typeError(`${where} must be an array of [start, end] ranges, got ${describe(value)}`);\n const ranges = (value as readonly unknown[]).map((range): Interval => {\n if (!Array.isArray(range) || range.length !== 2) {\n throw typeError(`${where}: each range must be a [start, end] pair, got ${describe(range)}`);\n }\n const [start, end] = range as unknown as TimeRange;\n const interval: Interval = [parseTime(start), parseTime(end)];\n if (interval[0] >= interval[1]) {\n throw rangeError(`${where}: range start must be before its end, got ${describe(start)}–${describe(end)}`);\n }\n return interval;\n });\n ranges.sort((a, b) => a[0] - b[0]);\n const merged: [number, number][] = [];\n for (const [start, end] of ranges) {\n const last = merged.at(-1);\n if (last && start < last[1]) {\n throw rangeError(\n `${where}: ranges overlap (${formatTime(last[0])}–${formatTime(last[1])} and ${formatTime(start)}–${formatTime(end)})`,\n );\n }\n if (last?.[1] === start) last[1] = end;\n else merged.push([start, end]);\n }\n return merged;\n}\n\nexport function formatDayHours(intervals: readonly Interval[]): readonly TimeRangeText[] {\n return intervals.map(([start, end]) => [formatTime(start), formatTime(end)] as const);\n}\n/** `intervals` minus `[cutStart, cutEnd)`. */\nexport function subtractInterval(intervals: readonly Interval[], cutStart: number, cutEnd: number): Interval[] {\n const out: Interval[] = [];\n for (const [start, end] of intervals) {\n if (end <= cutStart || start >= cutEnd) {\n out.push([start, end]);\n continue;\n }\n if (start < cutStart) out.push([start, cutStart]);\n if (end > cutEnd) out.push([cutEnd, end]);\n }\n return out;\n}\n","// Time-level API: working hours on top of workdays.\n//\n// Working hours are wall-clock intervals per day. A Timeline maps them to positions on one\n// axis: wall-clock time for PlainDateTime, exact time for ZonedDateTime, so that a DST change\n// inside working hours counts as the real 7 or 9 hours it lasts. The algorithms then only\n// walk sorted periods of bigint positions.\n\nimport {\n checkOptionKeys,\n checkOptionsObject,\n compileDayCalendar,\n isWorkdayDay,\n MAX_SCAN_DAYS,\n parseDate,\n type DayCalendar,\n} from './day-calendar.js';\nimport { dayOfWeekFromEpochDay, epochDayFromIso, floorDiv, isoFromEpochDay } from './epoch.js';\nimport { describe, rangeError, typeError } from './errors.js';\nimport {\n DateFactory,\n isPlainDate,\n isPlainDateTime,\n isZonedDateTime,\n toIso,\n toPlainDate,\n withCalendarId,\n} from './temporal.js';\nimport {\n formatDayHours,\n NS_PER_DAY,\n NS_PER_HOUR,\n NS_PER_MINUTE,\n NS_PER_SECOND,\n nsOfTime,\n parseDayHours,\n type Interval,\n} from './time.js';\nimport type {\n DateInput,\n DayOfWeek,\n DateTimeFields,\n DateTimeInput,\n DurationInput,\n DurationLike,\n DurationOf,\n PlainDateTimeLike,\n PlainTimeLike,\n SpecialHoursFunction,\n TimeRangeText,\n WorkingTimeOptions,\n ZonedDateTimeLike,\n} from './types.js';\n\n// --- Compiled configuration ---------------------------------------------------------------\n\ntype Special =\n | { readonly kind: 'none' }\n | { readonly kind: 'table'; readonly byDay: ReadonlyMap<number, readonly Interval[]> }\n | { readonly kind: 'function'; readonly fn: SpecialHoursFunction };\n\nexport interface HoursCalendar {\n readonly days: DayCalendar;\n /** Regular intervals by ISO day of week. */\n readonly weekly: Readonly<Record<DayOfWeek, readonly Interval[]>>;\n /** The same, formatted, for passing to special-hours functions. */\n readonly weeklyText: Readonly<Record<DayOfWeek, readonly TimeRangeText[]>>;\n readonly special: Special;\n}\n\nfunction byDayOfWeek<V>(f: (dow: DayOfWeek) => V): Record<DayOfWeek, V> {\n return { 1: f(1), 2: f(2), 3: f(3), 4: f(4), 5: f(5), 6: f(6), 7: f(7) };\n}\n\nexport const OPTION_KEYS: ReadonlySet<string> = new Set([\n 'weekend',\n 'holidays',\n 'extraWorkdays',\n 'hours',\n 'specialHours',\n]);\nconst WEEKLY_KEYS: ReadonlySet<string> = new Set(['1', '2', '3', '4', '5', '6', '7', 'default']);\nconst EMPTY: readonly Interval[] = [];\n\nfunction compileWeekly(hours: unknown): Record<DayOfWeek, readonly Interval[]> {\n if (hours === undefined) throw typeError('working-time functions need an `hours` option');\n if (Array.isArray(hours)) {\n const uniform = parseDayHours(hours, 'hours');\n return byDayOfWeek(() => uniform);\n }\n if (typeof hours !== 'object' || hours === null) {\n throw typeError(`hours must be an array of ranges or an object by day of week, got ${describe(hours)}`);\n }\n checkOptionKeys(hours, WEEKLY_KEYS);\n const byDay = hours as Readonly<Record<string, unknown>>;\n const fallback = byDay['default'] === undefined ? EMPTY : parseDayHours(byDay['default'], 'hours.default');\n return byDayOfWeek((dow) => (byDay[dow] === undefined ? fallback : parseDayHours(byDay[dow], `hours[${dow}]`)));\n}\n\nfunction compileSpecial(special: unknown): Special {\n if (special === undefined) return { kind: 'none' };\n if (typeof special === 'function') return { kind: 'function', fn: special as SpecialHoursFunction };\n if (typeof special !== 'object' || special === null || Array.isArray(special)) {\n throw typeError(`specialHours must be an object keyed by date or a function, got ${describe(special)}`);\n }\n const byDay = new Map<number, readonly Interval[]>();\n for (const [date, hours] of Object.entries(special)) {\n byDay.set(parseDate(date), parseDayHours(hours, `specialHours[${JSON.stringify(date)}]`));\n }\n return { kind: 'table', byDay };\n}\n\nexport function compileHoursCalendar(options: WorkingTimeOptions): HoursCalendar {\n checkOptionsObject(options);\n const days = compileDayCalendar(options);\n const weekly = compileWeekly((options as Partial<WorkingTimeOptions> | undefined)?.hours);\n const weeklyText = byDayOfWeek((dow) => formatDayHours(weekly[dow]));\n return { days, weekly, weeklyText, special: compileSpecial(options.specialHours) };\n}\n\n/** The working intervals of an epoch day, after weekends, holidays and special hours. */\nfunction intervalsOn(cal: HoursCalendar, epochDay: number, dates: DateFactory): readonly Interval[] {\n const dow = dayOfWeekFromEpochDay(epochDay);\n const workday = isWorkdayDay(cal.days, epochDay, dates);\n const { special } = cal;\n if (special.kind === 'table') {\n const override = special.byDay.get(epochDay);\n if (override) return override;\n } else if (special.kind === 'function') {\n const date = dates.at(epochDay);\n const result = special.fn(date, workday ? cal.weeklyText[dow] : []);\n if (result !== undefined) return parseDayHours(result, `specialHours(${date.toString()})`);\n }\n return workday ? cal.weekly[dow] : EMPTY;\n}\n\n// --- Timelines ----------------------------------------------------------------------------\n//\n// A timeline maps the working periods of a wall-clock day to *positions*: bigint nanoseconds\n// on a single axis (wall-clock time for PlainDateTime, exact time for ZonedDateTime). The\n// periods of one day come back sorted, non-empty and merged. Across days they can still\n// overlap (Samoa skipped 2011-12-30, so that day's periods map onto the 31st), which the\n// algorithms handle with a cursor that never moves backwards.\n\n/** A working period `[start, end)` as positions. */\ntype Period = readonly [start: bigint, end: bigint];\n\ninterface Timeline<T> {\n /** Position of the input. */\n readonly origin: bigint;\n /** How far a day's periods can lie outside that day (see ZONED_LOOKAHEAD); 0 for wall-clock time. */\n readonly lookahead: bigint;\n readonly dates: DateFactory;\n /** Position of another value; throws a TypeError unless it is the same Temporal type. */\n positionOf(value: DateTimeInput): bigint;\n /** Working periods of a wall-clock day as positions: sorted, non-empty, merged. */\n periods(day: number, intervals: readonly Interval[]): readonly Period[];\n /** The input's Temporal type at `position`, keeping its calendar (and time zone). */\n at(position: bigint): T;\n /** A Temporal.Duration of `ns` nanoseconds, from the input's implementation. */\n duration(ns: bigint): DurationLike;\n}\n\nconst BIG_NS_PER_DAY = BigInt(NS_PER_DAY);\nconst BIG_NS_PER_SECOND = BigInt(NS_PER_SECOND);\n\nfunction wallFields(day: number, ns: number): DateTimeFields {\n const [year, month, dd] = isoFromEpochDay(day);\n return {\n year,\n month,\n day: dd,\n hour: Math.floor(ns / NS_PER_HOUR),\n minute: Math.floor((ns % NS_PER_HOUR) / NS_PER_MINUTE),\n second: Math.floor((ns % NS_PER_MINUTE) / NS_PER_SECOND),\n millisecond: Math.floor((ns % NS_PER_SECOND) / 1_000_000),\n microsecond: Math.floor((ns % 1_000_000) / 1_000),\n nanosecond: ns % 1_000,\n };\n}\n\n/** Wall-clock position: nanoseconds since 1970-01-01T00:00 as if it were UTC. */\nfunction wallPosition(day: number, ns: number): bigint {\n return BigInt(day) * BIG_NS_PER_DAY + BigInt(ns);\n}\n\nfunction wallDay(v: PlainTimeLike & { year: number; month: number; day: number }): number {\n return epochDayFromIso(v.year, v.month, v.day);\n}\n\nfunction durationFrom(zero: DurationLike, ns: bigint): DurationLike {\n return zero\n .add({ seconds: Number(ns / BIG_NS_PER_SECOND), nanoseconds: Number(ns % BIG_NS_PER_SECOND) })\n .round({ largestUnit: 'hours' });\n}\n\n/** Sorts periods by start, drops empty ones and merges overlapping or touching ones. */\nfunction normalizePeriods(periods: Period[]): Period[] {\n periods.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));\n const merged: [bigint, bigint][] = [];\n for (const [start, end] of periods) {\n if (end <= start) continue;\n const last = merged.at(-1);\n if (last && start <= last[1]) {\n if (end > last[1]) last[1] = end;\n } else {\n merged.push([start, end]);\n }\n }\n return merged;\n}\n\nclass PlainTimeline implements Timeline<PlainDateTimeLike> {\n readonly origin: bigint;\n readonly lookahead = 0n;\n readonly dates: DateFactory;\n readonly #iso: PlainDateTimeLike;\n readonly #calendarId: string;\n\n constructor(value: PlainDateTimeLike) {\n this.#calendarId = value.calendarId;\n this.#iso = toIso(value);\n this.origin = wallPosition(wallDay(this.#iso), nsOfTime(this.#iso));\n this.dates = new DateFactory(this.#iso.toPlainDate());\n }\n\n positionOf(value: DateTimeInput): bigint {\n if (!isPlainDateTime(value)) throw mixedTypesError(value);\n const iso = toIso(value);\n return wallPosition(wallDay(iso), nsOfTime(iso));\n }\n\n periods(day: number, intervals: readonly Interval[]): readonly Period[] {\n // Wall-clock intervals of one day are already sorted, disjoint and non-empty.\n return intervals.map(([start, end]) => [wallPosition(day, start), wallPosition(day, end)]);\n }\n\n at(position: bigint): PlainDateTimeLike {\n const day = floorDiv(position, BIG_NS_PER_DAY);\n const fields = wallFields(Number(day), Number(position - day * BIG_NS_PER_DAY));\n return withCalendarId(this.#iso.with(fields), this.#calendarId);\n }\n\n duration(ns: bigint): DurationLike {\n return durationFrom(this.#iso.until(this.#iso as never), ns);\n }\n}\n\n/**\n * A time zone's UTC offset is constant between transitions, so inside such a segment a wall\n * time converts to exact time with integer arithmetic. Segments are shrunk by this margin:\n * UTC offsets differ by at most 26 hours, so a wall time whose instant lies more than 48 hours\n * from any transition can be neither skipped nor repeated, and the arithmetic result is exactly\n * what Temporal's `'compatible'` disambiguation returns.\n */\nconst SEGMENT_MARGIN = 48n * BigInt(NS_PER_HOUR);\nconst FOREVER = 2n ** 100n;\n\ninterface OffsetSegment {\n /** Exact-time bounds `[start, end)`, already shrunk by the margin, with a constant offset. */\n readonly start: bigint;\n readonly end: bigint;\n readonly offset: bigint;\n}\n\n/**\n * How far a ZonedDateTime period can lie from its wall-clock day: UTC offsets span 26 hours\n * and a skipped wall time moves forward by at most a day (Samoa skipped 2011-12-30).\n */\nconst ZONED_LOOKAHEAD = 48n * BigInt(NS_PER_HOUR);\n\nclass ZonedTimeline implements Timeline<ZonedDateTimeLike> {\n readonly origin: bigint;\n readonly lookahead = ZONED_LOOKAHEAD;\n readonly dates: DateFactory;\n readonly #iso: ZonedDateTimeLike;\n readonly #calendarId: string;\n #segment: OffsetSegment | undefined;\n\n constructor(value: ZonedDateTimeLike) {\n this.#calendarId = value.calendarId;\n this.#iso = toIso(value);\n this.origin = this.#iso.epochNanoseconds;\n this.dates = new DateFactory(this.#iso.toPlainDate());\n }\n\n positionOf(value: DateTimeInput): bigint {\n if (!isZonedDateTime(value)) throw mixedTypesError(value);\n return value.epochNanoseconds;\n }\n\n periods(day: number, intervals: readonly Interval[]): readonly Period[] {\n // Skipped wall times move forward, so mapped periods can shrink to nothing, change\n // order or overlap (02:30–02:45 → 03:30–03:45 overlaps 03:00–04:00): normalize.\n return normalizePeriods(intervals.map(([start, end]) => [this.#exact(day, start), this.#exact(day, end)]));\n }\n\n /** Exact time of a wall-clock time; skipped times move forward, repeated times use the earlier. */\n #exact(day: number, ns: number): bigint {\n const wall = wallPosition(day, ns);\n const segment = this.#segment;\n if (segment) {\n const candidate = wall - segment.offset;\n if (candidate >= segment.start && candidate < segment.end) return candidate;\n }\n const d = Number(floorDiv(wall, BIG_NS_PER_DAY)); // normalizes 24:00 to the next day\n const fields = wallFields(d, Number(wall - BigInt(d) * BIG_NS_PER_DAY));\n const zdt = this.#iso.with(fields, { disambiguation: 'compatible', offset: 'ignore' });\n this.#segment = segmentAround(zdt);\n return zdt.epochNanoseconds;\n }\n\n at(position: bigint): ZonedDateTimeLike {\n // Exact-time arithmetic; seconds + nanoseconds keeps every field a safe integer.\n const delta = position - this.origin;\n const result = this.#iso.add({\n seconds: Number(delta / BIG_NS_PER_SECOND),\n nanoseconds: Number(delta % BIG_NS_PER_SECOND),\n });\n return withCalendarId(result, this.#calendarId);\n }\n\n duration(ns: bigint): DurationLike {\n return durationFrom(this.#iso.until(this.#iso as never), ns);\n }\n}\n\n/** The constant-offset segment containing `zdt`, shrunk by SEGMENT_MARGIN next to real transitions. */\nfunction segmentAround(zdt: ZonedDateTimeLike): OffsetSegment {\n // 'previous' is strictly before its receiver: ask from 1 ns later so that a transition at\n // exactly `zdt` (where 'compatible' puts every skipped wall time) is found.\n const previous = zdt.add({ nanoseconds: 1 }).getTimeZoneTransition('previous');\n const next = zdt.getTimeZoneTransition('next');\n return {\n start: previous ? previous.epochNanoseconds + SEGMENT_MARGIN : -FOREVER,\n end: next ? next.epochNanoseconds - SEGMENT_MARGIN : FOREVER,\n offset: BigInt(zdt.offsetNanoseconds),\n };\n}\n\n/** `pending ∪ periods`, sorted and merged. Appends without re-sorting in the common case. */\nfunction addPeriods(pending: Period[], periods: readonly Period[]): Period[] {\n const first = periods[0];\n const last = periods.at(-1);\n if (first === undefined || last === undefined) return pending;\n const pendingFirst = pending[0];\n const pendingLast = pending.at(-1);\n if (pendingFirst === undefined || pendingLast === undefined) return [...periods];\n if (first[0] > pendingLast[1]) return pending.concat(periods);\n if (last[1] < pendingFirst[0]) return periods.concat(pending);\n return normalizePeriods([...pending, ...periods]);\n}\n\nfunction mixedTypesError(value: unknown): TypeError {\n return typeError(`start and end must be the same Temporal type, got ${describe(value)} for end`);\n}\n\n/** Runs `run` with the timeline for `value`'s type. */\nfunction withTimeline<R>(value: DateTimeInput, run: <T>(tl: Timeline<T>) => R): R {\n if (isZonedDateTime(value)) return run(new ZonedTimeline(value));\n if (isPlainDateTime(value)) return run(new PlainTimeline(value));\n throw typeError(\n `expected a Temporal.PlainDateTime or ZonedDateTime, got ${describe(value)}` +\n (isPlainDate(value) ? ' (use the workday functions for dates)' : ''),\n );\n}\n\nfunction noWorkingTimeError(): RangeError {\n return rangeError(`no working time found within ${MAX_SCAN_DAYS} days — check the hours/holiday configuration`);\n}\n\n/**\n * Visits working periods in time order (reverse order when `dir` is -1), starting around\n * `from`, until `visit` returns a value. Days are read ahead into a buffer, and a period is\n * only emitted once no later day can produce an earlier one, so emitted periods are globally\n * sorted and merged even when DST shifts move periods across midnight. Throws when\n * MAX_SCAN_DAYS consecutive days have no working time, instead of looping forever.\n */\nfunction scan<T, R>(\n cal: HoursCalendar,\n tl: Timeline<T>,\n from: bigint,\n dir: 1 | -1,\n visit: (period: Period) => R | undefined,\n): R {\n let pending: Period[] = [];\n let day = Number(floorDiv(from - BigInt(dir) * tl.lookahead, BIG_NS_PER_DAY));\n for (let idle = 0; ; day += dir) {\n const periods = tl.periods(day, intervalsOn(cal, day, tl.dates));\n idle = periods.length === 0 ? idle + 1 : 0;\n if (idle > MAX_SCAN_DAYS) throw noWorkingTimeError();\n pending = addPeriods(pending, periods);\n // Every later day's periods lie beyond this frontier.\n const frontier = dir === 1 ? wallPosition(day + 1, 0) - tl.lookahead : wallPosition(day, 0) + tl.lookahead;\n for (;;) {\n const next = dir === 1 ? pending[0] : pending.at(-1);\n if (next === undefined || (dir === 1 ? next[0] >= frontier : next[1] <= frontier)) break;\n if (dir === 1) pending.shift();\n else pending.pop();\n const result = visit(next);\n if (result !== undefined) return result;\n }\n }\n}\n\n// --- Durations ----------------------------------------------------------------------------\n\nconst CALENDAR_UNITS = ['years', 'months', 'weeks', 'days'] as const;\nconst TIME_UNITS = [\n ['hours', BigInt(NS_PER_HOUR)],\n ['minutes', BigInt(NS_PER_MINUTE)],\n ['seconds', BigInt(NS_PER_SECOND)],\n ['milliseconds', 1_000_000n],\n ['microseconds', 1_000n],\n ['nanoseconds', 1n],\n] as const;\n\n/** Total nanoseconds of a clock-time duration. Calendar units are rejected: they have no fixed length. */\nexport function durationToNs(duration: DurationInput): bigint {\n if (typeof duration !== 'object' || (duration as unknown) === null) {\n throw typeError(`expected a Temporal.Duration or an object like { hours: 4 }, got ${describe(duration)}`);\n }\n let seen = false;\n for (const unit of CALENDAR_UNITS) {\n const value = duration[unit];\n if (value === undefined) continue;\n seen = true;\n if (value !== 0) throw rangeError(`${unit} are not supported in working time; use addWorkdays for whole days`);\n }\n let total = 0n;\n let sign = 0;\n for (const [unit, nsPerUnit] of TIME_UNITS) {\n const value: unknown = duration[unit];\n if (value === undefined) continue;\n seen = true;\n if (typeof value !== 'number' || !Number.isInteger(value)) {\n throw rangeError(`duration ${unit} must be an integer, got ${describe(value)}`);\n }\n if (value === 0) continue;\n if (sign !== 0 && Math.sign(value) !== sign) throw rangeError('duration fields must all have the same sign');\n sign = Math.sign(value);\n total += BigInt(value) * nsPerUnit;\n }\n if (!seen) throw typeError('duration needs at least one of hours, minutes, seconds, … (e.g. { hours: 4 })');\n return total;\n}\n\n/** The duration with every field negated (validated later by durationToNs). */\nfunction negate(duration: DurationInput): DurationInput {\n if (typeof duration !== 'object' || (duration as unknown) === null) return duration;\n const negated: Record<string, unknown> = {};\n for (const unit of [...CALENDAR_UNITS, ...TIME_UNITS.map(([u]) => u)]) {\n const value: unknown = duration[unit];\n negated[unit] = typeof value === 'number' ? -value : value;\n }\n return negated;\n}\n\n// --- Algorithms ---------------------------------------------------------------------------\n// All on positions. `cursor` is the furthest position already accounted for; clipping every\n// period to it makes overlapping periods (possible across DST-shifted days) count once.\n\nfunction isWorkingPosition<T>(cal: HoursCalendar, tl: Timeline<T>, position: bigint): boolean {\n const first = Number(floorDiv(position - tl.lookahead, BIG_NS_PER_DAY));\n const last = Number(floorDiv(position + tl.lookahead, BIG_NS_PER_DAY));\n for (let day = first; day <= last; day++) {\n for (const [start, end] of tl.periods(day, intervalsOn(cal, day, tl.dates))) {\n if (position >= start && position < end) return true;\n }\n }\n return false;\n}\n\nfunction addForward<T>(cal: HoursCalendar, tl: Timeline<T>, total: bigint): T {\n let cursor = tl.origin;\n let remaining = total;\n return scan(cal, tl, tl.origin, 1, ([start, end]) => {\n const from = start > cursor ? start : cursor;\n if (end <= from) return undefined;\n if (remaining <= end - from) return tl.at(from + remaining);\n remaining -= end - from;\n cursor = end;\n return undefined;\n });\n}\n\nfunction addBackward<T>(cal: HoursCalendar, tl: Timeline<T>, total: bigint): T {\n let cursor = tl.origin;\n let remaining = total;\n return scan(cal, tl, tl.origin, -1, ([start, end]) => {\n const to = end < cursor ? end : cursor;\n if (to <= start) return undefined;\n if (remaining <= to - start) return tl.at(to - remaining);\n remaining -= to - start;\n cursor = start;\n return undefined;\n });\n}\n\n/** Working nanoseconds in `[a, b)`, for `a <= b`. */\nfunction workingNsBetween<T>(cal: HoursCalendar, tl: Timeline<T>, a: bigint, b: bigint): bigint {\n let total = 0n;\n let cursor = a;\n scan(cal, tl, a, 1, ([start, end]) => {\n if (start >= b) return true; // periods come in time order: nothing more can overlap\n const from = start > cursor ? start : cursor;\n const to = end < b ? end : b;\n if (to > from) {\n total += to - from;\n cursor = to;\n }\n return undefined;\n });\n return total;\n}\n\nfunction rollForwardPosition<T>(cal: HoursCalendar, tl: Timeline<T>): T | undefined {\n if (isWorkingPosition(cal, tl, tl.origin)) return undefined;\n return scan(cal, tl, tl.origin, 1, ([start]) => (start > tl.origin ? tl.at(start) : undefined));\n}\n\nfunction rollBackwardPosition<T>(cal: HoursCalendar, tl: Timeline<T>): T | undefined {\n if (isWorkingPosition(cal, tl, tl.origin)) return undefined;\n return scan(cal, tl, tl.origin, -1, ([, end]) => (end <= tl.origin ? tl.at(end) : undefined));\n}\n\n// --- Implementations on a compiled calendar (shared with createWorkCalendar) ---------------\n\nexport function isWorkingTimeWith(cal: HoursCalendar, dateTime: DateTimeInput): boolean {\n return withTimeline(dateTime, (tl) => isWorkingPosition(cal, tl, tl.origin));\n}\n\nexport function addWorkingTimeWith<T extends DateTimeInput>(\n cal: HoursCalendar,\n dateTime: T,\n duration: DurationInput,\n): T {\n const total = durationToNs(duration);\n return withTimeline(dateTime, (tl) => {\n if (total === 0n) return dateTime;\n return (total > 0n ? addForward(cal, tl, total) : addBackward(cal, tl, -total)) as unknown as T;\n });\n}\n\nexport function subtractWorkingTimeWith<T extends DateTimeInput>(\n cal: HoursCalendar,\n dateTime: T,\n duration: DurationInput,\n): T {\n return addWorkingTimeWith(cal, dateTime, negate(duration));\n}\n\nexport function workingTimeBetweenWith<T extends DateTimeInput>(cal: HoursCalendar, start: T, end: T): DurationOf<T> {\n return withTimeline(start, (tl) => {\n const a = tl.origin;\n const b = tl.positionOf(end);\n const ns = a <= b ? workingNsBetween(cal, tl, a, b) : -workingNsBetween(cal, tl, b, a);\n return tl.duration(ns) as DurationOf<T>;\n });\n}\n\nexport function rollForwardToWorkingTimeWith<T extends DateTimeInput>(cal: HoursCalendar, dateTime: T): T {\n return withTimeline(dateTime, (tl) => rollForwardPosition(cal, tl) as T | undefined) ?? dateTime;\n}\n\nexport function rollBackwardToWorkingTimeWith<T extends DateTimeInput>(cal: HoursCalendar, dateTime: T): T {\n return withTimeline(dateTime, (tl) => rollBackwardPosition(cal, tl) as T | undefined) ?? dateTime;\n}\n\nexport function getWorkingHoursWith(cal: HoursCalendar, date: DateInput): readonly TimeRangeText[] {\n const dates = new DateFactory(toPlainDate(date));\n return formatDayHours(intervalsOn(cal, dates.epochDay, dates));\n}\n\n// --- Public functions ---------------------------------------------------------------------\n\n/** `true` if `dateTime` is inside working hours (periods are `[start, end)`: 17:00 is not working time in 09:00–17:00). */\nexport function isWorkingTime(dateTime: DateTimeInput, options: WorkingTimeOptions): boolean {\n return isWorkingTimeWith(compileHoursCalendar(options), dateTime);\n}\n\n/**\n * Adds working time: only time inside working hours counts. Negative durations go back.\n * Starting outside working hours, counting begins at the next working period. Landing\n * exactly at the end of a period returns that end (`16:00 + 1h` → `17:00`, not the next morning).\n *\n * The result has the type of the input. For `ZonedDateTime`, elapsed time is exact across DST changes.\n */\nexport function addWorkingTime<T extends DateTimeInput>(\n dateTime: T,\n duration: DurationInput,\n options: WorkingTimeOptions,\n): T {\n return addWorkingTimeWith(compileHoursCalendar(options), dateTime, duration);\n}\n\n/** Subtracts working time. Landing exactly at the start of a period returns that start. */\nexport function subtractWorkingTime<T extends DateTimeInput>(\n dateTime: T,\n duration: DurationInput,\n options: WorkingTimeOptions,\n): T {\n return subtractWorkingTimeWith(compileHoursCalendar(options), dateTime, duration);\n}\n\n/**\n * Working time in `[start, end)` as a `Temporal.Duration` balanced up to hours (e.g. `PT27H30M`);\n * negative when `end` is before `start`. Use `.total('hours')` for a number.\n */\nexport function workingTimeBetween<T extends DateTimeInput>(\n start: T,\n end: NoInfer<T>,\n options: WorkingTimeOptions,\n): DurationOf<T> {\n return workingTimeBetweenWith(compileHoursCalendar(options), start, end);\n}\n\n/** `dateTime` itself if it is working time, otherwise the start of the next working period. */\nexport function rollForwardToWorkingTime<T extends DateTimeInput>(dateTime: T, options: WorkingTimeOptions): T {\n return rollForwardToWorkingTimeWith(compileHoursCalendar(options), dateTime);\n}\n\n/** `dateTime` itself if it is working time, otherwise the end of the previous working period. */\nexport function rollBackwardToWorkingTime<T extends DateTimeInput>(dateTime: T, options: WorkingTimeOptions): T {\n return rollBackwardToWorkingTimeWith(compileHoursCalendar(options), dateTime);\n}\n\n/** The working periods of a date after weekends, holidays and special hours, e.g. `[['09:00', '17:00']]`. */\nexport function getWorkingHours(date: DateInput, options: WorkingTimeOptions): readonly TimeRangeText[] {\n return getWorkingHoursWith(compileHoursCalendar(options), date);\n}\n","// Day-level API: which dates are workdays, and stepping/counting by workdays.\n\nimport {\n compileDayCalendar,\n countWorkdays,\n isHolidayDay,\n isWeekendDay,\n isWorkdayDay,\n stepWorkdays,\n type DayCalendar,\n} from './day-calendar.js';\nimport { describe, rangeError } from './errors.js';\nimport { DateFactory, toPlainDate } from './temporal.js';\nimport type { DateInput, WorkdayOptions } from './types.js';\n\nfunction shiftDays<T extends DateInput>(date: T, days: number): T {\n return (days === 0 ? date : date.add({ days })) as T;\n}\n\nfunction checkAmount(amount: unknown): asserts amount is number {\n if (!Number.isSafeInteger(amount)) throw rangeError(`amount must be an integer, got ${describe(amount)}`);\n}\n\n// --- Implementations on a compiled calendar (shared with createWorkCalendar) ---------------\n\nexport function isWeekendWith(cal: DayCalendar, date: DateInput): boolean {\n return isWeekendDay(cal, new DateFactory(toPlainDate(date)).epochDay);\n}\n\nexport function isHolidayWith(cal: DayCalendar, date: DateInput): boolean {\n const dates = new DateFactory(toPlainDate(date));\n return isHolidayDay(cal, dates.epochDay, dates);\n}\n\nexport function isWorkdayWith(cal: DayCalendar, date: DateInput): boolean {\n const dates = new DateFactory(toPlainDate(date));\n return isWorkdayDay(cal, dates.epochDay, dates);\n}\n\nexport function addWorkdaysWith<T extends DateInput>(cal: DayCalendar, date: T, amount: number): T {\n checkAmount(amount);\n const dates = new DateFactory(toPlainDate(date));\n if (amount === 0) return date;\n const target = stepWorkdays(cal, dates.epochDay, Math.abs(amount), amount > 0 ? 1 : -1, dates);\n return shiftDays(date, target - dates.epochDay);\n}\n\nexport function subtractWorkdaysWith<T extends DateInput>(cal: DayCalendar, date: T, amount: number): T {\n checkAmount(amount);\n return addWorkdaysWith(cal, date, -amount);\n}\n\nexport function nextWorkdayWith<T extends DateInput>(cal: DayCalendar, date: T): T {\n const dates = new DateFactory(toPlainDate(date));\n return shiftDays(date, stepWorkdays(cal, dates.epochDay, 1, 1, dates) - dates.epochDay);\n}\n\nexport function previousWorkdayWith<T extends DateInput>(cal: DayCalendar, date: T): T {\n const dates = new DateFactory(toPlainDate(date));\n return shiftDays(date, stepWorkdays(cal, dates.epochDay, 1, -1, dates) - dates.epochDay);\n}\n\nexport function rollForwardWith<T extends DateInput>(cal: DayCalendar, date: T): T {\n return isWorkdayWith(cal, date) ? date : nextWorkdayWith(cal, date);\n}\n\nexport function rollBackwardWith<T extends DateInput>(cal: DayCalendar, date: T): T {\n return isWorkdayWith(cal, date) ? date : previousWorkdayWith(cal, date);\n}\n\nexport function workdaysBetweenWith(cal: DayCalendar, start: DateInput, end: DateInput): number {\n const a = new DateFactory(toPlainDate(start));\n const endDay = new DateFactory(toPlainDate(end)).epochDay;\n return countWorkdays(cal, a.epochDay, endDay, a);\n}\n\nexport function* eachWorkdayWith<T extends DateInput>(cal: DayCalendar, start: T, end: DateInput): Generator<T, void> {\n const dates = new DateFactory(toPlainDate(start));\n const endDay = new DateFactory(toPlainDate(end)).epochDay;\n for (let day = dates.epochDay; day <= endDay; day++) {\n if (isWorkdayDay(cal, day, dates)) yield shiftDays(start, day - dates.epochDay);\n }\n}\n\n// --- Public functions ---------------------------------------------------------------------\n\n/** `true` if the date falls on a configured weekend day (ignores holidays and `extraWorkdays`). */\nexport function isWeekend(date: DateInput, options?: WorkdayOptions): boolean {\n return isWeekendWith(compileDayCalendar(options), date);\n}\n\n/** `true` if the date is a configured holiday and not listed in `extraWorkdays`. */\nexport function isHoliday(date: DateInput, options?: WorkdayOptions): boolean {\n return isHolidayWith(compileDayCalendar(options), date);\n}\n\n/** `true` if the date is a working day: not a weekend day and not a holiday, or listed in `extraWorkdays`. */\nexport function isWorkday(date: DateInput, options?: WorkdayOptions): boolean {\n return isWorkdayWith(compileDayCalendar(options), date);\n}\n\n/**\n * Adds `amount` workdays (negative to go back). The result has the same type as the input,\n * and time of day / time zone are preserved. `amount = 0` returns the input unchanged.\n * Starting on a non-workday, `+1` gives the next workday.\n */\nexport function addWorkdays<T extends DateInput>(date: T, amount: number, options?: WorkdayOptions): T {\n return addWorkdaysWith(compileDayCalendar(options), date, amount);\n}\n\n/** Subtracts `amount` workdays. Same as `addWorkdays(date, -amount)`. */\nexport function subtractWorkdays<T extends DateInput>(date: T, amount: number, options?: WorkdayOptions): T {\n return subtractWorkdaysWith(compileDayCalendar(options), date, amount);\n}\n\n/** The first workday strictly after `date`. */\nexport function nextWorkday<T extends DateInput>(date: T, options?: WorkdayOptions): T {\n return nextWorkdayWith(compileDayCalendar(options), date);\n}\n\n/** The last workday strictly before `date`. */\nexport function previousWorkday<T extends DateInput>(date: T, options?: WorkdayOptions): T {\n return previousWorkdayWith(compileDayCalendar(options), date);\n}\n\n/** `date` itself if it is a workday, otherwise the next workday after it. */\nexport function rollForward<T extends DateInput>(date: T, options?: WorkdayOptions): T {\n return rollForwardWith(compileDayCalendar(options), date);\n}\n\n/** `date` itself if it is a workday, otherwise the previous workday before it. */\nexport function rollBackward<T extends DateInput>(date: T, options?: WorkdayOptions): T {\n return rollBackwardWith(compileDayCalendar(options), date);\n}\n\n/**\n * Number of workdays after `start` up to and including `end` — the range `(start, end]`.\n * Negative when `end` is before `start`. Only calendar dates matter; times are ignored.\n *\n * For `amount >= 0`: `workdaysBetween(d, addWorkdays(d, amount)) === amount`.\n */\nexport function workdaysBetween(start: DateInput, end: DateInput, options?: WorkdayOptions): number {\n return workdaysBetweenWith(compileDayCalendar(options), start, end);\n}\n\n/**\n * Yields every workday from `start` to `end`, both inclusive, in ascending order.\n * Values have the type of `start` (time of day / zone preserved). Yields nothing if `end < start`.\n */\nexport function eachWorkday<T extends DateInput>(\n start: T,\n end: DateInput,\n options?: WorkdayOptions,\n): Generator<T, void> {\n // Compile eagerly so that invalid options throw at the call, not on the first next().\n return eachWorkdayWith(compileDayCalendar(options), start, end);\n}\n","import { checkOptionsObject, compileDayCalendar, isIterable } from './day-calendar.js';\nimport {\n addWorkingTimeWith,\n compileHoursCalendar,\n getWorkingHoursWith,\n isWorkingTimeWith,\n rollBackwardToWorkingTimeWith,\n rollForwardToWorkingTimeWith,\n subtractWorkingTimeWith,\n workingTimeBetweenWith,\n} from './hours.js';\nimport type {\n DateInput,\n DateTimeInput,\n DurationInput,\n DurationOf,\n TimeRangeText,\n WorkdayOptions,\n WorkingTimeOptions,\n} from './types.js';\nimport {\n addWorkdaysWith,\n eachWorkdayWith,\n isHolidayWith,\n isWeekendWith,\n isWorkdayWith,\n nextWorkdayWith,\n previousWorkdayWith,\n rollBackwardWith,\n rollForwardWith,\n subtractWorkdaysWith,\n workdaysBetweenWith,\n} from './workdays.js';\n\n/** Workday helpers bound to one configuration. See the standalone functions for details. */\nexport interface WorkCalendar {\n /** A frozen snapshot of the options the calendar was created with. */\n readonly options: Readonly<WorkdayOptions>;\n isWorkday(date: DateInput): boolean;\n isWeekend(date: DateInput): boolean;\n isHoliday(date: DateInput): boolean;\n addWorkdays<T extends DateInput>(date: T, amount: number): T;\n subtractWorkdays<T extends DateInput>(date: T, amount: number): T;\n nextWorkday<T extends DateInput>(date: T): T;\n previousWorkday<T extends DateInput>(date: T): T;\n rollForward<T extends DateInput>(date: T): T;\n rollBackward<T extends DateInput>(date: T): T;\n workdaysBetween(start: DateInput, end: DateInput): number;\n eachWorkday<T extends DateInput>(start: T, end: DateInput): Generator<T, void>;\n}\n\n/** A calendar created with `hours`: workday helpers plus working-time helpers. */\nexport interface WorkTimeCalendar extends WorkCalendar {\n readonly options: Readonly<WorkingTimeOptions>;\n isWorkingTime(dateTime: DateTimeInput): boolean;\n addWorkingTime<T extends DateTimeInput>(dateTime: T, duration: DurationInput): T;\n subtractWorkingTime<T extends DateTimeInput>(dateTime: T, duration: DurationInput): T;\n workingTimeBetween<T extends DateTimeInput>(start: T, end: NoInfer<T>): DurationOf<T>;\n rollForwardToWorkingTime<T extends DateTimeInput>(dateTime: T): T;\n rollBackwardToWorkingTime<T extends DateTimeInput>(dateTime: T): T;\n getWorkingHours(date: DateInput): readonly TimeRangeText[];\n}\n\n/**\n * Creates helpers bound to one configuration. The options are validated and read\n * immediately (holidays and hours are parsed once), so later changes to the passed-in\n * arrays don't affect the calendar. Prefer this over the standalone functions when the\n * same configuration is used repeatedly. With `hours`, the working-time helpers are included.\n */\nexport function createWorkCalendar(options: WorkingTimeOptions): WorkTimeCalendar;\nexport function createWorkCalendar(options?: WorkdayOptions): WorkCalendar;\nexport function createWorkCalendar(options: WorkdayOptions | WorkingTimeOptions = {}): WorkCalendar {\n checkOptionsObject(options);\n const snapshot = snapshotOptions(options);\n const days = compileDayCalendar(snapshot);\n const calendar: WorkCalendar = {\n options: snapshot,\n isWorkday: (date) => isWorkdayWith(days, date),\n isWeekend: (date) => isWeekendWith(days, date),\n isHoliday: (date) => isHolidayWith(days, date),\n addWorkdays: (date, amount) => addWorkdaysWith(days, date, amount),\n subtractWorkdays: (date, amount) => subtractWorkdaysWith(days, date, amount),\n nextWorkday: (date) => nextWorkdayWith(days, date),\n previousWorkday: (date) => previousWorkdayWith(days, date),\n rollForward: (date) => rollForwardWith(days, date),\n rollBackward: (date) => rollBackwardWith(days, date),\n workdaysBetween: (start, end) => workdaysBetweenWith(days, start, end),\n eachWorkday: (start, end) => eachWorkdayWith(days, start, end),\n };\n if (!hasHours(snapshot)) return Object.freeze(calendar);\n\n const hours = compileHoursCalendar(snapshot);\n return Object.freeze({\n ...calendar,\n options: snapshot,\n isWorkingTime: (dateTime) => isWorkingTimeWith(hours, dateTime),\n addWorkingTime: (dateTime, duration) => addWorkingTimeWith(hours, dateTime, duration),\n subtractWorkingTime: (dateTime, duration) => subtractWorkingTimeWith(hours, dateTime, duration),\n workingTimeBetween: (start, end) => workingTimeBetweenWith(hours, start, end),\n rollForwardToWorkingTime: (dateTime) => rollForwardToWorkingTimeWith(hours, dateTime),\n rollBackwardToWorkingTime: (dateTime) => rollBackwardToWorkingTimeWith(hours, dateTime),\n getWorkingHours: (date) => getWorkingHoursWith(hours, date),\n } satisfies WorkTimeCalendar);\n}\n\nfunction hasHours(options: WorkdayOptions): options is WorkingTimeOptions {\n return (options as Partial<WorkingTimeOptions>).hours !== undefined;\n}\n\n/**\n * Copies iterables into frozen arrays so the calendar is immune to later mutation.\n * Anything else is passed through unchanged for the compilers to reject.\n */\nfunction snapshotOptions<O extends WorkdayOptions>(options: O): Readonly<O> {\n const copy = <V>(value: V): V => (isIterable(value) ? (Object.freeze(Array.from(value)) as V) : value);\n return Object.freeze({\n ...options,\n weekend: copy(options.weekend),\n holidays: copy(options.holidays),\n extraWorkdays: copy(options.extraWorkdays),\n });\n}\n","// Adapter for the `date-holidays` package (https://www.npmjs.com/package/date-holidays).\n//\n// It is duck-typed, so this library does not depend on date-holidays. Holidays are read\n// from `getHolidays(year)` and its `date` strings (\"2026-12-24 14:00:00\"), which give the\n// local date and time in the holiday's own region whatever the machine's time zone is.\n// (`isHoliday(date)` is avoided: it interprets dates in the machine's time zone.)\n\nimport { epochDayFromIso, floorDiv } from './epoch.js';\nimport { describe, rangeError, typeError } from './errors.js';\nimport { epochDayOf, toIsoDate } from './temporal.js';\nimport {\n formatDayHours,\n type Interval,\n NS_PER_DAY,\n NS_PER_HOUR,\n NS_PER_MINUTE,\n parseDayHours,\n subtractInterval,\n} from './time.js';\nimport type { HolidayPredicate, PlainDateLike, SpecialHoursFunction, TimeRangeText } from './types.js';\n\n/** The parts of a `date-holidays` holiday this adapter uses. */\nexport interface DateHolidaysEntry {\n /** Local start, `'YYYY-MM-DD hh:mm:ss'`, optionally with a `' -0600'`-style shift (eve-start holidays). */\n readonly date: string;\n /** `'public'`, `'bank'`, `'school'`, `'optional'` or `'observance'`. */\n readonly type: string;\n readonly start: Date;\n readonly end: Date;\n}\n\n/** The parts of a `date-holidays` `Holidays` instance this adapter uses. */\nexport interface DateHolidaysSource {\n getHolidays(year: number): readonly DateHolidaysEntry[];\n}\n\nexport interface FromDateHolidaysOptions {\n /** Holiday types that close the business. Default `['public']`. */\n readonly types?: readonly string[] | undefined;\n}\n\n/** Spread into calendar options: `createWorkCalendar({ ...fromDateHolidays(hd), hours })`. */\nexport interface DateHolidaysOptions {\n /** `true` for dates that a holiday covers completely. */\n readonly holidays: HolidayPredicate;\n /** Regular hours minus partial-day closures (e.g. closing at 14:00 on Christmas Eve). */\n readonly specialHours: SpecialHoursFunction;\n}\n\nconst ENTRY_DATE_RE = /^(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})(?: ([+-])(\\d{2})(\\d{2}))?$/;\nconst DAY = BigInt(NS_PER_DAY);\n/** Holidays spanning a DST change last 23 or 25 hours; ends this close to midnight snap to it. */\nconst SNAP = 90n * BigInt(NS_PER_MINUTE);\n\n/** What the loaded holidays cover. */\ninterface Coverage {\n /** Dates covered completely, as epoch days. */\n readonly full: Set<number>;\n /** Partial closures per epoch day, in nanoseconds since midnight. */\n readonly partial: Map<number, Interval[]>;\n}\n\n/** The holiday as a wall-clock span `[start, end)` in nanoseconds since 1970-01-01T00:00 (wall). */\nfunction wallSpan(entry: DateHolidaysEntry): [bigint, bigint] {\n const m = ENTRY_DATE_RE.exec(entry.date);\n if (!m) throw rangeError(`unexpected date-holidays date ${describe(entry.date)}`);\n const n = (i: number): number => Number(m[i]);\n const shiftSign = m[7] === '-' ? -1 : 1;\n const shift = m[7] === undefined ? 0 : shiftSign * (n(8) * NS_PER_HOUR + n(9) * NS_PER_MINUTE);\n const timeNs = n(4) * NS_PER_HOUR + n(5) * NS_PER_MINUTE + n(6) * 1_000_000_000 + shift;\n const start = BigInt(epochDayFromIso(n(1), n(2), n(3))) * DAY + BigInt(timeNs);\n const durationMs = entry.end.getTime() - entry.start.getTime();\n if (!Number.isFinite(durationMs) || durationMs <= 0) {\n throw rangeError(`date-holidays entry ${describe(entry.date)} has no valid start/end`);\n }\n let end = start + BigInt(durationMs) * 1_000_000n;\n const nearestMidnight = floorDiv(end + DAY / 2n, DAY) * DAY;\n const distance = end - nearestMidnight;\n if (distance !== 0n && distance > -SNAP && distance < SNAP) end = nearestMidnight;\n return [start, end];\n}\n\nfunction addSpan(data: Coverage, [start, end]: [bigint, bigint]): void {\n for (let day = floorDiv(start, DAY); day * DAY < end; day++) {\n const dayStart = day * DAY;\n const from = start > dayStart ? start - dayStart : 0n;\n const to = end < dayStart + DAY ? end - dayStart : DAY;\n const epochDay = Number(day);\n if (from === 0n && to === DAY) {\n data.full.add(epochDay);\n } else {\n const list = data.partial.get(epochDay) ?? [];\n list.push([Number(from), Number(to)]);\n data.partial.set(epochDay, list);\n }\n }\n}\n\n/**\n * Turns a `date-holidays` instance into `holidays` and `specialHours` options:\n *\n * ```ts\n * import Holidays from 'date-holidays';\n * const cal = createWorkCalendar({\n * ...fromDateHolidays(new Holidays('DE', 'BY'), { types: ['public', 'bank'] }),\n * hours: [['09:00', '17:00']],\n * });\n * ```\n *\n * Days a holiday covers completely are holidays. Days it covers partly (Christmas Eve from\n * 14:00) stay workdays with reduced hours. Holidays that `date-holidays` starts on the\n * evening before (Hijri and Hebrew calendar holidays) are taken as it reports them.\n * Results are cached per year.\n */\nexport function fromDateHolidays(\n source: DateHolidaysSource,\n options: FromDateHolidaysOptions = {},\n): DateHolidaysOptions {\n if (typeof (source as Partial<DateHolidaysSource> | null)?.getHolidays !== 'function') {\n throw typeError(`expected a date-holidays instance (with getHolidays), got ${describe(source)}`);\n }\n const typesOption: unknown = options.types ?? ['public'];\n if (!Array.isArray(typesOption) || !typesOption.every((t) => typeof t === 'string')) {\n throw typeError(`types must be an array of strings, got ${describe(typesOption)}`);\n }\n const types = new Set<string>(typesOption);\n\n const loaded = new Set<number>();\n const known: Coverage = { full: new Set(), partial: new Map() };\n // A holiday dated in one year can reach into the previous one (eve-start on Jan 1) or the next.\n const ensure = (date: PlainDateLike): number => {\n const iso = toIsoDate(date);\n for (const year of [iso.year - 1, iso.year, iso.year + 1]) {\n if (loaded.has(year)) continue;\n loaded.add(year);\n for (const entry of source.getHolidays(year)) {\n if (types.has(entry.type)) addSpan(known, wallSpan(entry));\n }\n }\n return epochDayOf(iso);\n };\n\n return {\n holidays: (date) => known.full.has(ensure(date)),\n specialHours: (date, regular: readonly TimeRangeText[]) => {\n const day = ensure(date);\n if (known.full.has(day)) return undefined;\n const closures = known.partial.get(day);\n if (!closures) return undefined;\n let open = parseDayHours(regular, 'regular hours');\n for (const [from, to] of closures) open = subtractInterval(open, from, to);\n return formatDayHours(open);\n },\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,96 @@
1
1
  {
2
2
  "name": "temporal-workdays",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Business days and business hours for the JavaScript Temporal API: add workdays, add working time (SLA), count both, with weekends, holidays, breaks, half days and date-holidays support. Exact across DST. Zero dependencies.",
5
+ "keywords": [
6
+ "temporal",
7
+ "business-days",
8
+ "business-hours",
9
+ "workdays",
10
+ "working-days",
11
+ "working-hours",
12
+ "sla",
13
+ "holidays",
14
+ "date-holidays",
15
+ "weekend",
16
+ "date",
17
+ "calendar",
18
+ "plaindate",
19
+ "zoneddatetime",
20
+ "dst"
21
+ ],
22
+ "license": "MIT",
23
+ "author": "Akash Gupta",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/akashgupta1909/temporal-workdays.git"
27
+ },
28
+ "homepage": "https://github.com/akashgupta1909/temporal-workdays#readme",
29
+ "bugs": {
30
+ "url": "https://github.com/akashgupta1909/temporal-workdays/issues"
31
+ },
32
+ "type": "module",
33
+ "sideEffects": false,
34
+ "main": "./dist/index.cjs",
35
+ "module": "./dist/index.js",
36
+ "types": "./dist/index.d.ts",
37
+ "exports": {
38
+ ".": {
39
+ "import": {
40
+ "types": "./dist/index.d.ts",
41
+ "default": "./dist/index.js"
42
+ },
43
+ "require": {
44
+ "types": "./dist/index.d.cts",
45
+ "default": "./dist/index.cjs"
46
+ }
47
+ },
48
+ "./package.json": "./package.json"
49
+ },
50
+ "files": [
51
+ "CHANGELOG.md",
52
+ "dist",
53
+ "README.md",
54
+ "LICENSE"
55
+ ],
56
+ "engines": {
57
+ "node": ">=18"
58
+ },
59
+ "scripts": {
60
+ "build": "tsup",
61
+ "test": "vitest run --coverage",
62
+ "test:watch": "vitest",
63
+ "test:smoke": "node test/smoke/smoke.mjs",
64
+ "typecheck": "tsc",
65
+ "lint": "eslint .",
66
+ "format": "prettier --write .",
67
+ "format:check": "prettier --check .",
68
+ "size": "size-limit",
69
+ "lint:pkg": "publint && attw --pack .",
70
+ "check": "npm run typecheck && npm run lint && npm run format:check && npm test && npm run build && npm run test:consumer && npm run lint:pkg && npm run size && npm run test:smoke",
71
+ "prepublishOnly": "npm run check",
72
+ "test:consumer": "tsc -p test/consumer"
73
+ },
74
+ "devDependencies": {
75
+ "@arethetypeswrong/cli": "^0.18.5",
76
+ "@eslint/js": "^10.0.1",
77
+ "@size-limit/preset-small-lib": "^14.3.0",
78
+ "@types/node": "^22.20.5",
79
+ "@vitest/coverage-v8": "^5.1.0",
80
+ "date-holidays": "^3.38.1",
81
+ "eslint": "^10.14.0",
82
+ "eslint-config-prettier": "^10.1.8",
83
+ "fast-check": "^4.10.2",
84
+ "prettier": "^3.9.10",
85
+ "publint": "^0.3.25",
86
+ "size-limit": "^14.3.0",
87
+ "temporal-polyfill": "^1.0.8",
88
+ "tsup": "^9.0.0",
89
+ "typescript": "^6.0.3",
90
+ "typescript-eslint": "^8.72.1",
91
+ "vitest": "^5.1.0"
92
+ },
93
+ "overrides": {
94
+ "minimatch": "^11.0.1"
95
+ }
96
+ }