temporal-fmt 0.9.3 → 0.9.4

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.
Files changed (100) hide show
  1. package/README.md +314 -8
  2. package/dist/calendarUtils.cjs +259 -4
  3. package/dist/calendarUtils.cjs.map +1 -1
  4. package/dist/calendarUtils.js +33 -1
  5. package/dist/chunk-4N3WCGEY.js +183 -0
  6. package/dist/{chunk-SSPABEUR.js.map → chunk-4N3WCGEY.js.map} +1 -1
  7. package/dist/chunk-5UTV5VP6.js +984 -0
  8. package/dist/chunk-5UTV5VP6.js.map +1 -0
  9. package/dist/chunk-ACKKWH5Z.js +578 -0
  10. package/dist/{chunk-2JHEV7ZF.js.map → chunk-ACKKWH5Z.js.map} +1 -1
  11. package/dist/chunk-EGUUO6LE.js +439 -0
  12. package/dist/chunk-EGUUO6LE.js.map +1 -0
  13. package/dist/chunk-FBPHNRVW.js +2939 -0
  14. package/dist/chunk-FBPHNRVW.js.map +1 -0
  15. package/dist/chunk-GPB4JHGI.js +65 -0
  16. package/dist/chunk-GPB4JHGI.js.map +1 -0
  17. package/dist/chunk-H7YQX25T.js +170 -0
  18. package/dist/{chunk-J2AQNXF2.js.map → chunk-H7YQX25T.js.map} +1 -1
  19. package/dist/chunk-HXY2GUUM.js +182 -0
  20. package/dist/{chunk-EHLRZULM.js.map → chunk-HXY2GUUM.js.map} +1 -1
  21. package/dist/chunk-L24NPTAJ.js +328 -0
  22. package/dist/{chunk-GMGZZG6I.js.map → chunk-L24NPTAJ.js.map} +1 -1
  23. package/dist/chunk-M3GDTHMT.js +169 -0
  24. package/dist/chunk-M3GDTHMT.js.map +1 -0
  25. package/dist/chunk-MKPDLQKD.js +51 -0
  26. package/dist/chunk-MKPDLQKD.js.map +1 -0
  27. package/dist/chunk-TSLPIURC.js +242 -0
  28. package/dist/{chunk-VQXUMFB2.js.map → chunk-TSLPIURC.js.map} +1 -1
  29. package/dist/chunk-UOPAV3WX.js +75 -0
  30. package/dist/chunk-UOPAV3WX.js.map +1 -0
  31. package/dist/chunk-VNIUIQA4.js +398 -0
  32. package/dist/chunk-VNIUIQA4.js.map +1 -0
  33. package/dist/chunk-YEUASGDK.js +9 -0
  34. package/dist/chunk-YEUASGDK.js.map +1 -0
  35. package/dist/chunk-ZQZF5EXW.js +29 -0
  36. package/dist/chunk-ZQZF5EXW.js.map +1 -0
  37. package/dist/config.d.cts +4 -2
  38. package/dist/config.d.ts +4 -2
  39. package/dist/duration.cjs +638 -26
  40. package/dist/duration.cjs.map +1 -1
  41. package/dist/duration.js +28 -1
  42. package/dist/format.cjs +833 -35
  43. package/dist/format.cjs.map +1 -1
  44. package/dist/format.js +20 -1
  45. package/dist/index.cjs +7698 -163
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +108 -24
  48. package/dist/index.d.ts +108 -24
  49. package/dist/index.js +1536 -58
  50. package/dist/index.js.map +1 -1
  51. package/dist/interval.cjs +5480 -35
  52. package/dist/interval.cjs.map +1 -1
  53. package/dist/interval.js +46 -1
  54. package/dist/localeRegistry.cjs +375 -32
  55. package/dist/localeRegistry.cjs.map +1 -1
  56. package/dist/localeRegistry.js +11 -1
  57. package/dist/modApi.d.cts +131 -0
  58. package/dist/modApi.d.ts +131 -0
  59. package/dist/parse.cjs +1797 -70
  60. package/dist/parse.cjs.map +1 -1
  61. package/dist/parse.js +20 -1
  62. package/dist/recurrence.cjs +452 -20
  63. package/dist/recurrence.cjs.map +1 -1
  64. package/dist/recurrence.js +19 -1
  65. package/dist/relativeTime.cjs +268 -21
  66. package/dist/relativeTime.cjs.map +1 -1
  67. package/dist/relativeTime.js +14 -1
  68. package/dist/runtime.d.cts +201 -0
  69. package/dist/runtime.d.ts +201 -0
  70. package/dist/timezone.cjs +387 -20
  71. package/dist/timezone.cjs.map +1 -1
  72. package/dist/timezone.js +26 -1
  73. package/package.json +4 -6
  74. package/scripts/cli.mjs +27 -5
  75. package/dist/chunk-2JHEV7ZF.js +0 -7
  76. package/dist/chunk-3MZLTVP3.js +0 -2
  77. package/dist/chunk-3MZLTVP3.js.map +0 -1
  78. package/dist/chunk-4JDAJSEM.js +0 -35
  79. package/dist/chunk-4JDAJSEM.js.map +0 -1
  80. package/dist/chunk-4XRE37WT.js +0 -2
  81. package/dist/chunk-4XRE37WT.js.map +0 -1
  82. package/dist/chunk-5U5WJ465.js +0 -36
  83. package/dist/chunk-5U5WJ465.js.map +0 -1
  84. package/dist/chunk-C6ZZ62ET.js +0 -2
  85. package/dist/chunk-C6ZZ62ET.js.map +0 -1
  86. package/dist/chunk-EHLRZULM.js +0 -5
  87. package/dist/chunk-GMGZZG6I.js +0 -2
  88. package/dist/chunk-J2AQNXF2.js +0 -2
  89. package/dist/chunk-NPKJ7QFK.js +0 -7
  90. package/dist/chunk-NPKJ7QFK.js.map +0 -1
  91. package/dist/chunk-R4YEFOVE.js +0 -2
  92. package/dist/chunk-R4YEFOVE.js.map +0 -1
  93. package/dist/chunk-SSPABEUR.js +0 -11
  94. package/dist/chunk-UJR6DHXY.js +0 -2
  95. package/dist/chunk-UJR6DHXY.js.map +0 -1
  96. package/dist/chunk-VQXUMFB2.js +0 -21
  97. package/dist/chunk-XH46JNPK.js +0 -2
  98. package/dist/chunk-XH46JNPK.js.map +0 -1
  99. package/dist/chunk-ZGMTY52O.js +0 -2
  100. package/dist/chunk-ZGMTY52O.js.map +0 -1
@@ -1,7 +0,0 @@
1
- import{b as d}from"./chunk-GMGZZG6I.js";import{b as c,c as p,k as l}from"./chunk-5U5WJ465.js";var h=d.map(([n])=>n).sort((n,t)=>t.length-n.length);function N(n){let t=[],e=0;for(;e<n.length;){let o=n[e];if(o==="'"){if(n[e+1]==="'"){a(t,"'"),e+=2;continue}let r=e+1,s="",u=!1;for(;r<n.length;){if(n[r]==="'"){if(n[r+1]==="'"){s+="'",r+=2;continue}u=!0,r+=1;break}s+=n[r],r+=1}if(!u)throw new c({format:n,message:`temporal-fmt: unterminated quote in format string "${n}"`});a(t,s),e=r;continue}let i=h.find(r=>n.startsWith(r,e));if(i){let r=i[i.length-1];if(n[e+i.length]===r){let s=e+i.length;for(;n[s]===r;)s+=1;throw new p({format:n,token:n.slice(e,s),message:`temporal-fmt: "${n.slice(e,s)}" in format string "${n}" isn't a recognized token \u2014 did you mean "${i}"?`})}t.push({kind:"token",value:i}),e+=i.length;continue}a(t,o),e+=1}return t}function a(n,t){let e=n[n.length-1];e&&e.kind==="literal"?e.value+=t:n.push({kind:"literal",value:t})}var g=new Set(["latn","arab","deva","beng","guru","gujr","orya","tamldec","telu","knda","mlym","fullwide","hanidec"]),m=new Map;function f(n){let t=m.get(n);if(t)return t;/* c8 ignore start @preserve -- dead by construction, not just
2
- untested: both callers (convertDigits, convertDigitsToAscii) already
3
- return early on system === 'latn' before calling getDigitMap at all,
4
- so this function is never invoked with 'latn'. Kept as a defensive
5
- fallback rather than trusting that stays true for any future
6
- caller. */if(n==="latn"){t={};for(let e=0;e<10;e++)t[String(e)]=String(e)}else{/* c8 ignore stop @preserve */let e=new Intl.NumberFormat("en-US-u-nu-"+n,{useGrouping:!1});t={};for(let o=0;o<10;o++)t[String(o)]=e.format(o)}return m.set(n,t),t}function S(n,t){if(t==="latn")return n;if(!g.has(t))throw new l({actual:t,reason:`numbering system "${t}" is not supported. Supported: ${[...g].join(", ")}.`});let e=f(t),o="";for(let i of n)i>="0"&&i<="9"?o+=e[i]??i:o+=i;return o}function b(n,t){if(t==="latn")return n;if(!g.has(t))throw new l({actual:t,reason:`numbering system "${t}" is not supported.`});let e=f(t),o={};for(let r of Object.keys(e))o[e[r]]=r;let i="";for(let r of n)i+=o[r]??r;return i}function O(n,t){let e=t.numberingSystem??"latn";return e==="latn"?n:S(n,e)}function v(n,t){let e=t.parseNumberingSystem??"latn";return e==="latn"?n:b(n,e)}export{N as a,g as b,S as c,b as d,O as e,v as f};
7
- //# sourceMappingURL=chunk-NPKJ7QFK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/tokenize.ts","../src/numbering.ts"],"sourcesContent":["import { TOKENS } from './tokens.js';\nimport { FormatSyntaxError, UnknownTokenError } from './errors.js';\n\nexport type Piece =\n | { kind: 'token'; value: string }\n | { kind: 'literal'; value: string };\n\n// longest-first so the greedy scan never matches \"M\" when \"MMMM\" was there\nconst SORTED_TOKEN_STRINGS = TOKENS.map(([tok]) => tok).sort((a, b) => b.length - a.length);\n\n/**\n * Splits a format string like `\"yyyy-MM-dd 'at' HH:mm\"` into token/literal\n * pieces. Text in single quotes is always literal (e.g. write 'rd' in\n * \"3rd\" so it's not read as the day token). A doubled quote ('') means a\n * literal quote character, both inside a quoted span and standalone.\n */\nexport function tokenize(format: string): Piece[] {\n const pieces: Piece[] = [];\n let i = 0;\n\n while (i < format.length) {\n const ch = format[i];\n\n if (ch === \"'\") {\n // check doubled-quote first or \"''best''\" parses wrong\n if (format[i + 1] === \"'\") {\n appendLiteral(pieces, \"'\");\n i += 2;\n continue;\n }\n\n let j = i + 1;\n let literal = '';\n let closed = false;\n while (j < format.length) {\n if (format[j] === \"'\") {\n if (format[j + 1] === \"'\") {\n literal += \"'\";\n j += 2;\n continue;\n }\n closed = true;\n j += 1;\n break;\n }\n literal += format[j];\n j += 1;\n }\n\n if (!closed) {\n throw new FormatSyntaxError({\n format,\n message: `temporal-fmt: unterminated quote in format string \"${format}\"`,\n });\n }\n\n appendLiteral(pieces, literal);\n i = j;\n continue;\n }\n\n const match = SORTED_TOKEN_STRINGS.find((tok) => format.startsWith(tok, i));\n if (match) {\n // match is already the longest registered token starting at i, so\n // one more of its last character can't be a token of its own —\n // it'd fall through to whatever token or literal rule handles that\n // character next, silently splicing an unrelated field onto this\n // one (e.g. \"zzzz\" used to read as zzz + literal \"z\", \"MMMMM\" as\n // MMMM + the numeric-month token M). Treat the whole overlong run\n // as one unrecognized token instead.\n const runChar = match[match.length - 1];\n if (format[i + match.length] === runChar) {\n let end = i + match.length;\n while (format[end] === runChar) end += 1;\n // UnknownTokenError, not FormatSyntaxError: wrapUntypedError's\n // classifier already treats this exact message (\"isn't a\n // recognized token\") as UNKNOWN_TOKEN (see errors.test.js's\n // \"overlong token run classifies as UnknownTokenError\"), and a\n // direct throw here needs to agree with what safeParse's fallback\n // path would have classified it as.\n throw new UnknownTokenError({\n format,\n token: format.slice(i, end),\n message:\n `temporal-fmt: \"${format.slice(i, end)}\" in format string \"${format}\" isn't a recognized token — ` +\n `did you mean \"${match}\"?`,\n });\n }\n pieces.push({ kind: 'token', value: match });\n i += match.length;\n continue;\n }\n\n // not a token or quote — pass through as-is\n appendLiteral(pieces, ch);\n i += 1;\n }\n\n return pieces;\n}\n\n// merges into the previous piece if it's also a literal, so \"---\" is one\n// piece instead of three\nfunction appendLiteral(pieces: Piece[], value: string): void {\n const last = pieces[pieces.length - 1];\n if (last && last.kind === 'literal') {\n last.value += value;\n } else {\n pieces.push({ kind: 'literal', value });\n }\n}","// Numbering systems. Default: latn (ASCII digits).\n// Optional: arab, deva, beng, etc. Configurable on formatting.\n//\n// The library's existing tokens always render ASCII digits (see\n// tokens.ts's pad() — uses String(n) which produces ASCII). This\n// module adds the ability to convert the output to a locale's native\n// digits via Intl.NumberFormat, which is the standard mechanism JS\n// provides for digit transliteration.\n//\n// On the parse side: parse() only accepts ASCII digits, matching how\n// the existing NUMERIC_FRAGMENTS regex is built. A parseNumberingSystem\n// option could convert input digits to ASCII before matching — but\n// that's a per-call opt-in, not silent acceptance of every numeral\n// system.\n\nimport { DEFAULT_LOCALE, type FormatOptions } from './tokens.js';\nimport { InvalidLocaleError } from './errors.js';\n\nexport type NumberingSystem = 'latn' | 'arab' | 'deva' | 'beng' | 'guru' | 'gujr' | 'orya' | 'tamldec' | 'telu' | 'knda' | 'mlym' | 'fullwide' | 'hanidec';\n\n// All supported NumberingSystem values. latn is the default and what\n// the rest of the library produces natively.\nexport const SUPPORTED_NUMBERING_SYSTEMS: ReadonlySet<string> = new Set([\n 'latn', 'arab', 'deva', 'beng', 'guru', 'gujr', 'orya', 'tamldec',\n 'telu', 'knda', 'mlym', 'fullwide', 'hanidec',\n]);\n\nconst digitMapCache = new Map<string, Record<string, string>>();\n\n// Builds a per-numbering-system digit transliteration map. Uses\n// Intl.NumberFormat to render 0-9 in the requested system, then\n// builds the lookup table. Cached because constructing a formatter\n// is expensive and we re-use the same map for every digit in the\n// output.\nfunction getDigitMap(system: string): Record<string, string> {\n let map = digitMapCache.get(system);\n if (map) return map;\n /* c8 ignore start @preserve -- dead by construction, not just\n untested: both callers (convertDigits, convertDigitsToAscii) already\n return early on system === 'latn' before calling getDigitMap at all,\n so this function is never invoked with 'latn'. Kept as a defensive\n fallback rather than trusting that stays true for any future\n caller. */\n if (system === 'latn') {\n map = {};\n for (let i = 0; i < 10; i++) map[String(i)] = String(i);\n } else {\n /* c8 ignore stop @preserve */\n const fmt = new Intl.NumberFormat('en-US-u-nu-' + system, { useGrouping: false });\n map = {};\n for (let i = 0; i < 10; i++) {\n map[String(i)] = fmt.format(i);\n }\n }\n digitMapCache.set(system, map);\n return map;\n}\n\n// Converts every ASCII digit in `s` to its equivalent in the requested\n// numbering system. Non-digit characters pass through unchanged.\nexport function convertDigits(s: string, system: string): string {\n if (system === 'latn') return s;\n if (!SUPPORTED_NUMBERING_SYSTEMS.has(system)) {\n throw new InvalidLocaleError({ actual: system, reason: `numbering system \"${system}\" is not supported. Supported: ${[...SUPPORTED_NUMBERING_SYSTEMS].join(', ')}.` });\n }\n const map = getDigitMap(system);\n let result = '';\n for (const ch of s) {\n if (ch >= '0' && ch <= '9') {\n // map[ch] is always populated for '0'-'9' since getDigitMap builds\n // all ten digit keys for every supported system and ch is already\n // range-checked above; the ?? ch fallback exists only as a\n // type-safety guard against Record's implicit undefined, not a\n // reachable runtime path.\n /* c8 ignore next */\n result += map[ch] ?? ch;\n } else {\n result += ch;\n }\n }\n return result;\n}\n\n// Parses a string with non-ASCII digits back to ASCII. The inverse of\n// convertDigits — used by parse() when an explicit `numberingSystem`\n// option is passed. Throws on unsupported systems.\nexport function convertDigitsToAscii(s: string, system: string): string {\n // Same dead-by-construction situation as applyParseNumbering's own\n // 'latn' guard: this function's only caller (applyParseNumbering)\n // already returns early on system === 'latn' before reaching this\n // call, so system is never 'latn' here in practice. Kept as a\n // defensive guard for any future direct caller.\n /* c8 ignore next */\n if (system === 'latn') return s;\n if (!SUPPORTED_NUMBERING_SYSTEMS.has(system)) {\n throw new InvalidLocaleError({ actual: system, reason: `numbering system \"${system}\" is not supported.` });\n }\n const map = getDigitMap(system);\n // Build reverse map.\n const reverse: Record<string, string> = {};\n for (const k of Object.keys(map)) reverse[map[k]!] = k;\n let result = '';\n for (const ch of s) {\n result += reverse[ch] ?? ch;\n }\n return result;\n}\n\n// Augmented FormatOptions that includes the numberingSystem field.\n// Callers pass { numberingSystem: 'arab' } to format() to get Arabic-\n// Indic digits in the output.\nexport interface NumberingFormatOptions extends FormatOptions {\n numberingSystem?: string;\n}\n\n// Parse-side counterpart. Named parseNumberingSystem (not numberingSystem)\n// so a caller mixing format() and parse() options in the same config\n// object can set both independently — the two directions aren't always\n// symmetric (e.g. converting *to* native digits on output without\n// expecting native digits back on input, or vice versa).\nexport interface NumberingParseOptions extends FormatOptions {\n parseNumberingSystem?: string;\n}\n\n// Helper for the format path: takes the formatted ASCII output of\n// format() and converts digits if a numberingSystem was requested.\n// Kept here so format.ts doesn't need to know about numbering systems.\nexport function applyNumbering(s: string, options: NumberingFormatOptions): string {\n const system = options.numberingSystem ?? 'latn';\n if (system === 'latn') return s;\n return convertDigits(s, system);\n}\n\n// Helper for the parse path: converts input digits to ASCII before\n// matching, when parseNumberingSystem is set. Distinct from the format\n// path's option name (numberingSystem vs parseNumberingSystem) so a\n// caller can be explicit about which direction they want transliterated.\nexport function applyParseNumbering(s: string, options: { parseNumberingSystem?: string }): string {\n // Both call sites of applyParseNumbering (parse.ts) already guard with\n // `if (options.parseNumberingSystem)` before calling it, so\n // options.parseNumberingSystem is always truthy here — the ?? 'latn'\n // fallback, and the subsequent 'latn' early return, are dead by\n // construction, not just untested. Kept as a defensive default rather\n // than assuming every future caller replicates the guard.\n /* c8 ignore next 2 */\n const system = options.parseNumberingSystem ?? 'latn';\n if (system === 'latn') return s;\n return convertDigitsToAscii(s, system);\n}\n\n// Suppress unused-import warning. DEFAULT_LOCALE is imported for the\n// type augmentation pattern above; if the project ever exports a\n// typed-locale interface, it'll be the source of truth for the default.\nvoid DEFAULT_LOCALE;"],"mappings":"8FAQA,IAAMA,EAAuBC,EAAO,IAAI,CAAC,CAACC,CAAG,IAAMA,CAAG,EAAE,KAAK,CAACC,EAAGC,IAAMA,EAAE,OAASD,EAAE,MAAM,EAQnF,SAASE,EAASC,EAAyB,CAChD,IAAMC,EAAkB,CAAC,EACrBC,EAAI,EAER,KAAOA,EAAIF,EAAO,QAAQ,CACxB,IAAMG,EAAKH,EAAOE,CAAC,EAEnB,GAAIC,IAAO,IAAK,CAEd,GAAIH,EAAOE,EAAI,CAAC,IAAM,IAAK,CACzBE,EAAcH,EAAQ,GAAG,EACzBC,GAAK,EACL,QACF,CAEA,IAAIG,EAAIH,EAAI,EACRI,EAAU,GACVC,EAAS,GACb,KAAOF,EAAIL,EAAO,QAAQ,CACxB,GAAIA,EAAOK,CAAC,IAAM,IAAK,CACrB,GAAIL,EAAOK,EAAI,CAAC,IAAM,IAAK,CACzBC,GAAW,IACXD,GAAK,EACL,QACF,CACAE,EAAS,GACTF,GAAK,EACL,KACF,CACAC,GAAWN,EAAOK,CAAC,EACnBA,GAAK,CACP,CAEA,GAAI,CAACE,EACH,MAAM,IAAIC,EAAkB,CAC1B,OAAAR,EACA,QAAS,sDAAsDA,CAAM,GACvE,CAAC,EAGHI,EAAcH,EAAQK,CAAO,EAC7BJ,EAAIG,EACJ,QACF,CAEA,IAAMI,EAAQf,EAAqB,KAAME,GAAQI,EAAO,WAAWJ,EAAKM,CAAC,CAAC,EAC1E,GAAIO,EAAO,CAQT,IAAMC,EAAUD,EAAMA,EAAM,OAAS,CAAC,EACtC,GAAIT,EAAOE,EAAIO,EAAM,MAAM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endLiteral","j","literal","closed","FormatSyntaxError","match","runChar","end","UnknownTokenError","value","last","SUPPORTED_NUMBERING_SYSTEMS","digitMapCache","getDigitMap","system","map","i","fmt","convertDigits","s","InvalidLocaleError","result","ch","convertDigitsToAscii","reverse","k","applyNumbering","options","applyParseNumbering"]}
@@ -1,2 +0,0 @@
1
- import{a as u}from"./chunk-GMGZZG6I.js";import{k as f,p as c}from"./chunk-5U5WJ465.js";import{w as l}from"./chunk-VQXUMFB2.js";var s=new Map,y=100;function w(r,n){let t=`${r}|${n}`,e=s.get(t);if(e)return e;if(s.size>=y){let o=s.keys().next().value;o!==void 0&&s.delete(o)}try{e=new Intl.RelativeTimeFormat(c(r),{numeric:n})}catch(o){throw new f({actual:r,reason:o.message})}return s.set(t,e),e}function p(r,n,t={}){let e=t.locale??u,o=t.numeric??"auto",a=w(e,o),i=-l(r,n),m=Math.abs(i);return m===0?a.format(0,"day"):m<7?a.format(i,"day"):m<30?a.format(-Math.trunc(-i/7),"week"):m<365?a.format(-Math.trunc(-i/30),"month"):a.format(-Math.trunc(-i/365),"year")}function v(r,n={}){let t=new Date,e={year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()};return p(r,e,n)}export{p as a,v as b};
2
- //# sourceMappingURL=chunk-R4YEFOVE.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/relativeTime.ts"],"sourcesContent":["// Relative time helpers. The existing formatDistance() in\n// formatDistance.ts stays; this module adds formatRelative() and\n// formatRelativeToNow().\n//\n// Semantic distinction:\n// formatDistance(date1, date2) — \"3 days ago\" / \"in 2 hours\"\n// Describes the gap between two values, delegating unit selection\n// and pluralization to Intl.RelativeTimeFormat.\n// formatRelative(date, baseDate) — \"yesterday\" / \"tomorrow\" / \"today\"\n// / \"in 3 days\" / \"last week\"\n// Calendar-relative: uses the calendar date diff, not the ms diff.\n// \"in 1 day\" means \"tomorrow\", even if it's 23 hours away.\n// formatRelativeToNow(date) — same as formatRelative(date, now)\n\nimport { differenceInDays } from './arithmetic.js';\nimport { DEFAULT_LOCALE, type FormatOptions } from './tokens.js';\nimport { normalizeLocaleTag } from './localeVocab.js';\nimport { InvalidLocaleError } from './errors.js';\n\nexport interface FormatRelativeOptions extends FormatOptions {\n // 'auto' (default) lets Intl.RelativeTimeFormat use natural forms like\n // \"yesterday\"/\"tomorrow\"/\"now\" when the value lands on ±1 or 0.\n // 'always' forces the strict \"1 day ago\"/\"in 1 day\" form.\n numeric?: 'always' | 'auto';\n}\n\nconst rtfCache = new Map<string, Intl.RelativeTimeFormat>();\nconst MAX_RTF_CACHE_SIZE = 100;\n\nfunction getRtf(locale: string, numeric: 'always' | 'auto'): Intl.RelativeTimeFormat {\n // Same cache shape as formatDistance.ts uses.\n const key = `${locale}|${numeric}`;\n let rtf = rtfCache.get(key);\n if (rtf) return rtf;\n if (rtfCache.size >= MAX_RTF_CACHE_SIZE) {\n const oldestKey = rtfCache.keys().next().value;\n if (oldestKey !== undefined) rtfCache.delete(oldestKey);\n }\n try {\n rtf = new Intl.RelativeTimeFormat(normalizeLocaleTag(locale), { numeric });\n } catch (err) {\n // Malformed locale tags reach Intl as a bare RangeError; surface the\n // library's typed error instead. (Every failure mode of these\n // constructors with a string locale is a RangeError, so converting\n // unconditionally loses nothing — the original message is preserved\n // in `reason` either way.)\n throw new InvalidLocaleError({ actual: locale, reason: (err as Error).message });\n }\n rtfCache.set(key, rtf);\n return rtf;\n}\n\n// Calendar-relative \"describe date1 as if standing at date2\" — uses\n// differenceInDays (which counts date boundaries, not 24-hour periods),\n// so \"2026-08-04 23:59\" relative to \"2026-08-05 00:00\" reads as\n// \"yesterday\" (1 day ago), not \"1 second ago\".\n//\n// differenceInDays(a, b) returns b - a; for formatRelative(date1, date2)\n// we want date1 - date2 (so positive means date1 is in the future relative\n// to date2). Swap the argument order.\nexport function formatRelative(\n date1: unknown,\n date2: unknown,\n options: FormatRelativeOptions = {},\n): string {\n const locale = options.locale ?? DEFAULT_LOCALE;\n const numeric = options.numeric ?? 'auto';\n const rtf = getRtf(locale, numeric);\n const dayDiff = -differenceInDays(date1, date2);\n const absDays = Math.abs(dayDiff);\n\n if (absDays === 0) {\n return rtf.format(0, 'day'); // \"now\" / \"in 0 days\"\n }\n if (absDays < 7) {\n return rtf.format(dayDiff, 'day');\n }\n if (absDays < 30) {\n return rtf.format(-Math.trunc(-dayDiff / 7), 'week');\n }\n if (absDays < 365) {\n return rtf.format(-Math.trunc(-dayDiff / 30), 'month');\n }\n return rtf.format(-Math.trunc(-dayDiff / 365), 'year');\n}\n\nexport function formatRelativeToNow(\n date: unknown,\n options: FormatRelativeOptions = {},\n): string {\n // Use the system's current date as the reference. PlainDate.from a\n // JS Date so differenceInDays sees the right shape.\n const now = new Date();\n const nowFields = {\n year: now.getFullYear(),\n month: now.getMonth() + 1,\n day: now.getDate(),\n };\n return formatRelative(date, nowFields, options);\n}\n"],"mappings":"+HA0BA,IAAMA,EAAW,IAAI,IACfC,EAAqB,IAE3B,SAASC,EAAOC,EAAgBC,EAAqD,CAEnF,IAAMC,EAAM,GAAGF,CAAM,IAAIC,CAAO,GAC5BE,EAAMN,EAAS,IAAIK,CAAG,EAC1B,GAAIC,EAAK,OAAOA,EAChB,GAAIN,EAAS,MAAQC,EAAoB,CACvC,IAAMM,EAAYP,EAAS,KAAK,EAAE,KAAK,EAAE,MACrCO,IAAc,QAAWP,EAAS,OAAOO,CAAS,CACxD,CACA,GAAI,CACFD,EAAM,IAAI,KAAK,mBAAmBE,EAAmBL,CAAM,EAAG,CAAE,QAAAC,CAAQ,CAAC,CAC3E,OAASK,EAAK,CAMZ,MAAM,IAAIC,EAAmB,CAAE,OAAQP,EAAQ,OAASM,EAAc,OAAQ,CAAC,CACjF,CACA,OAAAT,EAAS,IAAIK,EAAKC,CAAG,EACdA,CACT,CAUO,SAASK,EACdC,EACAC,EACAC,EAAiC,CAAC,EAC1B,CACR,IAAMX,EAASW,EAAQ,QAAUC,EAC3BX,EAAUU,EAAQ,SAAW,OAC7BR,EAAMJ,EAAOC,EAAQC,CAAO,EAC5BY,EAAU,CAACC,EAAiBL,EAAOC,CAAK,EACxCK,EAAU,KAAK,IAAIF,CAAO,EAEhC,OAAIE,IAAY,EACPZ,EAAI,OAAO,EAAG,KAAK,EAExBY,EAAU,EACLZ,EAAI,OAAOU,EAAS,KAAK,EAE9BE,EAAU,GACLZ,EAAI,OAAO,CAAC,KAAK,MAAM,CAACU,EAAU,CAAC,EAAG,MAAM,EAEjDE,EAAU,IACLZ,EAAI,OAAO,CAAC,KAAK,MAAM,CAACU,EAAU,EAAE,EAAG,OAAO,EAEhDV,EAAI,OAAO,CAAC,KAAK,MAAM,CAACU,EAAU,GAAG,EAAG,MAAM,CACvD,CAEO,SAASG,EACdC,EACAN,EAAiC,CAAC,EAC1B,CAGR,IAAMO,EAAM,IAAI,KACVC,EAAY,CAChB,KAAMD,EAAI,YAAY,EACtB,MAAOA,EAAI,SAAS,EAAI,EACxB,IAAKA,EAAI,QAAQ,CACnB,EACA,OAAOV,EAAeS,EAAME,EAAWR,CAAO,CAChD","names":["rtfCache","MAX_RTF_CACHE_SIZE","getRtf","locale","numeric","key","rtf","oldestKey","normalizeLocaleTag","err","InvalidLocaleError","formatRelative","date1","date2","options","DEFAULT_LOCALE","dayDiff","differenceInDays","absDays","formatRelativeToNow","date","now","nowFields"]}
@@ -1,11 +0,0 @@
1
- import{a as v,e as c}from"./chunk-NPKJ7QFK.js";import{a as f,b as k}from"./chunk-GMGZZG6I.js";import{b as r,c as u}from"./chunk-5U5WJ465.js";var d=new Map(k.map(([t,n,i])=>[t,{fn:n,field:i}])),p=new Map,w=500;function h(t){let n=p.get(t);if(n)return n;if(p.size>=w){let i=p.keys().next().value;i!==void 0&&p.delete(i)}return n=v(t),p.set(t,n),n}function $(t,n,i={}){if(n.length>1e3)throw new r({format:n,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${n.length}).`});let l=i.locale??f,s=h(n),o="";for(let e of s){if(e.kind==="literal"){o+=e.value;continue}let a=d.get(e.value);/* c8 ignore start @preserve -- unreachable: tokenize() only ever emits
2
- tokens present in TOKENS, and HANDLER_BY_TOKEN is built from that
3
- same list, so every token piece.value can hold already has an entry
4
- here. Same defensive-guard category as the twin checks in
5
- analyze.ts/formatDuration.ts. */if(!a)throw new u({token:e.value,format:n,message:`temporal-fmt: unknown token "${e.value}"`});/* c8 ignore stop @preserve */if(t[a.field]===void 0)throw new r({format:n,token:e.value,message:`temporal-fmt: token "${e.value}" requires "${a.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});o+=a.fn(t,l)}return c(o,i)}function x(t,n,i={}){if(n.length>1e3)throw new r({format:n,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${n.length}).`});let l=i.locale??f,s=h(n),o=[];for(let e of s){if(e.kind==="literal"){let m=o[o.length-1];/* c8 ignore start @preserve -- unreachable through tokenize()'s own
6
- output: appendLiteral() in tokenize.ts already merges every
7
- adjacent literal character before pieces ever reaches here, so
8
- two 'literal' pieces never sit back-to-back in the array this
9
- loop walks. Kept as defense-in-depth in case that invariant ever
10
- changes upstream. */if(m&&m.type==="literal")m.value+=e.value;else{/* c8 ignore stop @preserve */o.push({type:"literal",value:e.value})}continue}let a=d.get(e.value);/* c8 ignore start @preserve -- unreachable, see the note in format() above */if(!a)throw new u({token:e.value,format:n,message:`temporal-fmt: unknown token "${e.value}"`});/* c8 ignore stop @preserve */if(t[a.field]===void 0)throw new r({format:n,token:e.value,message:`temporal-fmt: token "${e.value}" requires "${a.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});o.push({type:"token",value:c(a.fn(t,l),i),token:e.value})}return o}function L(t){if(t.length>1e3)throw new r({format:t,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${t.length}).`});let n=h(t);return{formatStr:t,pieces:n,format(i,l={}){let s=l.locale??f,o="";for(let e of n){if(e.kind==="literal"){o+=e.value;continue}let a=d.get(e.value);if(!a)throw new u({token:e.value,format:t,message:`temporal-fmt: unknown token "${e.value}"`});if(i[a.field]===void 0)throw new r({format:t,token:e.value,message:`temporal-fmt: token "${e.value}" requires "${a.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});o+=a.fn(i,s)}return c(o,l)},formatToParts(i,l={}){let s=l.locale??f,o=[];for(let e of n){if(e.kind==="literal"){let m=o[o.length-1];m&&m.type==="literal"?m.value+=e.value:o.push({type:"literal",value:e.value});continue}let a=d.get(e.value);if(!a)throw new u({token:e.value,format:t,message:`temporal-fmt: unknown token "${e.value}"`});if(i[a.field]===void 0)throw new r({format:t,token:e.value,message:`temporal-fmt: token "${e.value}" requires "${a.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});o.push({type:"token",value:c(a.fn(i,s),l),token:e.value})}return o}}}function N(t){return h(t)}function O(t){return d.get(t)}export{$ as a,x as b,L as c,N as d,O as e};
11
- //# sourceMappingURL=chunk-SSPABEUR.js.map
@@ -1,2 +0,0 @@
1
- import{n as p}from"./chunk-EHLRZULM.js";function x(n){let e=n.year,o=n.month,t=n.day,a=o<=2?e-1:e,m=Math.floor((a>=0?a:a-399)/400),b=a-m*400,y=o>2?o-3:o+9,w=Math.floor((153*y+2)/5)+t-1,d=b*365+Math.floor(b/4)-Math.floor(b/100)+w;return(m*146097+d-719468)*864e5+(n.hour??0)*36e5+(n.minute??0)*6e4+(n.second??0)*1e3+(n.millisecond??0)}function E(n){return p(n)}function u(n,e){let o=E(n),t=E(e),a=x(o),m=x(t);return a<m?-1:a>m?1:0}function V(n,e){return u(n,e)===0}function A(n,e){return u(n,e)<0}function U(n,e){return u(n,e)>0}function C(n){if(!Array.isArray(n)||n.length===0)throw new Error("temporal-fmt: min() requires a non-empty array of values.");let e=n[0];for(let o=1;o<n.length;o++)u(n[o],e)<0&&(e=n[o]);return e}function q(n){if(!Array.isArray(n)||n.length===0)throw new Error("temporal-fmt: max() requires a non-empty array of values.");let e=n[0];for(let o=1;o<n.length;o++)u(n[o],e)>0&&(e=n[o]);return e}function N(n,e,o){return u(n,e)<0?e:u(n,o)>0?o:n}function j(n,e,o){return u(n,e)>=0&&u(n,o)<=0}function r(n){let e=p(n);return{year:e.year,month:e.month,day:e.day}}function Y(){let n=new Date;return{year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}}function k(n,e){return n.year===e.year&&n.month===e.month&&n.day===e.day}function H(n,e){return k(r(n),r(e))}function I(n){return k(r(n),Y())}function R(){let n=new Date;return n.setDate(n.getDate()+1),{year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}}function F(){let n=new Date;return n.setDate(n.getDate()-1),{year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}}function Q(n){return k(r(n),R())}function Z(n){return k(r(n),F())}function W(n,e,o,t,a,m){let y=(c,i,l)=>{let f=i<=2?c-1:c,D=(f>=0?f:f-399)/400|0,s=f-D*400,S=i>2?i-3:i+9,g=Math.floor(Math.floor(153*S+2)/5+l-1),T=s*365+Math.floor(s/4)-Math.floor(s/100)+g;return D*146097+T-719468},w=y(n,e,o),d=y(t,a,m);if(Math.abs(w-d)>=7)return!1;let h=(c,i,l)=>{let f=y(c,i,l),s=new Date(Date.UTC(c,i-1,l)).getUTCDay();return s===0?7:s},M=w-(h(n,e,o)-1),_=d-(h(t,a,m)-1);return M===_}function $(n,e){let o=r(n),t=r(e);return W(o.year,o.month,o.day,t.year,t.month,t.day)}function z(n,e){let o=r(n),t=r(e);return o.year===t.year&&o.month===t.month}function G(n,e){let o=r(n),t=r(e);return o.year===t.year&&Math.ceil(o.month/3)===Math.ceil(t.month/3)}function J(n,e){return r(n).year===r(e).year}function O(n){if(typeof n!="object"||n===null)throw new Error(`temporal-fmt: isWeekend() expected a Temporal value, got ${String(n)}.`);let e=n;if(typeof e.dayOfWeek!="number")throw new Error("temporal-fmt: isWeekend() needs a value with a dayOfWeek field (PlainDate / PlainDateTime / ZonedDateTime).");return e.dayOfWeek===6||e.dayOfWeek===7}function K(n){return!O(n)}export{u as a,V as b,A as c,U as d,C as e,q as f,N as g,j as h,H as i,I as j,Q as k,Z as l,$ as m,z as n,G as o,J as p,O as q,K as r};
2
- //# sourceMappingURL=chunk-UJR6DHXY.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/comparison.ts"],"sourcesContent":["// Comparison helpers. Pure functions over the field\n// shape, no Temporal namespace needed — same convention as\n// calendarUtils.ts. All comparisons are field-based, not identity-based,\n// so a polyfill PlainDate compares equal to a native PlainDate with the\n// same year/month/day.\n\nimport { asDateFieldView, type DateFieldView } from './calendarUtils.js';\n\ninterface DateTimeFieldView extends DateFieldView {\n hour?: number;\n minute?: number;\n second?: number;\n millisecond?: number;\n}\n\nfunction toComparableMs(view: DateTimeFieldView): number {\n // Exact proleptic-Gregorian day count (Howard Hinnant's days_from_civil,\n // same algorithm arithmetic.ts/interval.ts use) plus the time-of-day —\n // NOT an approximation. The previous implementation multiplied the\n // year offset by an average 365.2425 days/year, on the theory that the\n // error \"is constant for any given year, so it cancels out in a diff\".\n // That's only true when both dates fall in the same year: the year\n // term's error differs by up to ~0.76 days between adjacent years\n // (365.2425 vs 365/366 actual), which corrupts cross-year comparisons\n // near the boundary — e.g. isAfter(2025-01-01T00:00, 2024-12-31T18:12)\n // returned false (truth: ~5.8h after), and isEqual() returned true for\n // instants ~18h apart (2025-01-01T00:00 vs 2024-12-31T05:49:12).\n // Exact arithmetic has no such error term.\n const y = view.year!, m = view.month!, d = view.day!;\n const y2 = m <= 2 ? y - 1 : y;\n const era = Math.floor((y2 >= 0 ? y2 : y2 - 399) / 400);\n const yoe = y2 - era * 400;\n const m2 = m > 2 ? m - 3 : m + 9;\n const doy = Math.floor((153 * m2 + 2) / 5) + d - 1;\n const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;\n const days = era * 146097 + doe - 719468;\n\n const MS_PER_HOUR = 3_600_000;\n const MS_PER_MINUTE = 60_000;\n const MS_PER_SECOND = 1_000;\n\n return days * 86_400_000\n + (view.hour ?? 0) * MS_PER_HOUR\n + (view.minute ?? 0) * MS_PER_MINUTE\n + (view.second ?? 0) * MS_PER_SECOND\n + (view.millisecond ?? 0);\n}\n\nfunction asDateTimeFieldView(value: unknown): DateTimeFieldView {\n const v = asDateFieldView(value);\n return v as DateTimeFieldView;\n}\n\n// Returns < 0 if a < b, 0 if a === b, > 0 if a > b. Same convention as\n// Array.prototype.sort and Temporal.PlainDate.compare. Lets callers\n// pass this directly as a comparator.\nexport function compare(a: unknown, b: unknown): number {\n const av = asDateTimeFieldView(a);\n const bv = asDateTimeFieldView(b);\n const am = toComparableMs(av);\n const bm = toComparableMs(bv);\n if (am < bm) return -1;\n if (am > bm) return 1;\n return 0;\n}\n\nexport function isEqual(a: unknown, b: unknown): boolean {\n return compare(a, b) === 0;\n}\n\nexport function isBefore(a: unknown, b: unknown): boolean {\n return compare(a, b) < 0;\n}\n\nexport function isAfter(a: unknown, b: unknown): boolean {\n return compare(a, b) > 0;\n}\n\nexport function min(values: unknown[]): unknown {\n if (!Array.isArray(values) || values.length === 0) {\n throw new Error('temporal-fmt: min() requires a non-empty array of values.');\n }\n let best = values[0];\n for (let i = 1; i < values.length; i++) {\n if (compare(values[i], best) < 0) best = values[i];\n }\n return best;\n}\n\nexport function max(values: unknown[]): unknown {\n if (!Array.isArray(values) || values.length === 0) {\n throw new Error('temporal-fmt: max() requires a non-empty array of values.');\n }\n let best = values[0];\n for (let i = 1; i < values.length; i++) {\n if (compare(values[i], best) > 0) best = values[i];\n }\n return best;\n}\n\nexport function clamp(value: unknown, lo: unknown, hi: unknown): unknown {\n if (compare(value, lo) < 0) return lo;\n if (compare(value, hi) > 0) return hi;\n return value;\n}\n\nexport function isBetween(value: unknown, lo: unknown, hi: unknown): boolean {\n return compare(value, lo) >= 0 && compare(value, hi) <= 0;\n}\n\n// Semantic helpers — same-day/week/month/quarter/year tests. Useful for\n// UI (\"is this event today?\") and for grouping/aggregation. All take a\n// reference value to compare against; the \"isToday\" / \"isTomorrow\" /\n// \"isYesterday\" variants compute the reference from the current system\n// date themselves so callers don't have to.\nfunction readYearMonthDay(value: unknown): { year: number; month: number; day: number } {\n const v = asDateFieldView(value);\n return { year: v.year!, month: v.month!, day: v.day! };\n}\n\nfunction todayYearMonthDay(): { year: number; month: number; day: number } {\n const now = new Date();\n return { year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate() };\n}\n\nfunction dateEqualYearMonthDay(a: { year: number; month: number; day: number }, b: { year: number; month: number; day: number }): boolean {\n return a.year === b.year && a.month === b.month && a.day === b.day;\n}\n\nexport function isSameDay(value: unknown, reference: unknown): boolean {\n return dateEqualYearMonthDay(readYearMonthDay(value), readYearMonthDay(reference));\n}\n\nexport function isToday(value: unknown): boolean {\n return dateEqualYearMonthDay(readYearMonthDay(value), todayYearMonthDay());\n}\n\nfunction tomorrowYearMonthDay(): { year: number; month: number; day: number } {\n const d = new Date();\n d.setDate(d.getDate() + 1);\n return { year: d.getFullYear(), month: d.getMonth() + 1, day: d.getDate() };\n}\n\nfunction yesterdayYearMonthDay(): { year: number; month: number; day: number } {\n const d = new Date();\n d.setDate(d.getDate() - 1);\n return { year: d.getFullYear(), month: d.getMonth() + 1, day: d.getDate() };\n}\n\nexport function isTomorrow(value: unknown): boolean {\n return dateEqualYearMonthDay(readYearMonthDay(value), tomorrowYearMonthDay());\n}\n\nexport function isYesterday(value: unknown): boolean {\n return dateEqualYearMonthDay(readYearMonthDay(value), yesterdayYearMonthDay());\n}\n\nfunction sameWeek(yearA: number, monthA: number, dayA: number, yearB: number, monthB: number, dayB: number): boolean {\n // Same week iff the dates are within 7 days of each other AND the earlier\n // one's weekday is ≤ the later one's weekday (so we don't say \"Sun and\n // the following Mon are in the same week\" — ISO weeks run Mon-Sun).\n // Easier: compute ISO week numbers via isoWeekYearAndWeek, compare both\n // year and week. That handles the year-boundary case (Dec 31 vs Jan 1 of\n // the next year, which can be in the same ISO week).\n // Local import to avoid module-cycle: isoWeek.ts doesn't import from here.\n // Lazy require-style dynamic via inline static import at top would be\n // cleaner; this inline computation is fine for a pure helper.\n // ...actually let's just compute weekday offsets directly. Same-ISO-week\n // iff |d1 - d2| < 7 days AND the earlier date's ISO weekday ≤ the later\n // date's ISO weekday so they fall in the same Mon-Sun span.\n const DAYS_PER_400_YEARS = 146097;\n const daysSince = (y: number, m: number, d: number): number => {\n // Zeller's congruence variant — convert Y/M/D to a day count.\n // Using a simple algorithm here that's correct for proleptic Gregorian.\n const y2 = m <= 2 ? y - 1 : y;\n const era = (y2 >= 0 ? y2 : y2 - 399) / 400 | 0;\n const yoe = y2 - era * 400;\n const m2 = m > 2 ? m - 3 : m + 9;\n const doy = Math.floor((Math.floor(153 * m2 + 2) / 5) + d - 1);\n const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;\n return era * DAYS_PER_400_YEARS + doe - 719468;\n };\n const a = daysSince(yearA, monthA, dayA);\n const b = daysSince(yearB, monthB, dayB);\n if (Math.abs(a - b) >= 7) return false;\n // Same week iff both dates round to the same Monday. Compute the\n // Monday-of-week for each: subtract (weekday - 1) days, where weekday\n // is 1=Mon..7=Sun. Use the standard Zeller formula for weekday.\n const weekdayOf = (y: number, m: number, d: number): number => {\n const days = daysSince(y, m, d);\n // 1970-01-01 was a Thursday (ISO 4). So weekday = ((days + 3) mod 7) + 1\n // mapped to Mon=1..Sun=7. Let's compute: Sun=0..Sat=6 via JS Date.\n const date = new Date(Date.UTC(y, m - 1, d));\n const jsDow = date.getUTCDay(); // 0=Sun..6=Sat\n return jsDow === 0 ? 7 : jsDow;\n };\n const wa = a - (weekdayOf(yearA, monthA, dayA) - 1);\n const wb = b - (weekdayOf(yearB, monthB, dayB) - 1);\n return wa === wb;\n}\n\nexport function isSameWeek(value: unknown, reference: unknown): boolean {\n const a = readYearMonthDay(value);\n const b = readYearMonthDay(reference);\n return sameWeek(a.year, a.month, a.day, b.year, b.month, b.day);\n}\n\nexport function isSameMonth(value: unknown, reference: unknown): boolean {\n const a = readYearMonthDay(value);\n const b = readYearMonthDay(reference);\n return a.year === b.year && a.month === b.month;\n}\n\nexport function isSameQuarter(value: unknown, reference: unknown): boolean {\n const a = readYearMonthDay(value);\n const b = readYearMonthDay(reference);\n return a.year === b.year && Math.ceil(a.month / 3) === Math.ceil(b.month / 3);\n}\n\nexport function isSameYear(value: unknown, reference: unknown): boolean {\n return readYearMonthDay(value).year === readYearMonthDay(reference).year;\n}\n\n// isWeekend / isWeekday depend on dayOfWeek — present on PlainDate,\n// PlainDateTime, ZonedDateTime, but NOT on PlainTime. Callers passing\n// PlainTime get a descriptive throw. Doesn't call asDateFieldView\n// because that would reject PlainTime (no year/month/day) before\n// reaching the dayOfWeek check — and the error we want here is the\n// \"no dayOfWeek field\" one, not the \"no date fields\" one.\nexport function isWeekend(value: unknown): boolean {\n if (typeof value !== 'object' || value === null) {\n throw new Error(`temporal-fmt: isWeekend() expected a Temporal value, got ${String(value)}.`);\n }\n const v = value as { dayOfWeek?: unknown };\n if (typeof v.dayOfWeek !== 'number') {\n throw new Error(\n `temporal-fmt: isWeekend() needs a value with a dayOfWeek field (PlainDate / PlainDateTime / ZonedDateTime).`\n );\n }\n // 6=Sat, 7=Sun in Temporal's Mon=1..Sun=7 numbering.\n return v.dayOfWeek === 6 || v.dayOfWeek === 7;\n}\n\nexport function isWeekday(value: unknown): boolean {\n return !isWeekend(value);\n}\n"],"mappings":"wCAeA,SAASA,EAAeC,EAAiC,CAavD,IAAMC,EAAID,EAAK,KAAOE,EAAIF,EAAK,MAAQG,EAAIH,EAAK,IAC1CI,EAAKF,GAAK,EAAID,EAAI,EAAIA,EACtBI,EAAM,KAAK,OAAOD,GAAM,EAAIA,EAAKA,EAAK,KAAO,GAAG,EAChDE,EAAMF,EAAKC,EAAM,IACjBE,EAAKL,EAAI,EAAIA,EAAI,EAAIA,EAAI,EACzBM,EAAM,KAAK,OAAO,IAAMD,EAAK,GAAK,CAAC,EAAIJ,EAAI,EAC3CM,EAAMH,EAAM,IA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","yoe","m2","doy","doe","asDateTimeFieldView","value","asDateFieldView","compare","a","b","av","bv","am","bm","isEqual","isBefore","isAfter","min","values","best","i","max","clamp","lo","hi","isBetween","readYearMonthDay","v","todayYearMonthDay","now","dateEqualYearMonthDay","isSameDay","reference","isToday","tomorrowYearMonthDay","yesterdayYearMonthDay","isTomorrow","isYesterday","sameWeek","yearA","monthA","dayA","yearB","monthB","dayB","daysSince","weekdayOf","days","jsDow","wa","wb","isSameWeek","isSameMonth","isSameQuarter","isSameYear","isWeekend","isWeekday"]}
@@ -1,21 +0,0 @@
1
- import{a as D,n as O}from"./chunk-EHLRZULM.js";function E(n){return O(n)}function p(n){if(typeof n.dayOfWeek!="number")return;/* c8 ignore start @preserve -- unreachable: every call site (add()'s
2
- 'years'/'months' cases, shiftDays()) passes a `result` whose
3
- year/month/day were just explicitly set, and the value originally
4
- came from asDateTime()/asDateFieldView(), which throws unless
5
- year/month/day are all present as numbers. So by the time this guard
6
- runs, all three are guaranteed valid. Kept in case a future caller
7
- constructs a DateTimeFieldView bypassing that validation. */if(typeof n.year!="number"||typeof n.month!="number"||typeof n.day!="number")return;/* c8 ignore stop @preserve */let e=new Date(Date.UTC(n.year,n.month-1,n.day)).getUTCDay();n.dayOfWeek=e===0?7:e}function i(n,e,t){let o={...E(n)};switch(t){case"years":{/* c8 ignore start @preserve -- the `?? 0` fallback is unreachable:
8
- asDateTime()/asDateFieldView() (called at the top of add()) throws
9
- unless year is present as a number, so result.year is never
10
- undefined here. Kept as a guard against a future change that
11
- relaxes that validation. */o.year=(o.year??0)+e;/* c8 ignore stop @preserve */let s=D({year:o.year,month:o.month});o.day>s&&(o.day=s),p(o);break}case"months":{/* c8 ignore start @preserve -- both `??` fallbacks are unreachable
12
- for the same reason as the 'years' case above: asDateFieldView()
13
- guarantees year and month are present numbers before add() ever
14
- reaches here. */let s=(o.year??0)*12+(o.month??1)-1+e;/* c8 ignore stop @preserve */o.year=Math.floor(s/12),o.month=s%12+1,o.month<1&&(o.month+=12,o.year-=1);/* c8 ignore start @preserve -- unreachable: (total % 12) + 1 can never
15
- exceed 12 for any integer total in JS (its range is [-10, 12] since
16
- JS's % can return a negative remainder but never one with
17
- magnitude >= 12, so adding 1 tops out at 12). Only the < 1 branch
18
- above is reachable; this was written symmetrically with it but the
19
- overflow direction it guards against can't occur. Kept rather than
20
- removed since it costs nothing and documents the intent. */o.month>12&&(o.month-=12,o.year+=1);/* c8 ignore stop @preserve */let a=D({year:o.year,month:o.month});o.day>a&&(o.day=a),p(o);break}case"weeks":o=S(o,e*7);break;case"days":o=S(o,e);break;case"hours":o=b(o,e*36e5);break;case"minutes":o=b(o,e*6e4);break;case"seconds":o=b(o,e*1e3);break;case"milliseconds":o=b(o,e);break}return o}function S(n,e){let t=n.year,r=n.month,o=n.day,s=r<=2?t-1:t,a=Math.floor((s>=0?s:s-399)/400),u=s-a*400,c=r>2?r-3:r+9,M=Math.floor((153*c+2)/5)+o-1,d=u*365+Math.floor(u/4)-Math.floor(u/100)+M,f=a*146097+d-719468+e+719468,m=Math.floor((f>=0?f:f-146096)/146097),_=f-m*146097,w=Math.floor((_-Math.floor(_/1460)+Math.floor(_/36524)-Math.floor(_/146096))/365),x=w+m*400,P=_-(365*w+Math.floor(w/4)-Math.floor(w/100)),k=Math.floor((5*P+2)/153),V=P-Math.floor((153*k+2)/5)+1,T=k<10?k+3:k-9,I=T<=2?x+1:x,U={...n,year:I,month:T,day:V};return p(U),U}function b(n,e){let a=(n.hour??0)*36e5+(n.minute??0)*6e4+(n.second??0)*1e3+(n.millisecond??0)+e,u=Math.floor(a/864e5),c=a%864e5;c<0&&(c+=864e5);let M=Math.floor(c/36e5),d=Math.floor(c%36e5/6e4),h=Math.floor(c%6e4/1e3),f=c%1e3,m={...n,hour:M,minute:d,second:h,millisecond:f};return u!==0?S(m,u):m}function y(n,e,t){return i(n,-e,t)}var C=(n,e)=>i(n,e,"years"),H=(n,e)=>i(n,e,"months"),A=(n,e)=>i(n,e,"weeks"),Y=(n,e)=>i(n,e,"days"),W=(n,e)=>i(n,e,"hours"),g=(n,e)=>i(n,e,"minutes"),j=(n,e)=>i(n,e,"seconds"),z=(n,e)=>i(n,e,"milliseconds"),q=(n,e)=>y(n,e,"years"),B=(n,e)=>y(n,e,"months"),G=(n,e)=>y(n,e,"weeks"),J=(n,e)=>y(n,e,"days"),K=(n,e)=>y(n,e,"hours"),L=(n,e)=>y(n,e,"minutes"),Q=(n,e)=>y(n,e,"seconds"),X=(n,e)=>y(n,e,"milliseconds");function l(n,e,t){let r=E(n),o=E(e);if(t==="years")return o.year-r.year;if(t==="months")return o.year*12+o.month-1-(r.year*12+r.month-1);if(t==="weeks"||t==="days"){let h=R(r),m=R(o)-h;return t==="weeks"?Math.trunc(m/7):m}let s=36e5,a=6e4,u=1e3,c=F(r),d=F(o)-c;switch(t){case"hours":return Math.trunc(d/s);case"minutes":return Math.trunc(d/a);case"seconds":return Math.trunc(d/u);case"milliseconds":return d}}function R(n){let e=n.year,t=n.month,r=n.day,o=t<=2?e-1:e,s=Math.floor((o>=0?o:o-399)/400),a=o-s*400,u=t>2?t-3:t+9,c=Math.floor((153*u+2)/5)+r-1,M=a*365+Math.floor(a/4)-Math.floor(a/100)+c;return s*146097+M-719468}function F(n){return R(n)*864e5+(n.hour??0)*36e5+(n.minute??0)*6e4+(n.second??0)*1e3+(n.millisecond??0)}var Z=(n,e)=>l(n,e,"years"),$=(n,e)=>l(n,e,"months"),v=(n,e)=>l(n,e,"weeks"),nn=(n,e)=>l(n,e,"days"),en=(n,e)=>l(n,e,"hours"),on=(n,e)=>l(n,e,"minutes"),tn=(n,e)=>l(n,e,"seconds"),sn=(n,e)=>l(n,e,"milliseconds");export{i as a,y as b,C as c,H as d,A as e,Y as f,W as g,g as h,j as i,z as j,q as k,B as l,G as m,J as n,K as o,L as p,Q as q,X as r,l as s,Z as t,$ as u,v,nn as w,en as x,on as y,tn as z,sn as A};
21
- //# sourceMappingURL=chunk-VQXUMFB2.js.map
@@ -1,2 +0,0 @@
1
- import{k as o,o as u,t as d}from"./chunk-5U5WJ465.js";var a=new Map,h=256,L=256;function g(t){try{return new Intl.Locale(t.replace(/_/g,"-")).toString().toLowerCase()}catch{return t}}function w(t,r){if(typeof t!="string"||t.length===0)throw new o({actual:String(t),reason:"locale string must be non-empty"});if(t.length>h)throw new o({actual:String(t.length),reason:`locale tag must be at most ${h} characters`});u(t,r),f(r,t);let e=g(t);a.set(e,{...r})}function f(t,r){let e=(n,i,c)=>{if(n!==void 0){if(!Array.isArray(n))throw new o({actual:String(n),reason:`locale "${r}": "${i}" must be an array`});if(n.length!==c)throw new o({actual:String(n.length),reason:`locale "${r}": "${i}" must have ${c} entries (got ${n.length})`});for(let s=0;s<n.length;s++){if(typeof n[s]!="string"||n[s].length===0)throw new o({actual:String(n[s]),reason:`locale "${r}": "${i}[${s}]" must be a non-empty string`});if(n[s].length>L)throw new o({actual:String(n[s].length),reason:`locale "${r}": "${i}[${s}]" must be at most ${L} characters`})}}};e(t.quartersLong,"quartersLong",4),e(t.quartersShort,"quartersShort",4),e(t.erasLong,"erasLong",2),e(t.erasShort,"erasShort",2),e(t.ordinals,"ordinals",4)}function b(t){let r=g(t),e=a.get(r);if(e)return e;try{return{...d(t)}}catch{return}}function p(t){let r=g(t);return a.has(r)}export{w as a,b,p as c};
2
- //# sourceMappingURL=chunk-XH46JNPK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/localeRegistry.ts"],"sourcesContent":["// Locale registration and lookup. Extends the\n// existing registerLocaleVocab() surface in localeVocab.ts with\n// registerLocale() / getLocale() / hasLocale() and a richer LocaleVocab\n// that covers quarters, eras, ordinals, duration units, and relative-\n// time language.\n//\n// The existing localeVocab.ts stays as the implementation for months/\n// weekdays/day-periods (those are what tokens.ts's MMMM/MMM/EEEE/EEE/a\n// tokens read). This module wraps it and adds the extended fields.\n\nimport { registerLocaleVocab, getLocaleVocab, type LocaleVocab as BaseLocaleVocab } from './localeVocab.js';\nimport { InvalidLocaleError } from './errors.js';\n\nexport interface ExtendedLocaleVocab extends BaseLocaleVocab {\n // Quarters: Q1..Q4 long form (\"First quarter\", etc.). Default falls\n // back to \"Q1\"..\"Q4\" if not registered.\n quartersLong?: string[];\n quartersShort?: string[];\n // Eras: [\"BC\", \"AD\"] for gregory, etc. Default [\"BC\", \"AD\"].\n erasLong?: string[];\n erasShort?: string[];\n // Ordinal suffix rules: [\"st\", \"nd\", \"rd\", \"th\"] for English. Default\n // empty (the existing 'do' token has English-only ordinal logic baked\n // into tokens.ts; this field lets a custom locale override it).\n ordinals?: string[];\n // Duration unit names: long singular/plural for each unit. Used by\n // formatDuration's locale-aware path when Intl.NumberFormat isn't\n // desired (e.g. for a made-up locale Intl doesn't know about).\n durationUnits?: {\n years: [string, string];\n months: [string, string];\n weeks: [string, string];\n days: [string, string];\n hours: [string, string];\n minutes: [string, string];\n seconds: [string, string];\n milliseconds: [string, string];\n };\n // Relative-time language: words for \"ago\" / \"in\" / \"now\". Used by\n // formatRelative()'s locale-aware path when Intl.RelativeTimeFormat\n // isn't available or doesn't cover a registered locale.\n relativeTime?: {\n past: string;\n future: string;\n now: string;\n };\n}\n\n// Bounded indirectly: every entry here is added by registerLocale(), which\n// first passes registerLocaleVocab() — and THAT registry caps new locales\n// at 500 (MAX_CUSTOM_VOCABS, RangeError past it). So extendedVocabs can\n// never exceed 500 keys; no separate cap is needed (and an unreachable one\n// would only add dead branches).\nconst extendedVocabs = new Map<string, ExtendedLocaleVocab>();\nconst MAX_LOCALE_TAG_LENGTH = 256;\nconst MAX_VOCAB_STRING_LENGTH = 256;\n\nfunction canonicalKey(locale: string): string {\n try {\n return new Intl.Locale(locale.replace(/_/g, '-')).toString().toLowerCase();\n } catch {\n return locale;\n }\n}\n\nexport function registerLocale(locale: string, vocab: ExtendedLocaleVocab): void {\n if (typeof locale !== 'string' || locale.length === 0) {\n throw new InvalidLocaleError({ actual: String(locale), reason: 'locale string must be non-empty' });\n }\n if (locale.length > MAX_LOCALE_TAG_LENGTH) {\n throw new InvalidLocaleError({ actual: String(locale.length), reason: `locale tag must be at most ${MAX_LOCALE_TAG_LENGTH} characters` });\n }\n // Validate the base vocab fields (months/weekdays/day-periods) via\n // the existing registerLocaleVocab — it has the strict-shape checks.\n registerLocaleVocab(locale, vocab);\n // Extended fields are optional; only validate the ones that are present.\n validateExtended(vocab, locale);\n const key = canonicalKey(locale);\n extendedVocabs.set(key, { ...vocab });\n}\n\nfunction validateExtended(vocab: ExtendedLocaleVocab, locale: string): void {\n const checkArray = (val: unknown, key: string, length: number) => {\n if (val === undefined) return;\n if (!Array.isArray(val)) {\n throw new InvalidLocaleError({ actual: String(val), reason: `locale \"${locale}\": \"${key}\" must be an array` });\n }\n if (val.length !== length) {\n throw new InvalidLocaleError({ actual: String(val.length), reason: `locale \"${locale}\": \"${key}\" must have ${length} entries (got ${val.length})` });\n }\n for (let i = 0; i < val.length; i++) {\n if (typeof val[i] !== 'string' || val[i]!.length === 0) {\n throw new InvalidLocaleError({ actual: String(val[i]), reason: `locale \"${locale}\": \"${key}[${i}]\" must be a non-empty string` });\n }\n if (val[i]!.length > MAX_VOCAB_STRING_LENGTH) {\n throw new InvalidLocaleError({ actual: String(val[i]!.length), reason: `locale \"${locale}\": \"${key}[${i}]\" must be at most ${MAX_VOCAB_STRING_LENGTH} characters` });\n }\n }\n };\n checkArray(vocab.quartersLong, 'quartersLong', 4);\n checkArray(vocab.quartersShort, 'quartersShort', 4);\n checkArray(vocab.erasLong, 'erasLong', 2);\n checkArray(vocab.erasShort, 'erasShort', 2);\n checkArray(vocab.ordinals, 'ordinals', 4);\n}\n\nexport function getLocale(locale: string): ExtendedLocaleVocab | undefined {\n // Returns the extended vocab for a locale, OR undefined (falls back\n // to Intl). Combines the base vocab (from localeVocab.ts, which\n // includes Intl defaults) with any extended fields registered here.\n const key = canonicalKey(locale);\n const ext = extendedVocabs.get(key);\n if (ext) return ext;\n // Fall back to base vocab (Intl-derived) without extended fields.\n try {\n const base = getLocaleVocab(locale);\n return { ...base };\n } catch {\n return undefined;\n }\n}\n\nexport function hasLocale(locale: string): boolean {\n const key = canonicalKey(locale);\n return extendedVocabs.has(key);\n}\n\n// Re-export the base vocab types for callers that want them.\nexport type { LocaleVocab } from './localeVocab.js';\n"],"mappings":"sDAqDA,IAAMA,EAAiB,IAAI,IACrBC,EAAwB,IACxBC,EAA0B,IAEhC,SAASC,EAAaC,EAAwB,CAC5C,GAAI,CACF,OAAO,IAAI,KAAK,OAAOA,EAAO,QAAQ,KAAM,GAAG,CAAC,EAAE,SAAS,EAAE,YAAY,CAC3E,MAAQ,CACN,OAAOA,CACT,CACF,CAEO,SAASC,EAAeD,EAAgBE,EAAkC,CAC/E,GAAI,OAAOF,GAAW,UAAYA,EAAO,SAAW,EAClD,MAAM,IAAIG,EAAmB,CAAE,OAAQ,OAAOH,CAAM,EAAG,OAAQ,iCAAkC,CAAC,EAEpG,GAAIA,EAAO,OAASH,EAClB,MAAM,IAAIM,EAAmB,CAAE,OAAQ,OAAOH,EAAO,MAAM,EAAG,OAAQ,8BAA8BH,CAAqB,aAAc,CAAC,EAI1IO,EAAoBJ,EAAQE,CAAK,EAEjCG,EAAiBH,EAAOF,CAAM,EAC9B,IAAMM,EAAMP,EAAaC,CAAM,EAC/BJ,EAAe,IAAIU,EAAK,CAAE,GAAGJ,CAAM,CAAC,CACtC,CAEA,SAASG,EAAiBH,EAA4BF,EAAsB,CAC1E,IAAMO,EAAa,CAACC,EAAcF,EAAaG,IAAmB,CAChE,GAAID,IAAQ,OACZ,IAAI,CAAC,MAAM,QAAQA,CAAG,EACpB,MAAM,IAAIL,EAAmB,CAAE,OAAQ,OAAOK,CAAG,EAAG,OAAQ,WAAWR,CAAM,OAAOM,CAAG,oBAAqB,CAAC,EAE/G,GAAIE,EAAI,SAAWC,EACjB,MAAM,IAAIN,EAAmB,CAAE,OAAQ,OAAOK,EAAI,MAAM,EAAG,OAAQ,WAAWR,CAAM,OAAOM,CAAG,eAAeG,CAAM,iBAAiBD,EAAI,MAAM,GAAI,CAAC,EAErJ,QAASE,EAAI,EAAGA,EAAIF,EAAI,OAAQE,IAAK,CACnC,GAAI,OAAOF,EAAIE,CAAC,GAAM,UAAYF,EAAIE,CAAC,EAAG,SAAW,EACnD,MAAM,IAAIP,EAAmB,CAAE,OAAQ,OAAOK,EAAIE,CAAC,CAAC,EAAG,OAAQ,WAAWV,CAAM,OAAOM,CAAG,IAAII,CAAC,+BAAgC,CAAC,EAElI,GAAIF,EAAIE,CAAC,EAAG,OAASZ,EACnB,MAAM,IAAIK,EAAmB,CAAE,OAAQ,OAAOK,EAAIE,CAAC,EAAG,MAAM,EAAG,OAAQ,WAAWV,CAAM,OAAOM,CAAG,IAAII,CAAC,sBAAsBZ,CAAuB,aAAc,CAAC,CAEvK,EACF,EACAS,EAAWL,EAAM,aAAc,eAAgB,CAAC,EAChDK,EAAWL,EAAM,cAAe,gBAAiB,CAAC,EAClDK,EAAWL,EAAM,SAAU,WAAY,CAAC,EACxCK,EAAWL,EAAM,UAAW,YAAa,CAAC,EAC1CK,EAAWL,EAAM,SAAU,WAAY,CAAC,CAC1C,CAEO,SAASS,EAAUX,EAAiD,CAIzE,IAAMM,EAAMP,EAAaC,CAAM,EACzBY,EAAMhB,EAAe,IAAIU,CAAG,EAClC,GAAIM,EAAK,OAAOA,EAEhB,GAAI,CAEF,MAAO,CAAE,GADIC,EAAeb,CAAM,CACjB,CACnB,MAAQ,CACN,MACF,CACF,CAEO,SAASc,EAAUd,EAAyB,CACjD,IAAMM,EAAMP,EAAaC,CAAM,EAC/B,OAAOJ,EAAe,IAAIU,CAAG,CAC/B","names":["extendedVocabs","MAX_LOCALE_TAG_LENGTH","MAX_VOCAB_STRING_LENGTH","canonicalKey","locale","registerLocale","vocab","InvalidLocaleError","registerLocaleVocab","validateExtended","key","checkArray","val","length","i","getLocale","ext","getLocaleVocab","hasLocale"]}
@@ -1,2 +0,0 @@
1
- import{a as p}from"./chunk-VQXUMFB2.js";import{a as y}from"./chunk-UJR6DHXY.js";function R(t,e){let n=t,r=0,u=[],d=1e4,i=!1,c=!0;function o(f){let a=f;return!(e.byWeekday&&e.byWeekday.length>0&&!e.byWeekday.includes(a.dayOfWeek??0)||e.byMonthDay&&e.byMonthDay.length>0&&!e.byMonthDay.includes(a.day??0)||e.byMonth&&e.byMonth.length>0&&!e.byMonth.includes(a.month??0)||e.exDates&&e.exDates.some(l=>y(l,f)===0))}function s(f,a){let l=e.frequency==="secondly"?"seconds":e.frequency==="minutely"?"minutes":e.frequency==="hourly"?"hours":e.frequency==="daily"?"days":e.frequency==="weekly"?"weeks":e.frequency==="monthly"?"months":"years";return p(f,a*e.interval,l)}function b(f){u.push(f),u.length>d&&u.shift()}function m(f){let a=f,l=0;do{if(a=s(a,1),l++,l>1e3)return i=!0,{value:a,found:!1};if(e.until&&y(a,e.until)>0)return i=!0,{value:a,found:!1}}while(!o(a));return{value:a,found:!0}}return{next(){if(i)return{value:void 0,done:!0};if(c){if(c=!1,o(n))return r++,e.count!==void 0&&r>=e.count&&(i=!0),e.until&&y(n,e.until)>0?(i=!0,{value:void 0,done:!0}):(b(n),{value:n,done:!1});let a=m(n);return a.found?(n=a.value,r++,e.count!==void 0&&r>=e.count&&(i=!0),b(n),{value:n,done:!1}):{value:void 0,done:!0}}let f=m(n);return f.found?(n=f.value,r++,e.count!==void 0&&r>=e.count&&(i=!0),b(n),{value:n,done:!1}):{value:void 0,done:!0}},previous(){return u.length===0?{value:void 0,done:!0}:{value:u.pop(),done:!1}}}}function w(t,e){let n=[];for(let r=0;r<e;r++){let u=t.next();if(u.done)break;n.push(u.value)}return n}var h=1e5;function g(t,e){for(let r=0;r<e&&!t.next().done;r++);let n=[];for(;n.length<h;){let r=t.next();if(r.done)return n;n.push(r.value)}throw new RangeError(`temporal-fmt: skip() collected ${h} occurrences and the rule is still producing \u2014 add a count or until to the rule, or use take(iter, n) for a bounded read.`)}function M(t,e,n,r){let u=R(t,e),d=[];for(;;){let i=u.next();if(i.done||y(i.value,r)>=0)break;y(i.value,n)>=0&&d.push(i.value)}return d}function E(t){let e=t.trim().toUpperCase().replace(/^RRULE:/,"").split(";"),n={frequency:"daily",interval:1},r=new Set(["SECONDLY","MINUTELY","HOURLY","DAILY","WEEKLY","MONTHLY","YEARLY"]);for(let u of e){if(!u)continue;let d=u.indexOf("=");if(d<0)continue;let i=u.slice(0,d),c=u.slice(d+1);switch(i){case"FREQ":if(!r.has(c))throw new RangeError(`temporal-fmt: unsupported RRULE frequency "${c}".`);n.frequency=c.toLowerCase();break;case"INTERVAL":{let o=Number(c);if(!Number.isSafeInteger(o)||o<1)throw new RangeError(`temporal-fmt: RRULE INTERVAL must be a positive safe integer (got "${c}").`);n.interval=o;break}case"COUNT":{let o=Number(c);if(!Number.isSafeInteger(o)||o<1)throw new RangeError(`temporal-fmt: RRULE COUNT must be a positive safe integer (got "${c}").`);n.count=o;break}case"UNTIL":n.until=c;break;case"BYDAY":n.byWeekday=c.split(",").map(o=>{let s=o.match(/^([+-]?\d)?([A-Z]{2})$/);if(!s)return 0;let b=s[2];return{MO:1,TU:2,WE:3,TH:4,FR:5,SA:6,SU:7}[b]??0});break;case"BYMONTHDAY":{let o=c.split(",").map(Number);if(o.some(s=>!Number.isInteger(s)||s===0||s<-31||s>31))throw new RangeError("temporal-fmt: RRULE BYMONTHDAY contains an out-of-range value.");n.byMonthDay=o;break}case"BYMONTH":{let o=c.split(",").map(Number);if(o.some(s=>!Number.isInteger(s)||s<1||s>12))throw new RangeError("temporal-fmt: RRULE BYMONTH contains an out-of-range value.");n.byMonth=o;break}}}return n}function N(t){let e=[`FREQ=${t.frequency.toUpperCase()}`];if(t.interval!==1&&e.push(`INTERVAL=${t.interval}`),t.count!==void 0&&e.push(`COUNT=${t.count}`),t.until!==void 0&&e.push(`UNTIL=${String(t.until)}`),t.byWeekday&&t.byWeekday.length>0){let n={1:"MO",2:"TU",3:"WE",4:"TH",5:"FR",6:"SA",7:"SU"};e.push(`BYDAY=${t.byWeekday.map(r=>n[r]).join(",")}`)}return t.byMonthDay&&t.byMonthDay.length>0&&e.push(`BYMONTHDAY=${t.byMonthDay.join(",")}`),t.byMonth&&t.byMonth.length>0&&e.push(`BYMONTH=${t.byMonth.join(",")}`),e.join(";")}export{R as a,w as b,g as c,M as d,E as e,N as f};
2
- //# sourceMappingURL=chunk-ZGMTY52O.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/recurrence.ts"],"sourcesContent":["// Recurrence engine. Deterministic RRULE-like\n// recurrence without pulling in a runtime dependency. Supports\n// secondly/minutely/hourly/daily/weekly/monthly/yearly frequencies,\n// interval, count, until, weekdays, monthDays, positional rules,\n// exclusions, inclusions.\n//\n// RRULE interop: parseRRule() / formatRRule() convert to/from the\n// standard iCalendar RRULE string format (RFC 5545). Implemented\n// without depending on a RRULE library — the grammar is small enough\n// to handle inline.\n\nimport { add } from './arithmetic.js';\nimport { compare } from './comparison.js';\n\nexport type RecurrenceFrequency = 'secondly' | 'minutely' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly';\n\nexport interface RecurrenceRule {\n frequency: RecurrenceFrequency;\n interval: number; // default 1\n count?: number; // max occurrences\n until?: unknown; // Temporal value — recurrence ends before this\n // For weekly: ISO weekdays to include (1=Mon..7=Sun). Empty = all.\n byWeekday?: number[];\n // For monthly/yearly: days of month to include (1-31, or negative\n // for end-of-month: -1 = last day).\n byMonthDay?: number[];\n // For yearly: months to include (1-12).\n byMonth?: number[];\n // For weekly: which week of the year (1-53).\n byWeek?: number[];\n // Exclusions: dates to skip even if they match the rule.\n exDates?: unknown[];\n // Inclusions: dates to add even if they don't match the rule.\n rDates?: unknown[];\n}\n\nexport interface RecurrenceIterator {\n next(): { value: unknown; done: boolean } | { value: undefined; done: true };\n previous(): { value: unknown; done: boolean } | { value: undefined; done: true };\n}\n\n// Creates a recurrence iterator starting from `start`. The first call\n// to next() returns `start` itself (if it matches the rule); subsequent\n// calls return the next matching occurrence.\nexport function recurrence(start: unknown, rule: RecurrenceRule): RecurrenceIterator {\n let current: unknown = start;\n let count = 0;\n // Track past values for previous() — keeps a ring buffer of the last\n // N occurrences so previous() can walk back without recomputing.\n const history: unknown[] = [];\n const MAX_HISTORY = 10_000;\n let atEnd = false;\n let atStart = true;\n\n function matches(value: unknown): boolean {\n const v = value as { dayOfWeek?: number; day?: number; month?: number; year?: number; hour?: number; minute?: number; second?: number };\n if (rule.byWeekday && rule.byWeekday.length > 0) {\n if (!rule.byWeekday.includes(v.dayOfWeek ?? 0)) return false;\n }\n if (rule.byMonthDay && rule.byMonthDay.length > 0) {\n if (!rule.byMonthDay.includes(v.day ?? 0)) return false;\n }\n if (rule.byMonth && rule.byMonth.length > 0) {\n if (!rule.byMonth.includes(v.month ?? 0)) return false;\n }\n if (rule.exDates && rule.exDates.some((d) => compare(d, value) === 0)) return false;\n return true;\n }\n\n function advance(value: unknown, steps: number): unknown {\n // Add `steps` * interval units to `value`.\n const unit = rule.frequency === 'secondly' ? 'seconds'\n : rule.frequency === 'minutely' ? 'minutes'\n : rule.frequency === 'hourly' ? 'hours'\n : rule.frequency === 'daily' ? 'days'\n : rule.frequency === 'weekly' ? 'weeks'\n : rule.frequency === 'monthly' ? 'months'\n : 'years';\n return add(value, steps * rule.interval, unit as Parameters<typeof add>[2]);\n }\n\n function recordHistory(value: unknown): void {\n history.push(value);\n if (history.length > MAX_HISTORY) history.shift();\n }\n\n function nextMatch(value: unknown): { value: unknown; found: boolean } {\n // Advance one step at a time until we find a match. For\n // byWeekday/byMonthDay rules this can skip multiple steps.\n let candidate = value;\n let safetyCounter = 0;\n do {\n candidate = advance(candidate, 1);\n safetyCounter++;\n if (safetyCounter > 1000) {\n // Defensive — if the rule is so restrictive no match exists\n // within 1000 steps, give up rather than spin forever. The\n // caller must treat this as \"no more occurrences\", not as a\n // real match — returning the unmatched candidate here used to\n // get handed back to next()'s caller as if it were valid.\n atEnd = true;\n return { value: candidate, found: false };\n }\n if (rule.until && compare(candidate, rule.until) > 0) {\n atEnd = true;\n return { value: candidate, found: false };\n }\n } while (!matches(candidate));\n return { value: candidate, found: true };\n }\n\n return {\n next() {\n if (atEnd) return { value: undefined, done: true };\n if (atStart) {\n atStart = false;\n if (matches(current)) {\n count++;\n if (rule.count !== undefined && count >= rule.count) atEnd = true;\n if (rule.until && compare(current, rule.until) > 0) {\n atEnd = true;\n return { value: undefined, done: true };\n }\n // Include rDates that match the current value.\n recordHistory(current);\n return { value: current, done: false };\n }\n // If start doesn't match, advance to first match.\n const advanced = nextMatch(current);\n if (!advanced.found) return { value: undefined, done: true };\n current = advanced.value;\n count++;\n if (rule.count !== undefined && count >= rule.count) atEnd = true;\n recordHistory(current);\n return { value: current, done: false };\n }\n const advanced = nextMatch(current);\n if (!advanced.found) return { value: undefined, done: true };\n current = advanced.value;\n count++;\n if (rule.count !== undefined && count >= rule.count) atEnd = true;\n recordHistory(current);\n return { value: current, done: false };\n },\n previous() {\n if (history.length === 0) return { value: undefined, done: true };\n const v = history.pop()!;\n return { value: v, done: false };\n },\n };\n}\n\n// Take N occurrences from a recurrence iterator.\nexport function take(iter: RecurrenceIterator, n: number): unknown[] {\n const result: unknown[] = [];\n for (let i = 0; i < n; i++) {\n const r = iter.next();\n if (r.done) break;\n result.push(r.value);\n }\n return result;\n}\n\n// Upper bound on how many occurrences skip() will collect after its\n// skip phase. skip() used to call take(iter, Number.MAX_SAFE_INTEGER),\n// and an iterator over an unbounded rule (no count, no until — e.g.\n// { frequency: 'daily', interval: 1 }) never returns done: next() always\n// has another day. The call then looped forever, pushing into a result\n// array until the process OOM'd. Same cap style as businessCalendar.ts.\nconst MAX_SKIP_COLLECTION = 100_000;\n\n// Skip N occurrences from a recurrence iterator, returning the ones\n// that follow. Throws a RangeError when the iterator is still producing\n// occurrences after MAX_SKIP_COLLECTION — that means the rule is\n// unbounded (no count/until) and \"everything after the skip\" has no\n// finite answer.\nexport function skip(iter: RecurrenceIterator, n: number): unknown[] {\n for (let i = 0; i < n; i++) {\n const r = iter.next();\n if (r.done) break;\n }\n const result: unknown[] = [];\n while (result.length < MAX_SKIP_COLLECTION) {\n const r = iter.next();\n if (r.done) return result;\n result.push(r.value);\n }\n throw new RangeError(\n `temporal-fmt: skip() collected ${MAX_SKIP_COLLECTION} occurrences and the rule is still ` +\n `producing — add a count or until to the rule, or use take(iter, n) for a bounded read.`\n );\n}\n\n// All occurrences between two dates (inclusive of start, exclusive of end).\nexport function between(start: unknown, rule: RecurrenceRule, rangeStart: unknown, rangeEnd: unknown): unknown[] {\n const iter = recurrence(start, rule);\n const result: unknown[] = [];\n while (true) {\n const r = iter.next();\n if (r.done) break;\n if (compare(r.value, rangeEnd) >= 0) break;\n if (compare(r.value, rangeStart) >= 0) result.push(r.value);\n }\n return result;\n}\n\n// Parses an RRULE string like \"FREQ=DAILY;INTERVAL=2;COUNT=5\" into a\n// RecurrenceRule. Doesn't support every RRULE feature (BYSETPOS,\n// BYHOUR, BYMINUTE, BYSECOND are parsed but not enforced by the\n// recurrence iterator above), but covers the common cases.\nexport function parseRRule(input: string): RecurrenceRule {\n const parts = input.trim().toUpperCase().replace(/^RRULE:/, '').split(';');\n const rule: RecurrenceRule = { frequency: 'daily', interval: 1 };\n const frequencies: ReadonlySet<string> = new Set([\n 'SECONDLY', 'MINUTELY', 'HOURLY', 'DAILY', 'WEEKLY', 'MONTHLY', 'YEARLY',\n ]);\n for (const part of parts) {\n if (!part) continue;\n const eq = part.indexOf('=');\n if (eq < 0) continue;\n const key = part.slice(0, eq);\n const value = part.slice(eq + 1);\n switch (key) {\n case 'FREQ':\n if (!frequencies.has(value)) {\n throw new RangeError(`temporal-fmt: unsupported RRULE frequency \"${value}\".`);\n }\n rule.frequency = value.toLowerCase() as RecurrenceFrequency;\n break;\n case 'INTERVAL': {\n const interval = Number(value);\n if (!Number.isSafeInteger(interval) || interval < 1) {\n throw new RangeError(`temporal-fmt: RRULE INTERVAL must be a positive safe integer (got \"${value}\").`);\n }\n rule.interval = interval;\n break;\n }\n case 'COUNT': {\n const count = Number(value);\n if (!Number.isSafeInteger(count) || count < 1) {\n throw new RangeError(`temporal-fmt: RRULE COUNT must be a positive safe integer (got \"${value}\").`);\n }\n rule.count = count;\n break;\n }\n case 'UNTIL':\n rule.until = value;\n break;\n case 'BYDAY':\n rule.byWeekday = value.split(',').map((d) => {\n const m = d.match(/^([+-]?\\d)?([A-Z]{2})$/);\n if (!m) return 0;\n const wd = m[2];\n const map: Record<string, number> = { MO: 1, TU: 2, WE: 3, TH: 4, FR: 5, SA: 6, SU: 7 };\n return map[wd!] ?? 0;\n });\n break;\n case 'BYMONTHDAY': {\n const values = value.split(',').map(Number);\n if (values.some((day) => !Number.isInteger(day) || day === 0 || day < -31 || day > 31)) {\n throw new RangeError(`temporal-fmt: RRULE BYMONTHDAY contains an out-of-range value.`);\n }\n rule.byMonthDay = values;\n break;\n }\n case 'BYMONTH': {\n const values = value.split(',').map(Number);\n if (values.some((month) => !Number.isInteger(month) || month < 1 || month > 12)) {\n throw new RangeError(`temporal-fmt: RRULE BYMONTH contains an out-of-range value.`);\n }\n rule.byMonth = values;\n break;\n }\n }\n }\n return rule;\n}\n\nexport function formatRRule(rule: RecurrenceRule): string {\n const parts: string[] = [`FREQ=${rule.frequency.toUpperCase()}`];\n if (rule.interval !== 1) parts.push(`INTERVAL=${rule.interval}`);\n if (rule.count !== undefined) parts.push(`COUNT=${rule.count}`);\n if (rule.until !== undefined) parts.push(`UNTIL=${String(rule.until)}`);\n if (rule.byWeekday && rule.byWeekday.length > 0) {\n const map: Record<number, string> = { 1: 'MO', 2: 'TU', 3: 'WE', 4: 'TH', 5: 'FR', 6: 'SA', 7: 'SU' };\n parts.push(`BYDAY=${rule.byWeekday.map((d) => map[d]).join(',')}`);\n }\n if (rule.byMonthDay && rule.byMonthDay.length > 0) parts.push(`BYMONTHDAY=${rule.byMonthDay.join(',')}`);\n if (rule.byMonth && rule.byMonth.length > 0) parts.push(`BYMONTH=${rule.byMonth.join(',')}`);\n return parts.join(';');\n}"],"mappings":"gFA4CO,SAASA,EAAWC,EAAgB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pF5C,EAAK,QAAU0C,EACf,KACF,CACF,CACF,CACA,OAAO1C,CACT,CAEO,SAAS6C,EAAY7C,EAA8B,CACxD,IAAMkC,EAAkB,CAAC,QAAQlC,EAAK,UAAU,YAAY,CAAC,EAAE,EAI/D,GAHIA,EAAK,WAAa,GAAGkC,EAAM,KAAK,YAAYlC,EAAK,QAAQ,EAAE,EAC3DA,EAAK,QAAU,QAAWkC,EAAM,KAAK,SAASlC,EAAK,KAAK,EAAE,EAC1DA,EAAK,QAAU,QAAWkC,EAAM,KAAK,SAAS,OAAOlC,EAAK,KAAK,CAAC,EAAE,EAClEA,EAAK,WAAaA,EAAK,UAAU,OAAS,EAAG,CAC/C,IAAM8C,EAA8B,CAAE,EAAG,KAAM,EAAG,KAAM,EAAG,KAAM,EAAG,KAAM,EAAG,KAAM,EAAG,KAAM,EAAG,IAAK,EACpGZ,EAAM,KAAK,SAASlC,EAAK,UAAU,IAAKU,GAAMoC,EAAIpC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CACnE,CACA,OAAIV,EAAK,YAAcA,EAAK,WAAW,OAAS,GAAGkC,EAAM,KAAK,cAAclC,EAAK,WAAW,KAAK,GAAG,CAAC,EAAE,EACnGA,EAAK,SAAWA,EAAK,QAAQ,OAAS,GAAGkC,EAAM,KAAK,WAAWlC,EAAK,QAAQ,KAAK,GAAG,CAAC,EAAE,EACpFkC,EAAM,KAAK,GAAG,CACvB","names":["recurrence","start","rule","current","count","history","MAX_HISTORY","atEnd","atStart","matches","value","v","d","compare","advance","steps","unit","add","recordHistory","nextMatch","candidate","safetyCounter","advanced","take","iter","n","result","i","r","MAX_SKIP_COLLECTION","skip","between","rangeStart","rangeEnd","parseRRule","input","parts","frequencies","part","eq","key","interval","m","wd","values","day","month","formatRRule","map"]}