temporal-fmt 0.9.2 → 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.
- package/README.md +480 -9
- package/dist/calendarUtils.cjs +259 -4
- package/dist/calendarUtils.cjs.map +1 -1
- package/dist/calendarUtils.js +33 -1
- package/dist/chunk-4N3WCGEY.js +183 -0
- package/dist/{chunk-4JWGUR4O.js.map → chunk-4N3WCGEY.js.map} +1 -1
- package/dist/chunk-5UTV5VP6.js +984 -0
- package/dist/chunk-5UTV5VP6.js.map +1 -0
- package/dist/chunk-ACKKWH5Z.js +578 -0
- package/dist/{chunk-2JHEV7ZF.js.map → chunk-ACKKWH5Z.js.map} +1 -1
- package/dist/chunk-EGUUO6LE.js +439 -0
- package/dist/chunk-EGUUO6LE.js.map +1 -0
- package/dist/chunk-FBPHNRVW.js +2939 -0
- package/dist/chunk-FBPHNRVW.js.map +1 -0
- package/dist/chunk-GPB4JHGI.js +65 -0
- package/dist/chunk-GPB4JHGI.js.map +1 -0
- package/dist/chunk-H7YQX25T.js +170 -0
- package/dist/{chunk-J2AQNXF2.js.map → chunk-H7YQX25T.js.map} +1 -1
- package/dist/chunk-HXY2GUUM.js +182 -0
- package/dist/{chunk-EHLRZULM.js.map → chunk-HXY2GUUM.js.map} +1 -1
- package/dist/chunk-L24NPTAJ.js +328 -0
- package/dist/chunk-L24NPTAJ.js.map +1 -0
- package/dist/chunk-M3GDTHMT.js +169 -0
- package/dist/chunk-M3GDTHMT.js.map +1 -0
- package/dist/chunk-MKPDLQKD.js +51 -0
- package/dist/chunk-MKPDLQKD.js.map +1 -0
- package/dist/chunk-TSLPIURC.js +242 -0
- package/dist/{chunk-VQXUMFB2.js.map → chunk-TSLPIURC.js.map} +1 -1
- package/dist/chunk-UOPAV3WX.js +75 -0
- package/dist/chunk-UOPAV3WX.js.map +1 -0
- package/dist/chunk-VNIUIQA4.js +398 -0
- package/dist/chunk-VNIUIQA4.js.map +1 -0
- package/dist/chunk-YEUASGDK.js +9 -0
- package/dist/chunk-YEUASGDK.js.map +1 -0
- package/dist/chunk-ZQZF5EXW.js +29 -0
- package/dist/chunk-ZQZF5EXW.js.map +1 -0
- package/dist/config.d.cts +4 -2
- package/dist/config.d.ts +4 -2
- package/dist/duration.cjs +638 -26
- package/dist/duration.cjs.map +1 -1
- package/dist/duration.js +28 -1
- package/dist/format.cjs +833 -35
- package/dist/format.cjs.map +1 -1
- package/dist/format.js +20 -1
- package/dist/index.cjs +7698 -163
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +108 -24
- package/dist/index.d.ts +108 -24
- package/dist/index.js +1536 -58
- package/dist/index.js.map +1 -1
- package/dist/interval.cjs +5480 -35
- package/dist/interval.cjs.map +1 -1
- package/dist/interval.js +46 -1
- package/dist/localeRegistry.cjs +375 -32
- package/dist/localeRegistry.cjs.map +1 -1
- package/dist/localeRegistry.js +11 -1
- package/dist/modApi.d.cts +131 -0
- package/dist/modApi.d.ts +131 -0
- package/dist/parse.cjs +1797 -70
- package/dist/parse.cjs.map +1 -1
- package/dist/parse.js +20 -1
- package/dist/pattern.d.cts +1 -0
- package/dist/pattern.d.ts +1 -0
- package/dist/recurrence.cjs +452 -20
- package/dist/recurrence.cjs.map +1 -1
- package/dist/recurrence.js +19 -1
- package/dist/relativeTime.cjs +268 -21
- package/dist/relativeTime.cjs.map +1 -1
- package/dist/relativeTime.js +14 -1
- package/dist/runtime.d.cts +201 -0
- package/dist/runtime.d.ts +201 -0
- package/dist/timezone.cjs +387 -20
- package/dist/timezone.cjs.map +1 -1
- package/dist/timezone.js +26 -1
- package/package.json +4 -6
- package/scripts/cli.mjs +27 -5
- package/dist/chunk-2JHEV7ZF.js +0 -7
- package/dist/chunk-3MZLTVP3.js +0 -2
- package/dist/chunk-3MZLTVP3.js.map +0 -1
- package/dist/chunk-4JWGUR4O.js +0 -11
- package/dist/chunk-5U5WJ465.js +0 -36
- package/dist/chunk-5U5WJ465.js.map +0 -1
- package/dist/chunk-C5YESWFT.js +0 -2
- package/dist/chunk-C5YESWFT.js.map +0 -1
- package/dist/chunk-C6ZZ62ET.js +0 -2
- package/dist/chunk-C6ZZ62ET.js.map +0 -1
- package/dist/chunk-EHLRZULM.js +0 -5
- package/dist/chunk-F4RGUDA3.js +0 -2
- package/dist/chunk-F4RGUDA3.js.map +0 -1
- package/dist/chunk-J2AQNXF2.js +0 -2
- package/dist/chunk-NBXF7V5B.js +0 -2
- package/dist/chunk-NBXF7V5B.js.map +0 -1
- package/dist/chunk-R52YOKI3.js +0 -7
- package/dist/chunk-R52YOKI3.js.map +0 -1
- package/dist/chunk-UJR6DHXY.js +0 -2
- package/dist/chunk-UJR6DHXY.js.map +0 -1
- package/dist/chunk-VQXUMFB2.js +0 -21
- package/dist/chunk-XH46JNPK.js +0 -2
- package/dist/chunk-XH46JNPK.js.map +0 -1
- package/dist/chunk-YB6YAG7E.js +0 -35
- package/dist/chunk-YB6YAG7E.js.map +0 -1
- package/dist/chunk-ZGMTY52O.js +0 -2
- package/dist/chunk-ZGMTY52O.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,59 +1,1537 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* unit word here without a matching regex update. */throw new Error(`temporal-fmt: parseRelative internal error \u2014 unrecognized unit word "${e}".`);/* c8 ignore stop @preserve */}function no(e,n,t={}){let r=n,a=A(),o=(e??"").trim().replace(/\s+/g," ");if(o.length===0)throw new Error("temporal-fmt: parseRelative got an empty input string.");if(o.length>te)throw new RangeError(`temporal-fmt: parseRelative input is too large (maximum ${te} characters).`);let s=k(o),d=Vr(t.locale),i={temporal:a,reference:r},m=_e(eo(t.locale),o,{year:r.year,month:r.month,day:r.day,dayOfWeek:r.dayOfWeek});if(m!==null)return m;let l=y=>{for(let f of d.matchers){let c=y.match(f.pattern);if(c)return f.resolve(c,i)}return be},T=l(s);if(T!==be)return T;if(t.fuzzy){if(d!==Z)throw new Error("temporal-fmt: parseRelative's { fuzzy: true } option currently only supports English. Pass no locale (or locale: 'en'), or omit { fuzzy: true } for this locale.");let y=Xr(s);if(y!==void 0){let f=l(y);if(f!==be)return f}}throw new Error(`temporal-fmt: parseRelative doesn't recognize "${o}". `+d.supportedHint)}var be=Symbol("temporal-fmt: parseRelative no match");function M(e){return typeof e=="object"&&e!==null}function x(e){return n=>{try{return e(n)}catch{return!1}}}function h(e,n){return typeof e[n]=="function"}function $(e,n){return M(e)?e[Symbol.toStringTag]===`Temporal.${n}`:!1}var Xe=x(function(n){if($(n,"PlainDate"))return!0;if(!M(n))return!1;let t=n;return typeof t.year=="number"&&typeof t.month=="number"&&typeof t.day=="number"&&typeof t.hour>"u"&&h(t,"toPlainDateTime")&&h(t,"withCalendar")}),qe=x(function(n){if($(n,"PlainTime"))return!0;if(!M(n))return!1;let t=n;return typeof t.hour=="number"&&typeof t.year>"u"&&!h(t,"withCalendar")&&!h(t,"toPlainDate")&&!h(t,"toPlainDateTime")}),Ke=x(function(n){if($(n,"PlainDateTime"))return!0;if(!M(n))return!1;let t=n;return typeof t.year=="number"&&typeof t.month=="number"&&typeof t.day=="number"&&typeof t.hour=="number"&&h(t,"withPlainTime")&&!h(t,"toInstant")}),Je=x(function(n){if($(n,"ZonedDateTime"))return!0;if(!M(n))return!1;let t=n;return typeof t.year=="number"&&typeof t.month=="number"&&typeof t.day=="number"&&typeof t.hour=="number"&&h(t,"withTimeZone")&&h(t,"toInstant")}),Qe=x(function(n){if($(n,"Instant"))return!0;if(!M(n))return!1;let t=n;return h(t,"toZonedDateTimeISO")&&!h(t,"toInstant")&&typeof t.year>"u"}),Ve=x(function(n){if($(n,"PlainYearMonth"))return!0;if(!M(n))return!1;let t=n;return typeof t.year=="number"&&typeof t.month=="number"&&typeof t.day>"u"&&h(t,"toPlainDate")}),en=x(function(n){if($(n,"PlainMonthDay"))return!0;if(!M(n))return!1;let t=n;return typeof t.year>"u"&&typeof t.month>"u"&&typeof t.day=="number"&&typeof t.monthCode=="string"&&h(t,"toPlainDate")}),nn=x(function(n){return $(n,"Duration")?!0:M(n)?h(n,"total"):!1}),tn=x(function(n){if(!M(n))return!1;let t=n[Symbol.toStringTag];if(typeof t=="string"&&t.startsWith("Temporal."))return!0;let r=n;return h(r,"toInstant")||h(r,"toPlainDate")||h(r,"toPlainDateTime")||h(r,"toPlainTime")||h(r,"toPlainYearMonth")||h(r,"toPlainMonthDay")||h(r,"toZonedDateTime")||h(r,"toZonedDateTimeISO")||h(r,"withCalendar")||h(r,"withPlainTime")||h(r,"withTimeZone")||h(r,"total")});function to(e){if(e===null)return"null";if(Array.isArray(e))return"array";if(typeof e=="object"){let n=e.constructor;return n&&typeof n.name=="string"&&n.name!=="Object"?`instance of ${n.name}`:"plain object"}return typeof e}function C(e,n,t){if(!n(e))throw new Error(`temporal-fmt: expected a Temporal.${t}, got ${to(e)}.`)}function ro(e){C(e,tn,"object (Instant, PlainDate, PlainTime, PlainDateTime, ZonedDateTime, Duration, PlainYearMonth, or PlainMonthDay)")}function oo(e){C(e,Qe,"Instant")}function ao(e){C(e,Xe,"PlainDate")}function io(e){C(e,qe,"PlainTime")}function so(e){C(e,Ke,"PlainDateTime")}function lo(e){C(e,Je,"ZonedDateTime")}function mo(e){C(e,Ve,"PlainYearMonth")}function uo(e){C(e,en,"PlainMonthDay")}function co(e){C(e,nn,"Duration")}var u={year:["PlainDate","PlainDateTime","ZonedDateTime","PlainYearMonth"],month:["PlainDate","PlainDateTime","ZonedDateTime","PlainYearMonth","PlainMonthDay"],day:["PlainDate","PlainDateTime","ZonedDateTime","PlainMonthDay"],hour:["PlainTime","PlainDateTime","ZonedDateTime","Instant"],minute:["PlainTime","PlainDateTime","ZonedDateTime","Instant"],second:["PlainTime","PlainDateTime","ZonedDateTime","Instant"],millisecond:["PlainTime","PlainDateTime","ZonedDateTime","Instant"],dayOfWeek:["PlainDate","PlainDateTime","ZonedDateTime"],timeZoneId:["ZonedDateTime"],offset:["ZonedDateTime"]},R={yyyy:{meaning:"Four-digit year (preserves sign for BCE; no truncation).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.year,roundTripSafe:!0},yy:{meaning:"Two-digit year (year % 100). Throws on negative years.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.year,roundTripSafe:!1},MMMM:{meaning:'Long month name (locale-aware, e.g. "January", "janvier").',formatCapable:!0,parseCapable:!0,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},MMM:{meaning:'Short month name (locale-aware, e.g. "Jan", "janv.").',formatCapable:!0,parseCapable:!0,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},MM:{meaning:"Two-digit month (01-12, zero-padded).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},M:{meaning:"One- or two-digit month (1-12, no padding).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},dd:{meaning:"Two-digit day-of-month (01-31, zero-padded).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.day,roundTripSafe:!0},d:{meaning:"One- or two-digit day-of-month (1-31, no padding).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.day,roundTripSafe:!0},EEEE:{meaning:'Long weekday name (locale-aware, e.g. "Monday", "lundi"). Parse cross-checks against the parsed date.',formatCapable:!0,parseCapable:!0,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.dayOfWeek,roundTripSafe:!0},EEE:{meaning:'Short weekday name (locale-aware, e.g. "Mon", "lun."). Parse cross-checks against the parsed date.',formatCapable:!0,parseCapable:!0,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.dayOfWeek,roundTripSafe:!0},HH:{meaning:"Two-digit hour, 24-hour clock (00-23, zero-padded).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.hour,roundTripSafe:!0},H:{meaning:"One- or two-digit hour, 24-hour clock (0-23, no padding).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.hour,roundTripSafe:!0},hh:{meaning:"Two-digit hour, 12-hour clock (01-12, zero-padded). Requires `a` token on parse.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.hour,roundTripSafe:!0},h:{meaning:"One- or two-digit hour, 12-hour clock (1-12, no padding). Requires `a` token on parse.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.hour,roundTripSafe:!0},mm:{meaning:"Two-digit minute (00-59, zero-padded).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.minute,roundTripSafe:!0},m:{meaning:"One- or two-digit minute (0-59, no padding).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.minute,roundTripSafe:!0},ss:{meaning:"Two-digit second (00-59, zero-padded).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.second,roundTripSafe:!0},s:{meaning:"One- or two-digit second (0-59, no padding).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.second,roundTripSafe:!0},S:{meaning:"Fractional second, 1 digit (tenths of a second).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SS:{meaning:"Fractional second, 2 digits (hundredths of a second).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSS:{meaning:"Fractional second, 3 digits (milliseconds).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSSS:{meaning:"Fractional second, 4 digits (tens of microseconds).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSSSS:{meaning:"Fractional second, 5 digits (hundred-thousandths of a second).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSSSSS:{meaning:"Fractional second, 6 digits (microseconds).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSSSSSS:{meaning:"Fractional second, 7 digits (tens of nanoseconds).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSSSSSSS:{meaning:"Fractional second, 8 digits (hundred-millionths of a second).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSSSSSSSS:{meaning:"Fractional second, 9 digits (nanoseconds).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},a:{meaning:'Day period (locale-aware: "AM"/"PM", "\u5348\u524D"/"\u5348\u5F8C", etc.). Required alongside 12-hour tokens on parse.',formatCapable:!0,parseCapable:!0,localeSensitive:!0,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.hour,roundTripSafe:!0},zzz:{meaning:'IANA time zone id (e.g. "America/New_York") or fixed offset ("+05:30"). Requires full date+time on parse.',formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.timeZoneId,roundTripSafe:!0},X:{meaning:"Numeric UTC offset, short (Z for UTC, \xB1HH[MM] otherwise). Minutes omitted when zero.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.offset,roundTripSafe:!0},XX:{meaning:"Numeric UTC offset, no colon (Z for UTC, \xB1HHMM otherwise).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.offset,roundTripSafe:!0},XXX:{meaning:"Numeric UTC offset, with colon (Z for UTC, \xB1HH:MM otherwise).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.offset,roundTripSafe:!0},x:{meaning:"Numeric UTC offset, short, never Z (always \xB1HH[MM]). Lowercase variant of X.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.offset,roundTripSafe:!0},xx:{meaning:"Numeric UTC offset, no colon, never Z (always \xB1HHMM). Lowercase variant of XX.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.offset,roundTripSafe:!0},xxx:{meaning:"Numeric UTC offset, with colon, never Z (always \xB1HH:MM). Lowercase variant of XXX.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.offset,roundTripSafe:!0},do:{meaning:'Ordinal day-of-month with English suffix ("1st", "2nd", "3rd", "4th", ... 21st, 22nd, ...). Format-only \u2014 not parseable.',formatCapable:!0,parseCapable:!1,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.day,roundTripSafe:!1},Q:{meaning:"Quarter as a digit (1-4). Derived from month.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},QQQ:{meaning:'Quarter with "Q" prefix ("Q1".."Q4"). Derived from month.',formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},ww:{meaning:"ISO 8601 week number (01-53). Format-only \u2014 week alone can't reconstruct a date.",formatCapable:!0,parseCapable:!1,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.dayOfWeek,roundTripSafe:!1},RRRR:{meaning:"ISO 8601 week-numbering year (4-digit, may differ from calendar year at year boundaries). Format-only.",formatCapable:!0,parseCapable:!1,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.dayOfWeek,roundTripSafe:!1},D:{meaning:"Day of year, unpadded (1-366). Format-only \u2014 parsing requires resolving against a year.",formatCapable:!0,parseCapable:!1,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.day,roundTripSafe:!1},DD:{meaning:"Day of year, 2-digit minimum (01-366). Format-only.",formatCapable:!0,parseCapable:!1,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.day,roundTripSafe:!1},DDD:{meaning:"Day of year, 3-digit zero-padded (001-366). Format-only.",formatCapable:!0,parseCapable:!1,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.day,roundTripSafe:!1},LLLL:{meaning:"Stand-alone long month name (nominative case in Slavic locales). Identical to MMMM in most locales.",formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},LLL:{meaning:"Stand-alone short month name. Identical to MMM in most locales.",formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},cccc:{meaning:"Stand-alone long weekday name. Identical to EEEE in most locales.",formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.dayOfWeek,roundTripSafe:!0},ccc:{meaning:"Stand-alone short weekday name. Identical to EEE in most locales.",formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.dayOfWeek,roundTripSafe:!0},GGGG:{meaning:'Long era name (locale-aware, e.g. "Anno Domini"/"Before Christ"). Format-only.',formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.year,roundTripSafe:!1},G:{meaning:'Short era name (locale-aware, e.g. "AD"/"BC"). Format-only.',formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.year,roundTripSafe:!1},zzzz:{meaning:'Localized long timezone name (e.g. "Eastern Standard Time"). Format-only.',formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.timeZoneId,roundTripSafe:!1},z:{meaning:'Localized short timezone name (e.g. "EST"). Format-only.',formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.timeZoneId,roundTripSafe:!1}},me=Object.keys(R);function fo(e){return q(e)}function rn(){return X.map(([e])=>({name:e,metadata:R[e]}))}function po(e){return R[e]}function W(e){if(e.length>1e3)throw new Error(`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${e.length}).`);let n=q(e),t=[],r=new Set,a=new Set,o=!0,s=!1,d=!1,i=!1,m=!0,l=[],T=0,y=[],f=()=>{y.length>=2&&l.push({code:"AMBIGUOUS_NUMERIC_RUN",message:`Adjacent unpadded numeric tokens "${y.join("")}" with no separator can be ambiguous to parse. Add a separator or use the padded form (e.g. "MM" instead of "M").`}),y.length=0};for(let p of n){if(p.kind==="literal"){T+=p.value.length,f();continue}let E=R[p.value];if(!E){l.push({code:"UNKNOWN_TOKEN_NO_METADATA",message:`Token "${p.value}" is recognized by the tokenizer but has no metadata entry in tokenMetadata.ts \u2014 this is a bug in temporal-fmt.`}),T+=p.value.length;continue}t.push({name:p.value,position:T,metadata:E});let Re=he(p.value);if(Re&&r.add(Re.field),t.length===1)for(let Y of E.supportedTypes)a.add(Y);else{let Y=new Set;for(let B of a)E.supportedTypes.includes(B)&&Y.add(B);a.clear();for(let B of Y)a.add(B)}E.parseCapable||(o=!1,l.push({code:"FORMAT_ONLY_TOKEN",message:`Token "${p.value}" is format-only \u2014 it can't be parsed back into a value. Use a parse-capable variant (e.g. "d" instead of "do") if you need round-trip.`})),E.localeSensitive&&(s=!0),E.calendarSensitive&&(d=!0),E.timezoneSensitive&&(i=!0),E.roundTripSafe||(m=!1),Ae.has(p.value)?y.push(p.value):f(),T+=p.value.length}f();let c=t.map(p=>p.name),g=c.some(p=>p==="hh"||p==="h"),D=c.some(p=>p==="HH"||p==="H"),pn=c.some(p=>p==="a");g&&!pn&&l.push({code:"TWELVE_HOUR_WITHOUT_A",message:`12-hour token ("hh"/"h") used without an "a" (AM/PM) token \u2014 parse() can't tell AM from PM and throws at runtime.`}),g&&D&&l.push({code:"MIXED_12_AND_24_HOUR",message:"Mixing 24-hour and 12-hour tokens \u2014 parse() refuses to guess which is authoritative and throws at runtime."});let Ce=c.some(p=>p==="X"||p==="XX"||p==="XXX"||p==="x"||p==="xx"||p==="xxx"),yn=c.some(p=>p==="zzz");return Ce&&yn&&l.push({code:"ZZZ_WITH_OFFSET_TOKEN",message:`Format string has both "zzz" and an offset token \u2014 parse() cross-checks them and throws if the parsed offset disagrees with the zone's actual offset.`}),Ce&&!r.has("year")&&l.push({code:"OFFSET_WITHOUT_FULL_DATE",message:"Offset token used without a full date \u2014 parse() needs a complete date and time to build a ZonedDateTime and throws at runtime otherwise."}),{tokens:t,requiredFields:[...r].sort(),compatibleTypes:[...a].sort(),parseable:o,localeSensitive:s,calendarSensitive:d,timezoneSensitive:i,ambiguous:l.some(p=>p.code==="AMBIGUOUS_NUMERIC_RUN"),roundTripSafe:m&&o,warnings:l}}function yo(e){let n=W(e),t=[];t.push(`Format string: "${e}"`),t.push(`Tokens (${n.tokens.length}):`);for(let r of n.tokens)t.push(` ${r.name} @${r.position} \u2014 ${r.metadata.meaning}`);if(n.requiredFields.length>0&&t.push(`Required fields: ${n.requiredFields.join(", ")}`),n.compatibleTypes.length>0&&t.push(`Compatible Temporal types: ${n.compatibleTypes.join(", ")}`),t.push(`Parseable: ${n.parseable?"yes":"no"}`),t.push(`Locale-sensitive: ${n.localeSensitive?"yes":"no"}`),t.push(`Calendar-sensitive: ${n.calendarSensitive?"yes":"no"}`),t.push(`Timezone-sensitive: ${n.timezoneSensitive?"yes":"no"}`),t.push(`Ambiguous: ${n.ambiguous?"yes":"no"}`),t.push(`Round-trip safe: ${n.roundTripSafe?"yes":"no"}`),n.warnings.length>0){t.push("Warnings:");for(let r of n.warnings)t.push(` [${r.code}] ${r.message}`)}return t.join(`
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
`)}}return e}function qo(e){let n=W(e),t=[];for(let r of n.warnings){let a=r.message,o;r.code==="TWELVE_HOUR_WITHOUT_A"?o='Add an "a" token (e.g. "h:mm a") or use "H:mm" for 24-hour.':r.code==="MIXED_12_AND_24_HOUR"?o='Pick one form: "HH:mm" for 24-hour or "h:mm a" for 12-hour.':r.code==="AMBIGUOUS_NUMERIC_RUN"?o='Add a separator or use padded forms (e.g. "MM" instead of "M").':r.code==="FORMAT_ONLY_TOKEN"&&(o='Use a parse-capable variant (e.g. "d" instead of "do").'),t.push({startColumn:0,endColumn:e.length,severity:"warning",message:a,code:r.code,suggestion:o})}return t}var Ee=[{from:"YYYY",to:"yyyy"},{from:"YY",to:"yy"},{from:"MMMM",to:"MMMM"},{from:"MMM",to:"MMM"},{from:"MM",to:"MM"},{from:"M",to:"M"},{from:"DD",to:"dd"},{from:"D",to:"d"},{from:"Do",to:null,notes:`Ordinal day (AdvancedFormat) \u2014 use temporal-fmt's own "do" token instead.`},{from:"dddd",to:"EEEE"},{from:"ddd",to:"EEE"},{from:"dd",to:null,notes:'Min-name weekday (e.g. "Tu") \u2014 temporal-fmt has no equivalent width.'},{from:"d",to:null,notes:'Numeric weekday (0-6) \u2014 no temporal-fmt equivalent; not the same as "d" here, which is day-of-month.'},{from:"HH",to:"HH"},{from:"H",to:"H"},{from:"hh",to:"hh"},{from:"h",to:"h"},{from:"kk",to:null,notes:"Hour 1-24 (AdvancedFormat) \u2014 no temporal-fmt equivalent."},{from:"k",to:null,notes:"Hour 1-24 (AdvancedFormat) \u2014 no temporal-fmt equivalent."},{from:"mm",to:"mm"},{from:"m",to:"m"},{from:"ss",to:"ss"},{from:"s",to:"s"},{from:"SSS",to:"SSS"},{from:"A",to:"a",notes:"Uppercase AM/PM in Day.js \u2014 temporal-fmt is always lowercase."},{from:"a",to:"a"},{from:"ZZ",to:"XX",notes:"Numeric UTC offset, no colon."},{from:"Z",to:"XXX",notes:"Numeric UTC offset with colon."},{from:"X",to:null,notes:"Unix timestamp (seconds) \u2014 use fromUnixSeconds() instead."},{from:"x",to:null,notes:"Unix timestamp (ms) \u2014 use fromUnixMilliseconds() instead."},{from:"Qo",to:null,notes:"Ordinal quarter (AdvancedFormat) \u2014 no temporal-fmt equivalent."},{from:"Q",to:"Q"},{from:"Mo",to:null,notes:"Ordinal month (AdvancedFormat) \u2014 no temporal-fmt equivalent."},{from:"ww",to:"ww"},{from:"wo",to:null,notes:"Ordinal ISO week (AdvancedFormat) \u2014 no temporal-fmt equivalent."},{from:"w",to:null,notes:`Unpadded ISO week \u2014 temporal-fmt's "ww" is always 2-digit.`},{from:"gggg",to:"RRRR",notes:"Week-numbering year, not the calendar year \u2014 same caveat as temporal-fmt's RRRR."},{from:"L",to:null,notes:"Localized date format (AdvancedFormat) \u2014 write the format string out explicitly."},{from:"LL",to:null,notes:"Localized date format (AdvancedFormat) \u2014 write the format string out explicitly."},{from:"LLL",to:null,notes:"Localized date format (AdvancedFormat) \u2014 write the format string out explicitly."},{from:"LLLL",to:null,notes:"Localized date format (AdvancedFormat) \u2014 write the format string out explicitly."},{from:"LT",to:null,notes:"Localized time format (AdvancedFormat) \u2014 write the format string out explicitly."},{from:"LTS",to:null,notes:"Localized time format (AdvancedFormat) \u2014 write the format string out explicitly."}],xe=[{from:"yyyy",to:"yyyy"},{from:"yy",to:"yy"},{from:"y",to:null,notes:'Unpadded calendar year, opt-in via useAdditionalWeekYearTokens \u2014 temporal-fmt has no unpadded-year token; use "yyyy".'},{from:"MMMM",to:"MMMM"},{from:"MMM",to:"MMM"},{from:"MM",to:"MM"},{from:"M",to:"M"},{from:"LLLL",to:"LLLL"},{from:"LLL",to:"LLL"},{from:"dd",to:"dd"},{from:"d",to:"d"},{from:"do",to:"do"},{from:"DDD",to:"DDD"},{from:"DD",to:"DD"},{from:"D",to:"D",notes:`Day-of-year, opt-in via useAdditionalDayOfYearTokens \u2014 matches temporal-fmt's own "D" already.`},{from:"EEEE",to:"EEEE"},{from:"EEE",to:"EEE"},{from:"eeee",to:null,notes:"Locale-aware numeric weekday \u2014 no temporal-fmt equivalent."},{from:"cccc",to:"cccc"},{from:"ccc",to:"ccc"},{from:"HH",to:"HH"},{from:"H",to:"H"},{from:"hh",to:"hh"},{from:"h",to:"h"},{from:"mm",to:"mm"},{from:"m",to:"m"},{from:"ss",to:"ss"},{from:"s",to:"s"},{from:"SSS",to:"SSS"},{from:"a",to:"a"},{from:"aaa",to:"a"},{from:"XXX",to:"XXX"},{from:"XX",to:"XX"},{from:"X",to:"X",notes:`Opt-in via useAdditionalDayOfYearTokens-adjacent rules in date-fns v3+; matches temporal-fmt's own "X" already.`},{from:"xxx",to:"xxx"},{from:"xx",to:"xx"},{from:"x",to:"x"},{from:"zzzz",to:"zzzz"},{from:"zzz",to:"zzz"},{from:"z",to:"z"},{from:"QQQ",to:"QQQ"},{from:"Q",to:"Q"},{from:"GGGG",to:"GGGG"},{from:"GGG",to:null,notes:'Abbreviated era \u2014 temporal-fmt only has "G" (short) and "GGGG" (long).'},{from:"GG",to:null,notes:'Abbreviated era \u2014 temporal-fmt only has "G" (short) and "GGGG" (long).'},{from:"G",to:"G"},{from:"ww",to:"ww"},{from:"w",to:null,notes:`Unpadded local week number \u2014 temporal-fmt's "ww" is ISO-week and always 2-digit.`},{from:"RRRR",to:"RRRR"},{from:"R",to:null,notes:`Unpadded ISO week-numbering year \u2014 temporal-fmt's "RRRR" is always 4-digit.`},{from:"Y",to:null,notes:'Week-numbering year (locale week rules), opt-in \u2014 no temporal-fmt equivalent; "RRRR" is ISO week-numbering, a different rule set.'},{from:"PPPP",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"PPP",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"PP",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"P",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"pppp",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"ppp",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"pp",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"p",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."}];function Ko(e,n){return L(n??{year:2026,month:8,day:4,hour:15,minute:45,second:30,millisecond:123,dayOfWeek:2,timeZoneId:"UTC",offset:"+00:00",calendarId:"iso8601"},e,{locale:"en-US"})}function Jo(e){return"README.md#token-reference"}function Qo(e){let n=[],t=0;for(;t<e.length;)if(e[t]==="["){let r=e.indexOf("]",t+1);if(r===-1){n.push({kind:"token",value:e.slice(t)});break}n.push({kind:"literal",value:e.slice(t+1,r)}),t=r+1}else{let r=t;for(;r<e.length&&e[r]!=="[";)r+=1;n.push({kind:"token",value:e.slice(t,r)}),t=r}return n}function Vo(e,n){let t=[],r=0;for(;r<e.length;){let a=n.find(s=>e.startsWith(s,r));if(a){t.push({kind:"token",value:a}),r+=a.length;continue}let o=t[t.length-1];o&&o.kind==="literal"?o.value+=e[r]:t.push({kind:"literal",value:e[r]}),r+=1}return t}function fn(e,n,t){let r=new Map(n.map(d=>[d.from,d.to])),a=[...r.keys()].sort((d,i)=>i.length-d.length),o=Qo(e),s="";for(let d of o){if(d.kind==="literal"){s+=`'${d.value.replace(/'/g,"''")}'`;continue}for(let i of Vo(d.value,a))if(i.kind==="token"){let m=r.get(i.value);if(m==null)throw new Error(`temporal-fmt: "${i.value}" has no ${t} -> temporal-fmt mapping (in format string "${e}"). Write the equivalent temporal-fmt token in by hand, or wrap it in brackets if it was meant as literal text.`);s+=m}else/[a-zA-Z]/.test(i.value)?s+=`'${i.value.replace(/'/g,"''")}'`:s+=i.value}return s}function ea(e){return fn(e,Ee,"Day.js")}function na(e){return fn(e,xe,"date-fns")}export{me as ALL_TOKEN_NAMES,zn as AmbiguousInputError,xe as DATE_FNS_TO_TEMPORAL_FMT,Ee as DAYJS_TO_TEMPORAL_FMT,an as DEFAULT_CONFIG,st as FORMAT_ONLY_TOKENS,w as FormatSyntaxError,Pn as InvalidCalendarError,ye as InvalidDateError,Nn as InvalidDurationError,ge as InvalidLocaleError,An as InvalidOffsetError,In as InvalidTimeError,On as InvalidTimeZoneError,$n as ParseMismatchError,et as SUPPORTED_NUMBERING_SYSTEMS,R as TOKEN_METADATA,Fn as TemporalFmtError,pe as UnknownTokenError,v as add,dn as addBusinessDays,gt as addDays,Jn as addDuration,ht as addHours,vt as addMilliseconds,Tt as addMinutes,pt as addMonths,wt as addSeconds,yt as addWeeks,ft as addYears,W as analyzeFormat,rt as applyNumbering,ot as applyParseNumbering,Rn as asDateFieldView,co as assertDuration,oo as assertInstant,ao as assertPlainDate,so as assertPlainDateTime,uo as assertPlainMonthDay,io as assertPlainTime,mo as assertPlainYearMonth,ro as assertTemporal,lo as assertZonedDateTime,Xn as balanceDuration,kr as between,Hn as ceil,Gt as clamp,J as compare,Kn as compareDuration,it as compileFormat,dt as compileParser,nt as convertDigits,tt as convertDigitsToAscii,_o as createBusinessCalendar,zo as createConfig,Wo as createFormatter,Uo as createHolidayCalendar,bn as dayOfYear,gn as daysInMonth,hn as daysInYear,Rt as difference,Ho as differenceInBusinessDays,At as differenceInDays,Ot as differenceInHours,Nt as differenceInMilliseconds,Pt as differenceInMinutes,$t as differenceInMonths,zt as differenceInSeconds,It as differenceInWeeks,Ft as differenceInYears,Cn as endOf,yo as explainFormat,To as fieldForToken,Ln as floor,L as format,ze as formatDistance,Ur as formatDistanceToNow,Gn as formatDuration,Zn as formatDurationToParts,Do as formatHTTPDate,on as formatISO,Yn as formatISODuration,So as formatRFC2822,vo as formatRFC3339,Dr as formatRRule,Tr as formatRange,wr as formatRangeToParts,nr as formatRelative,tr as formatRelativeToNow,Po as formatSQL,at as formatToParts,Ro as fromUnixMicroseconds,Co as fromUnixMilliseconds,Fo as fromUnixNanoseconds,xo as fromUnixSeconds,Bo as getAutocompleteData,Jo as getDocUrl,Xo as getHoverDocs,qo as getInlineDiagnostics,or as getLocale,Dn as getMonth,$r as getNextTransition,Cr as getOffset,Rr as getOffsetNanoseconds,Ir as getPreviousTransition,Mn as getQuarter,xr as getTimeZone,Ar as getTransitions,En as getWeekday,ar as hasLocale,Zo as holidaysBetween,cr as intersection,mr as intersects,ir as interval,sr as intervalContains,pr as intervalDifference,dr as intervalIsAfter,ur as intervalIsBefore,yr as intervalSubtract,Ht as isAfter,Lt as isBefore,Zt as isBetween,ce as isBusinessDay,Fr as isDST,nn as isDuration,_t as isEqual,Qe as isInstant,vn as isLeapMonth,wn as isLeapYear,Xe as isPlainDate,Ke as isPlainDateTime,en as isPlainMonthDay,qe as isPlainTime,Ve as isPlainYearMonth,Wt as isSameDay,Kt as isSameMonth,Jt as isSameQuarter,qt as isSameWeek,Qt as isSameYear,tn as isTemporal,Yt as isToday,Bt as isTomorrow,go as isValidFormat,er as isWeekday,Vt as isWeekend,Xt as isYesterday,Je as isZonedDateTime,Zr as listRegisteredGrammars,rn as listTokens,jt as max,gr as mergeIntervals,No as mergeWithConfig,Ut as min,Tn as monthsInYear,ln as nextBusinessDay,jo as nextHoliday,lr as overlaps,K as parse,Bn as parseDuration,Mo as parseHTTPDate,De as parseISO,Wn as parseISODuration,bo as parseRFC2822,wo as parseRFC3339,Mr as parseRRule,no as parseRelative,Oo as parseSQL,ut as parseToParts,Or as possibleInstantsFor,Ko as previewFormat,mn as previousBusinessDay,Go as previousHoliday,vr as recurrence,rr as registerLocale,jn as registerLocaleVocab,Gr as registerRelativeGrammar,Er as resolveZoned,_n as round,$e as roundDuration,$e as roundDurationAlias,lt as safeParse,Vn as setTemporal,Sr as skip,hr as splitInterval,xn as startOf,ct as subtract,Lo as subtractBusinessDays,Mt as subtractDays,Qn as subtractDuration,Dt as subtractHours,Ct as subtractMilliseconds,Et as subtractMinutes,St as subtractMonths,xt as subtractSeconds,kt as subtractWeeks,bt as subtractYears,br as take,Io as toUnixMicroseconds,$o as toUnixMilliseconds,Ao as toUnixNanoseconds,Eo as toUnixSeconds,po as tokenInfo,fo as tokenizeFormat,qn as totalDuration,na as translateDateFnsFormatString,ea as translateDayjsFormatString,Un as truncate,mt as tryParse,fr as union,ho as validateFormat,Sn as weekOfYear,kn as weekYear};
|
|
1
|
+
import {
|
|
2
|
+
formatRelative,
|
|
3
|
+
formatRelativeToNow
|
|
4
|
+
} from "./chunk-GPB4JHGI.js";
|
|
5
|
+
import {
|
|
6
|
+
ALL_TOKEN_NAMES,
|
|
7
|
+
DATE_FNS_TO_TEMPORAL_FMT,
|
|
8
|
+
DAYJS_TO_TEMPORAL_FMT,
|
|
9
|
+
DEFAULT_CONFIG,
|
|
10
|
+
OverrideConflictError,
|
|
11
|
+
TOKEN_METADATA,
|
|
12
|
+
addBusinessDays,
|
|
13
|
+
analyzeFormat,
|
|
14
|
+
contains,
|
|
15
|
+
createHolidayCalendar,
|
|
16
|
+
difference,
|
|
17
|
+
differenceInBusinessDays,
|
|
18
|
+
formatHTTPDate,
|
|
19
|
+
formatISO,
|
|
20
|
+
formatRFC2822,
|
|
21
|
+
formatRange,
|
|
22
|
+
fromUnixMilliseconds,
|
|
23
|
+
fromUnixSeconds,
|
|
24
|
+
getBalanceDurationImpl,
|
|
25
|
+
getBetweenImpl,
|
|
26
|
+
getCeilImpl,
|
|
27
|
+
getClampImpl,
|
|
28
|
+
getCompareDurationImpl,
|
|
29
|
+
getCompileFormatImpl,
|
|
30
|
+
getCompileParserImpl,
|
|
31
|
+
getCreateBusinessCalendarImpl,
|
|
32
|
+
getCreateConfigImpl,
|
|
33
|
+
getExplainFormatImpl,
|
|
34
|
+
getFieldForTokenImpl,
|
|
35
|
+
getFloorImpl,
|
|
36
|
+
getFormatDurationToPartsImpl,
|
|
37
|
+
getFormatISODurationImpl,
|
|
38
|
+
getFormatImpl,
|
|
39
|
+
getFormatRFC3339Impl,
|
|
40
|
+
getFormatRRuleImpl,
|
|
41
|
+
getFormatRangeToPartsImpl,
|
|
42
|
+
getFormatSQLImpl,
|
|
43
|
+
getFromUnixMicrosecondsImpl,
|
|
44
|
+
getFromUnixNanosecondsImpl,
|
|
45
|
+
getGetAutocompleteDataImpl,
|
|
46
|
+
getGetDocUrlImpl,
|
|
47
|
+
getGetHoverDocsImpl,
|
|
48
|
+
getGetInlineDiagnosticsImpl,
|
|
49
|
+
getGetLocaleImpl,
|
|
50
|
+
getGetMonthImpl,
|
|
51
|
+
getGetNextTransitionImpl,
|
|
52
|
+
getGetPreviousTransitionImpl,
|
|
53
|
+
getGetWeekdayImpl,
|
|
54
|
+
getHasLocaleImpl,
|
|
55
|
+
getIntersectionImpl,
|
|
56
|
+
getIntervalImpl,
|
|
57
|
+
getIsAfterImpl,
|
|
58
|
+
getIsBeforeImpl,
|
|
59
|
+
getIsBetweenImpl,
|
|
60
|
+
getIsEqualImpl,
|
|
61
|
+
getIsLeapMonthImpl,
|
|
62
|
+
getIsLeapYearImpl,
|
|
63
|
+
getIsSameDayImpl,
|
|
64
|
+
getIsSameMonthImpl,
|
|
65
|
+
getIsSameQuarterImpl,
|
|
66
|
+
getIsSameWeekImpl,
|
|
67
|
+
getIsSameYearImpl,
|
|
68
|
+
getIsTodayImpl,
|
|
69
|
+
getIsTomorrowImpl,
|
|
70
|
+
getIsValidFormatImpl,
|
|
71
|
+
getIsWeekdayImpl,
|
|
72
|
+
getIsYesterdayImpl,
|
|
73
|
+
getListRegisteredGrammarsImpl,
|
|
74
|
+
getListTokensImpl,
|
|
75
|
+
getMergeIntervalsImpl,
|
|
76
|
+
getMergeWithConfigImpl,
|
|
77
|
+
getMonthsInYearImpl,
|
|
78
|
+
getNextHolidayImpl,
|
|
79
|
+
getOverlapsImpl,
|
|
80
|
+
getParseDurationImpl,
|
|
81
|
+
getParseHTTPDateImpl,
|
|
82
|
+
getParseISODurationImpl,
|
|
83
|
+
getParseImpl,
|
|
84
|
+
getParseRFC2822Impl,
|
|
85
|
+
getParseRFC3339Impl,
|
|
86
|
+
getParseRRuleImpl,
|
|
87
|
+
getParseRelativeImpl,
|
|
88
|
+
getParseSQLImpl,
|
|
89
|
+
getPossibleInstantsForImpl,
|
|
90
|
+
getPreviewFormatImpl,
|
|
91
|
+
getPreviousHolidayImpl,
|
|
92
|
+
getResolveZonedImpl,
|
|
93
|
+
getSubtractBusinessDaysImpl,
|
|
94
|
+
getSubtractDurationImpl,
|
|
95
|
+
getToUnixMicrosecondsImpl,
|
|
96
|
+
getToUnixMillisecondsImpl,
|
|
97
|
+
getToUnixNanosecondsImpl,
|
|
98
|
+
getToUnixSecondsImpl,
|
|
99
|
+
getTokenInfoImpl,
|
|
100
|
+
getTokenizeFormatImpl,
|
|
101
|
+
getTranslateDateFnsFormatStringImpl,
|
|
102
|
+
getTruncateImpl,
|
|
103
|
+
getUnionImpl,
|
|
104
|
+
getValidateFormatImpl,
|
|
105
|
+
getWeekOfYearImpl,
|
|
106
|
+
getWeekYearImpl,
|
|
107
|
+
holidaysBetween,
|
|
108
|
+
intersects,
|
|
109
|
+
isAfter,
|
|
110
|
+
isBefore,
|
|
111
|
+
isBusinessDay,
|
|
112
|
+
nextBusinessDay,
|
|
113
|
+
parseISO,
|
|
114
|
+
previousBusinessDay,
|
|
115
|
+
registerRelativeGrammar,
|
|
116
|
+
setBalanceDurationOverride,
|
|
117
|
+
setBetweenOverride,
|
|
118
|
+
setCeilOverride,
|
|
119
|
+
setClampOverride,
|
|
120
|
+
setCompareDurationOverride,
|
|
121
|
+
setCompileFormatOverride,
|
|
122
|
+
setCompileParserOverride,
|
|
123
|
+
setCreateBusinessCalendarOverride,
|
|
124
|
+
setCreateConfigOverride,
|
|
125
|
+
setExplainFormatOverride,
|
|
126
|
+
setFieldForTokenOverride,
|
|
127
|
+
setFloorOverride,
|
|
128
|
+
setFormatDurationToPartsOverride,
|
|
129
|
+
setFormatISODurationOverride,
|
|
130
|
+
setFormatOverride,
|
|
131
|
+
setFormatRFC3339Override,
|
|
132
|
+
setFormatRRuleOverride,
|
|
133
|
+
setFormatRangeToPartsOverride,
|
|
134
|
+
setFormatSQLOverride,
|
|
135
|
+
setFromUnixMicrosecondsOverride,
|
|
136
|
+
setFromUnixNanosecondsOverride,
|
|
137
|
+
setGetAutocompleteDataOverride,
|
|
138
|
+
setGetDocUrlOverride,
|
|
139
|
+
setGetHoverDocsOverride,
|
|
140
|
+
setGetInlineDiagnosticsOverride,
|
|
141
|
+
setGetLocaleOverride,
|
|
142
|
+
setGetMonthOverride,
|
|
143
|
+
setGetNextTransitionOverride,
|
|
144
|
+
setGetPreviousTransitionOverride,
|
|
145
|
+
setGetWeekdayOverride,
|
|
146
|
+
setHasLocaleOverride,
|
|
147
|
+
setIntersectionOverride,
|
|
148
|
+
setIntervalOverride,
|
|
149
|
+
setIsAfterOverride,
|
|
150
|
+
setIsBeforeOverride,
|
|
151
|
+
setIsBetweenOverride,
|
|
152
|
+
setIsEqualOverride,
|
|
153
|
+
setIsLeapMonthOverride,
|
|
154
|
+
setIsLeapYearOverride,
|
|
155
|
+
setIsSameDayOverride,
|
|
156
|
+
setIsSameMonthOverride,
|
|
157
|
+
setIsSameQuarterOverride,
|
|
158
|
+
setIsSameWeekOverride,
|
|
159
|
+
setIsSameYearOverride,
|
|
160
|
+
setIsTodayOverride,
|
|
161
|
+
setIsTomorrowOverride,
|
|
162
|
+
setIsValidFormatOverride,
|
|
163
|
+
setIsWeekdayOverride,
|
|
164
|
+
setIsYesterdayOverride,
|
|
165
|
+
setListRegisteredGrammarsOverride,
|
|
166
|
+
setListTokensOverride,
|
|
167
|
+
setMergeIntervalsOverride,
|
|
168
|
+
setMergeWithConfigOverride,
|
|
169
|
+
setMonthsInYearOverride,
|
|
170
|
+
setNextHolidayOverride,
|
|
171
|
+
setOverlapsOverride,
|
|
172
|
+
setParseDurationOverride,
|
|
173
|
+
setParseHTTPDateOverride,
|
|
174
|
+
setParseISODurationOverride,
|
|
175
|
+
setParseOverride,
|
|
176
|
+
setParseRFC2822Override,
|
|
177
|
+
setParseRFC3339Override,
|
|
178
|
+
setParseRRuleOverride,
|
|
179
|
+
setParseRelativeOverride,
|
|
180
|
+
setParseSQLOverride,
|
|
181
|
+
setPossibleInstantsForOverride,
|
|
182
|
+
setPreviewFormatOverride,
|
|
183
|
+
setPreviousHolidayOverride,
|
|
184
|
+
setResolveZonedOverride,
|
|
185
|
+
setSubtractBusinessDaysOverride,
|
|
186
|
+
setSubtractDurationOverride,
|
|
187
|
+
setToUnixMicrosecondsOverride,
|
|
188
|
+
setToUnixMillisecondsOverride,
|
|
189
|
+
setToUnixNanosecondsOverride,
|
|
190
|
+
setToUnixSecondsOverride,
|
|
191
|
+
setTokenInfoOverride,
|
|
192
|
+
setTokenizeFormatOverride,
|
|
193
|
+
setTranslateDateFnsFormatStringOverride,
|
|
194
|
+
setTruncateOverride,
|
|
195
|
+
setUnionOverride,
|
|
196
|
+
setValidateFormatOverride,
|
|
197
|
+
setWeekOfYearOverride,
|
|
198
|
+
setWeekYearOverride,
|
|
199
|
+
splitInterval,
|
|
200
|
+
subtract,
|
|
201
|
+
translateDayjsFormatString
|
|
202
|
+
} from "./chunk-FBPHNRVW.js";
|
|
203
|
+
import {
|
|
204
|
+
getOffset,
|
|
205
|
+
getOffsetNanoseconds,
|
|
206
|
+
getTimeZone,
|
|
207
|
+
getTransitions,
|
|
208
|
+
isDST
|
|
209
|
+
} from "./chunk-H7YQX25T.js";
|
|
210
|
+
import {
|
|
211
|
+
addDuration,
|
|
212
|
+
formatDuration,
|
|
213
|
+
round,
|
|
214
|
+
roundDuration,
|
|
215
|
+
totalDuration
|
|
216
|
+
} from "./chunk-ACKKWH5Z.js";
|
|
217
|
+
import {
|
|
218
|
+
formatToParts
|
|
219
|
+
} from "./chunk-4N3WCGEY.js";
|
|
220
|
+
import {
|
|
221
|
+
registerLocale
|
|
222
|
+
} from "./chunk-UOPAV3WX.js";
|
|
223
|
+
import {
|
|
224
|
+
FORMAT_ONLY_TOKENS,
|
|
225
|
+
parseToParts,
|
|
226
|
+
safeParse,
|
|
227
|
+
tryParse
|
|
228
|
+
} from "./chunk-5UTV5VP6.js";
|
|
229
|
+
import {
|
|
230
|
+
SUPPORTED_NUMBERING_SYSTEMS,
|
|
231
|
+
applyNumbering,
|
|
232
|
+
applyParseNumbering,
|
|
233
|
+
convertDigits,
|
|
234
|
+
convertDigitsToAscii
|
|
235
|
+
} from "./chunk-M3GDTHMT.js";
|
|
236
|
+
import {
|
|
237
|
+
DEFAULT_LOCALE,
|
|
238
|
+
TOKENS
|
|
239
|
+
} from "./chunk-L24NPTAJ.js";
|
|
240
|
+
import {
|
|
241
|
+
setTemporal
|
|
242
|
+
} from "./chunk-ZQZF5EXW.js";
|
|
243
|
+
import {
|
|
244
|
+
MAX_FORMAT_LENGTH
|
|
245
|
+
} from "./chunk-YEUASGDK.js";
|
|
246
|
+
import {
|
|
247
|
+
AmbiguousInputError,
|
|
248
|
+
FormatSyntaxError,
|
|
249
|
+
InvalidCalendarError,
|
|
250
|
+
InvalidDateError,
|
|
251
|
+
InvalidDurationError,
|
|
252
|
+
InvalidLocaleError,
|
|
253
|
+
InvalidOffsetError,
|
|
254
|
+
InvalidTimeError,
|
|
255
|
+
InvalidTimeZoneError,
|
|
256
|
+
ParseMismatchError,
|
|
257
|
+
TemporalFmtError,
|
|
258
|
+
UnknownTokenError,
|
|
259
|
+
normalizeLocaleTag,
|
|
260
|
+
registerLocaleVocab
|
|
261
|
+
} from "./chunk-EGUUO6LE.js";
|
|
262
|
+
import {
|
|
263
|
+
compare,
|
|
264
|
+
isWeekend,
|
|
265
|
+
max,
|
|
266
|
+
min,
|
|
267
|
+
recurrence,
|
|
268
|
+
skip,
|
|
269
|
+
take
|
|
270
|
+
} from "./chunk-VNIUIQA4.js";
|
|
271
|
+
import {
|
|
272
|
+
add,
|
|
273
|
+
addDays,
|
|
274
|
+
addHours,
|
|
275
|
+
addMilliseconds,
|
|
276
|
+
addMinutes,
|
|
277
|
+
addMonths,
|
|
278
|
+
addSeconds,
|
|
279
|
+
addWeeks,
|
|
280
|
+
addYears,
|
|
281
|
+
difference as difference2,
|
|
282
|
+
differenceInDays,
|
|
283
|
+
differenceInHours,
|
|
284
|
+
differenceInMilliseconds,
|
|
285
|
+
differenceInMinutes,
|
|
286
|
+
differenceInMonths,
|
|
287
|
+
differenceInSeconds,
|
|
288
|
+
differenceInWeeks,
|
|
289
|
+
differenceInYears,
|
|
290
|
+
subtract as subtract2,
|
|
291
|
+
subtractDays,
|
|
292
|
+
subtractHours,
|
|
293
|
+
subtractMilliseconds,
|
|
294
|
+
subtractMinutes,
|
|
295
|
+
subtractMonths,
|
|
296
|
+
subtractSeconds,
|
|
297
|
+
subtractWeeks,
|
|
298
|
+
subtractYears
|
|
299
|
+
} from "./chunk-TSLPIURC.js";
|
|
300
|
+
import {
|
|
301
|
+
asDateFieldView,
|
|
302
|
+
dayOfYearHelper,
|
|
303
|
+
daysInMonth,
|
|
304
|
+
daysInYear,
|
|
305
|
+
endOf,
|
|
306
|
+
getQuarter,
|
|
307
|
+
startOf
|
|
308
|
+
} from "./chunk-HXY2GUUM.js";
|
|
309
|
+
import {
|
|
310
|
+
dayOfYear,
|
|
311
|
+
isGregorianLeapYear
|
|
312
|
+
} from "./chunk-MKPDLQKD.js";
|
|
313
|
+
|
|
314
|
+
// src/formatDistance.ts
|
|
315
|
+
function readFields(value, label) {
|
|
316
|
+
if (value === null || typeof value !== "object") {
|
|
317
|
+
throw new Error(
|
|
318
|
+
`temporal-fmt: formatDistance expects Temporal values, got ${label} = ${String(value)}.`
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
const obj = value;
|
|
322
|
+
const hasYear = typeof obj.year === "number";
|
|
323
|
+
const hasMonth = typeof obj.month === "number";
|
|
324
|
+
const hasDay = typeof obj.day === "number";
|
|
325
|
+
if (hasYear !== hasMonth || hasMonth !== hasDay) {
|
|
326
|
+
throw new Error(
|
|
327
|
+
`temporal-fmt: formatDistance got a ${label} with a partial date (some of year/month/day missing). Pass a full Temporal.PlainDate / PlainDateTime / ZonedDateTime.`
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
year: hasYear ? obj.year : void 0,
|
|
332
|
+
month: hasMonth ? obj.month : void 0,
|
|
333
|
+
day: hasDay ? obj.day : void 0,
|
|
334
|
+
hour: typeof obj.hour === "number" ? obj.hour : void 0,
|
|
335
|
+
minute: typeof obj.minute === "number" ? obj.minute : void 0,
|
|
336
|
+
second: typeof obj.second === "number" ? obj.second : void 0,
|
|
337
|
+
millisecond: typeof obj.millisecond === "number" ? obj.millisecond : void 0
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
var REFERENCE_YEAR = 2e3;
|
|
341
|
+
var MS_PER_SECOND = 1e3;
|
|
342
|
+
var MS_PER_MINUTE = 60 * MS_PER_SECOND;
|
|
343
|
+
var MS_PER_HOUR = 60 * MS_PER_MINUTE;
|
|
344
|
+
var MS_PER_DAY = 24 * MS_PER_HOUR;
|
|
345
|
+
function daysSinceReference(year, month, day) {
|
|
346
|
+
let days = 0;
|
|
347
|
+
if (year >= REFERENCE_YEAR) {
|
|
348
|
+
for (let y = REFERENCE_YEAR; y < year; y++) {
|
|
349
|
+
days += isGregorianLeapYear(y) ? 366 : 365;
|
|
350
|
+
}
|
|
351
|
+
} else {
|
|
352
|
+
for (let y = year; y < REFERENCE_YEAR; y++) {
|
|
353
|
+
days -= isGregorianLeapYear(y) ? 366 : 365;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
days += dayOfYear(year, month, day) - 1;
|
|
357
|
+
return days;
|
|
358
|
+
}
|
|
359
|
+
function toEpochMs(fields) {
|
|
360
|
+
if (fields.year === void 0 || fields.month === void 0 || fields.day === void 0) {
|
|
361
|
+
throw new Error(
|
|
362
|
+
`temporal-fmt: formatDistance needs a Temporal value with year/month/day fields (PlainDate, PlainDateTime, or ZonedDateTime). A PlainTime or other shape has no anchor date to diff against.`
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
const days = daysSinceReference(fields.year, fields.month, fields.day);
|
|
366
|
+
const hour = fields.hour ?? 0;
|
|
367
|
+
const minute = fields.minute ?? 0;
|
|
368
|
+
const second = fields.second ?? 0;
|
|
369
|
+
const millisecond = fields.millisecond ?? 0;
|
|
370
|
+
return days * MS_PER_DAY + hour * MS_PER_HOUR + minute * MS_PER_MINUTE + second * MS_PER_SECOND + millisecond;
|
|
371
|
+
}
|
|
372
|
+
var DEFAULT_CUTOFFS = {
|
|
373
|
+
seconds: 60,
|
|
374
|
+
// 60 s
|
|
375
|
+
minutes: 60,
|
|
376
|
+
// 60 min
|
|
377
|
+
hours: 24,
|
|
378
|
+
// 24 h
|
|
379
|
+
days: 30,
|
|
380
|
+
// 30 d
|
|
381
|
+
months: 365
|
|
382
|
+
// 365 d (in days, since the months→years boundary is day-resolution)
|
|
383
|
+
};
|
|
384
|
+
function resolveCutoffs(user) {
|
|
385
|
+
const merged = { ...DEFAULT_CUTOFFS, ...user };
|
|
386
|
+
for (const key of Object.keys(merged)) {
|
|
387
|
+
const value = merged[key];
|
|
388
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
389
|
+
throw new Error(
|
|
390
|
+
`temporal-fmt: formatDistance cutoff "${key}" must be a positive finite number (got ${String(value)}).`
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
const secondsMs = merged.seconds * MS_PER_SECOND;
|
|
395
|
+
const minutesMs = merged.minutes * MS_PER_MINUTE;
|
|
396
|
+
const hoursMs = merged.hours * MS_PER_HOUR;
|
|
397
|
+
const daysMs = merged.days * MS_PER_DAY;
|
|
398
|
+
const monthsMs = merged.months * MS_PER_DAY;
|
|
399
|
+
if (!(secondsMs <= minutesMs && minutesMs <= hoursMs && hoursMs <= daysMs && daysMs <= monthsMs)) {
|
|
400
|
+
throw new Error(
|
|
401
|
+
`temporal-fmt: formatDistance cutoffs must be monotonically non-decreasing in equivalent ms (seconds \u2264 minutes \u2264 hours \u2264 days \u2264 months). Got: seconds=${merged.seconds}s, minutes=${merged.minutes}min, hours=${merged.hours}h, days=${merged.days}d, months=${merged.months}d \u2014 pick a sequence where each boundary is at least as large as the one before it.`
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
return [
|
|
405
|
+
{ maxMs: secondsMs, unit: "second" },
|
|
406
|
+
{ maxMs: minutesMs, unit: "minute" },
|
|
407
|
+
{ maxMs: hoursMs, unit: "hour" },
|
|
408
|
+
{ maxMs: daysMs, unit: "day" },
|
|
409
|
+
{ maxMs: monthsMs, unit: "month" }
|
|
410
|
+
];
|
|
411
|
+
}
|
|
412
|
+
var rtfCache = /* @__PURE__ */ new Map();
|
|
413
|
+
var MAX_RTF_CACHE_SIZE = 100;
|
|
414
|
+
function getRtf(locale, numeric) {
|
|
415
|
+
const key = `${canonicalLocaleKey(locale)}|${numeric}`;
|
|
416
|
+
let rtf = rtfCache.get(key);
|
|
417
|
+
if (rtf) return rtf;
|
|
418
|
+
if (rtfCache.size >= MAX_RTF_CACHE_SIZE) {
|
|
419
|
+
const oldestKey = rtfCache.keys().next().value;
|
|
420
|
+
if (oldestKey !== void 0) rtfCache.delete(oldestKey);
|
|
421
|
+
}
|
|
422
|
+
try {
|
|
423
|
+
rtf = new Intl.RelativeTimeFormat(normalizeLocaleTag(locale), { numeric });
|
|
424
|
+
} catch (err) {
|
|
425
|
+
throw new InvalidLocaleError({ actual: locale, reason: err.message });
|
|
426
|
+
}
|
|
427
|
+
rtfCache.set(key, rtf);
|
|
428
|
+
return rtf;
|
|
429
|
+
}
|
|
430
|
+
function canonicalLocaleKey(locale) {
|
|
431
|
+
try {
|
|
432
|
+
return new Intl.Locale(locale.replace(/_/g, "-")).toString().toLowerCase();
|
|
433
|
+
} catch {
|
|
434
|
+
return locale;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
function formatDistance(date1, date2, options = {}) {
|
|
438
|
+
const fields1 = readFields(date1, "date1");
|
|
439
|
+
const fields2 = readFields(date2, "date2");
|
|
440
|
+
const diffMs = toEpochMs(fields1) - toEpochMs(fields2);
|
|
441
|
+
const absMs = Math.abs(diffMs);
|
|
442
|
+
const unitCutoffs = resolveCutoffs(options.cutoffs);
|
|
443
|
+
let unit = "year";
|
|
444
|
+
for (const { maxMs, unit: candidateUnit } of unitCutoffs) {
|
|
445
|
+
if (absMs < maxMs) {
|
|
446
|
+
unit = candidateUnit;
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const divisor = unitToMs(unit);
|
|
451
|
+
const rounded = Math.round(diffMs / divisor);
|
|
452
|
+
const numeric = options.numeric ?? "auto";
|
|
453
|
+
const locale = options.locale ?? DEFAULT_LOCALE;
|
|
454
|
+
const rtf = getRtf(locale, numeric);
|
|
455
|
+
return rtf.format(rounded, unit);
|
|
456
|
+
}
|
|
457
|
+
function formatDistanceToNow(date, options = {}) {
|
|
458
|
+
const now = /* @__PURE__ */ new Date();
|
|
459
|
+
const nowFields = {
|
|
460
|
+
year: now.getFullYear(),
|
|
461
|
+
month: now.getMonth() + 1,
|
|
462
|
+
day: now.getDate(),
|
|
463
|
+
hour: now.getHours(),
|
|
464
|
+
minute: now.getMinutes(),
|
|
465
|
+
second: now.getSeconds(),
|
|
466
|
+
millisecond: now.getMilliseconds()
|
|
467
|
+
};
|
|
468
|
+
return formatDistance(date, nowFields, options);
|
|
469
|
+
}
|
|
470
|
+
function unitToMs(unit) {
|
|
471
|
+
switch (unit) {
|
|
472
|
+
case "second":
|
|
473
|
+
return MS_PER_SECOND;
|
|
474
|
+
case "minute":
|
|
475
|
+
return MS_PER_MINUTE;
|
|
476
|
+
case "hour":
|
|
477
|
+
return MS_PER_HOUR;
|
|
478
|
+
case "day":
|
|
479
|
+
return MS_PER_DAY;
|
|
480
|
+
/* c8 ignore start @preserve -- unreachable: unitToMs is only called
|
|
481
|
+
with `unit` values produced by formatDistance's cutoff loop above,
|
|
482
|
+
which only ever yields 'second'/'minute'/'hour'/'day'/'month'
|
|
483
|
+
(from resolveCutoffs' fixed array) or 'year' (the loop's fallback
|
|
484
|
+
default). 'week' and 'quarter' were never wired into
|
|
485
|
+
resolveCutoffs — formatDistance intentionally skips week-
|
|
486
|
+
resolution output (see the comment above DEFAULT_CUTOFFS) — so
|
|
487
|
+
neither can reach this switch. */
|
|
488
|
+
case "week":
|
|
489
|
+
return 7 * MS_PER_DAY;
|
|
490
|
+
/* c8 ignore stop @preserve */
|
|
491
|
+
case "month":
|
|
492
|
+
return 30 * MS_PER_DAY;
|
|
493
|
+
/* c8 ignore start @preserve -- unreachable, same reason as 'week'
|
|
494
|
+
above: resolveCutoffs never produces 'quarter'. */
|
|
495
|
+
case "quarter":
|
|
496
|
+
return 91 * MS_PER_DAY;
|
|
497
|
+
/* c8 ignore stop @preserve */
|
|
498
|
+
case "year":
|
|
499
|
+
return 365 * MS_PER_DAY;
|
|
500
|
+
/* c8 ignore start @preserve -- unreachable: every unit
|
|
501
|
+
resolveCutoffs can actually produce ('second' through 'month', or
|
|
502
|
+
'year' as the loop's fallback default) has an explicit case
|
|
503
|
+
above, so this exhaustive-switch default can't fire at runtime.
|
|
504
|
+
It exists so TS accepts the function as total — the compiler
|
|
505
|
+
can't see through the cutoff-array iteration in formatDistance()
|
|
506
|
+
to know the input is already narrowed. */
|
|
507
|
+
default:
|
|
508
|
+
throw new Error(`temporal-fmt: formatDistance hit unhandled unit "${String(unit)}".`);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// src/typeGuards.ts
|
|
513
|
+
function isObject(v) {
|
|
514
|
+
return typeof v === "object" && v !== null;
|
|
515
|
+
}
|
|
516
|
+
function guardOrFalse(impl) {
|
|
517
|
+
return (value) => {
|
|
518
|
+
try {
|
|
519
|
+
return impl(value);
|
|
520
|
+
} catch {
|
|
521
|
+
return false;
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
function hasMethod(v, name) {
|
|
526
|
+
return typeof v[name] === "function";
|
|
527
|
+
}
|
|
528
|
+
function hasTag(value, typeName) {
|
|
529
|
+
if (!isObject(value)) return false;
|
|
530
|
+
const tag = value[Symbol.toStringTag];
|
|
531
|
+
return tag === `Temporal.${typeName}`;
|
|
532
|
+
}
|
|
533
|
+
var isPlainDate = guardOrFalse(function isPlainDateImpl(value) {
|
|
534
|
+
if (hasTag(value, "PlainDate")) return true;
|
|
535
|
+
if (!isObject(value)) return false;
|
|
536
|
+
const v = value;
|
|
537
|
+
return typeof v.year === "number" && typeof v.month === "number" && typeof v.day === "number" && typeof v.hour === "undefined" && hasMethod(v, "toPlainDateTime") && hasMethod(v, "withCalendar");
|
|
538
|
+
});
|
|
539
|
+
var isPlainTime = guardOrFalse(function isPlainTimeImpl(value) {
|
|
540
|
+
if (hasTag(value, "PlainTime")) return true;
|
|
541
|
+
if (!isObject(value)) return false;
|
|
542
|
+
const v = value;
|
|
543
|
+
return typeof v.hour === "number" && typeof v.year === "undefined" && !hasMethod(v, "withCalendar") && !hasMethod(v, "toPlainDate") && !hasMethod(v, "toPlainDateTime");
|
|
544
|
+
});
|
|
545
|
+
var isPlainDateTime = guardOrFalse(function isPlainDateTimeImpl(value) {
|
|
546
|
+
if (hasTag(value, "PlainDateTime")) return true;
|
|
547
|
+
if (!isObject(value)) return false;
|
|
548
|
+
const v = value;
|
|
549
|
+
return typeof v.year === "number" && typeof v.month === "number" && typeof v.day === "number" && typeof v.hour === "number" && hasMethod(v, "withPlainTime") && !hasMethod(v, "toInstant");
|
|
550
|
+
});
|
|
551
|
+
var isZonedDateTime = guardOrFalse(function isZonedDateTimeImpl(value) {
|
|
552
|
+
if (hasTag(value, "ZonedDateTime")) return true;
|
|
553
|
+
if (!isObject(value)) return false;
|
|
554
|
+
const v = value;
|
|
555
|
+
return typeof v.year === "number" && typeof v.month === "number" && typeof v.day === "number" && typeof v.hour === "number" && hasMethod(v, "withTimeZone") && hasMethod(v, "toInstant");
|
|
556
|
+
});
|
|
557
|
+
var isInstant = guardOrFalse(function isInstantImpl(value) {
|
|
558
|
+
if (hasTag(value, "Instant")) return true;
|
|
559
|
+
if (!isObject(value)) return false;
|
|
560
|
+
const v = value;
|
|
561
|
+
return hasMethod(v, "toZonedDateTimeISO") && !hasMethod(v, "toInstant") && typeof v.year === "undefined";
|
|
562
|
+
});
|
|
563
|
+
var isPlainYearMonth = guardOrFalse(function isPlainYearMonthImpl(value) {
|
|
564
|
+
if (hasTag(value, "PlainYearMonth")) return true;
|
|
565
|
+
if (!isObject(value)) return false;
|
|
566
|
+
const v = value;
|
|
567
|
+
return typeof v.year === "number" && typeof v.month === "number" && typeof v.day === "undefined" && hasMethod(v, "toPlainDate");
|
|
568
|
+
});
|
|
569
|
+
var isPlainMonthDay = guardOrFalse(function isPlainMonthDayImpl(value) {
|
|
570
|
+
if (hasTag(value, "PlainMonthDay")) return true;
|
|
571
|
+
if (!isObject(value)) return false;
|
|
572
|
+
const v = value;
|
|
573
|
+
return typeof v.year === "undefined" && typeof v.month === "undefined" && typeof v.day === "number" && typeof v.monthCode === "string" && hasMethod(v, "toPlainDate");
|
|
574
|
+
});
|
|
575
|
+
var isDuration = guardOrFalse(function isDurationImpl(value) {
|
|
576
|
+
if (hasTag(value, "Duration")) return true;
|
|
577
|
+
if (!isObject(value)) return false;
|
|
578
|
+
const v = value;
|
|
579
|
+
return hasMethod(v, "total");
|
|
580
|
+
});
|
|
581
|
+
var isTemporal = guardOrFalse(function isTemporalImpl(value) {
|
|
582
|
+
if (!isObject(value)) return false;
|
|
583
|
+
const tag = value[Symbol.toStringTag];
|
|
584
|
+
if (typeof tag === "string" && tag.startsWith("Temporal.")) return true;
|
|
585
|
+
const v = value;
|
|
586
|
+
return hasMethod(v, "toInstant") || hasMethod(v, "toPlainDate") || hasMethod(v, "toPlainDateTime") || hasMethod(v, "toPlainTime") || hasMethod(v, "toPlainYearMonth") || hasMethod(v, "toPlainMonthDay") || hasMethod(v, "toZonedDateTime") || hasMethod(v, "toZonedDateTimeISO") || hasMethod(v, "withCalendar") || hasMethod(v, "withPlainTime") || hasMethod(v, "withTimeZone") || hasMethod(v, "total");
|
|
587
|
+
});
|
|
588
|
+
function describeValue(value) {
|
|
589
|
+
if (value === null) return "null";
|
|
590
|
+
if (Array.isArray(value)) return "array";
|
|
591
|
+
if (typeof value === "object") {
|
|
592
|
+
const ctor = value.constructor;
|
|
593
|
+
if (ctor && typeof ctor.name === "string" && ctor.name !== "Object") {
|
|
594
|
+
return `instance of ${ctor.name}`;
|
|
595
|
+
}
|
|
596
|
+
return "plain object";
|
|
597
|
+
}
|
|
598
|
+
return typeof value;
|
|
599
|
+
}
|
|
600
|
+
function assertImpl(value, guard, expectedType) {
|
|
601
|
+
if (!guard(value)) {
|
|
602
|
+
throw new Error(
|
|
603
|
+
`temporal-fmt: expected a Temporal.${expectedType}, got ${describeValue(value)}.`
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
function assertTemporal(value) {
|
|
608
|
+
assertImpl(value, isTemporal, "object (Instant, PlainDate, PlainTime, PlainDateTime, ZonedDateTime, Duration, PlainYearMonth, or PlainMonthDay)");
|
|
609
|
+
}
|
|
610
|
+
function assertInstant(value) {
|
|
611
|
+
assertImpl(value, isInstant, "Instant");
|
|
612
|
+
}
|
|
613
|
+
function assertPlainDate(value) {
|
|
614
|
+
assertImpl(value, isPlainDate, "PlainDate");
|
|
615
|
+
}
|
|
616
|
+
function assertPlainTime(value) {
|
|
617
|
+
assertImpl(value, isPlainTime, "PlainTime");
|
|
618
|
+
}
|
|
619
|
+
function assertPlainDateTime(value) {
|
|
620
|
+
assertImpl(value, isPlainDateTime, "PlainDateTime");
|
|
621
|
+
}
|
|
622
|
+
function assertZonedDateTime(value) {
|
|
623
|
+
assertImpl(value, isZonedDateTime, "ZonedDateTime");
|
|
624
|
+
}
|
|
625
|
+
function assertPlainYearMonth(value) {
|
|
626
|
+
assertImpl(value, isPlainYearMonth, "PlainYearMonth");
|
|
627
|
+
}
|
|
628
|
+
function assertPlainMonthDay(value) {
|
|
629
|
+
assertImpl(value, isPlainMonthDay, "PlainMonthDay");
|
|
630
|
+
}
|
|
631
|
+
function assertDuration(value) {
|
|
632
|
+
assertImpl(value, isDuration, "Duration");
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// src/extensibility.ts
|
|
636
|
+
function createFormatter(options = {}) {
|
|
637
|
+
const mergedTokens = [...TOKENS];
|
|
638
|
+
const customTokenNames = /* @__PURE__ */ new Set();
|
|
639
|
+
for (const custom of options.tokens ?? []) {
|
|
640
|
+
customTokenNames.add(custom.name);
|
|
641
|
+
}
|
|
642
|
+
for (const custom of options.tokens ?? []) {
|
|
643
|
+
const existingIdx = mergedTokens.findIndex(([name]) => name === custom.name);
|
|
644
|
+
if (existingIdx >= 0) {
|
|
645
|
+
mergedTokens[existingIdx] = [custom.name, custom.handler, custom.field];
|
|
646
|
+
} else {
|
|
647
|
+
mergedTokens.push([custom.name, custom.handler, custom.field]);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
mergedTokens.sort((a, b) => b[0].length - a[0].length);
|
|
651
|
+
const handlerByToken = new Map(mergedTokens.map(([name, handler, field]) => [name, { handler, field }]));
|
|
652
|
+
const sortedTokenStrings = mergedTokens.map(([name]) => name);
|
|
653
|
+
function customTokenize(formatStr) {
|
|
654
|
+
const pieces = [];
|
|
655
|
+
let i = 0;
|
|
656
|
+
while (i < formatStr.length) {
|
|
657
|
+
const ch = formatStr[i];
|
|
658
|
+
if (ch === "'") {
|
|
659
|
+
if (formatStr[i + 1] === "'") {
|
|
660
|
+
appendLiteral(pieces, "'");
|
|
661
|
+
i += 2;
|
|
662
|
+
continue;
|
|
663
|
+
}
|
|
664
|
+
let j = i + 1;
|
|
665
|
+
let literal = "";
|
|
666
|
+
let closed = false;
|
|
667
|
+
while (j < formatStr.length) {
|
|
668
|
+
if (formatStr[j] === "'") {
|
|
669
|
+
if (formatStr[j + 1] === "'") {
|
|
670
|
+
literal += "'";
|
|
671
|
+
j += 2;
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
closed = true;
|
|
675
|
+
j += 1;
|
|
676
|
+
break;
|
|
677
|
+
}
|
|
678
|
+
literal += formatStr[j];
|
|
679
|
+
j += 1;
|
|
680
|
+
}
|
|
681
|
+
if (!closed) throw new Error(`temporal-fmt: unterminated quote in format string "${formatStr}"`);
|
|
682
|
+
appendLiteral(pieces, literal);
|
|
683
|
+
i = j;
|
|
684
|
+
continue;
|
|
685
|
+
}
|
|
686
|
+
const match = sortedTokenStrings.find((tok) => formatStr.startsWith(tok, i));
|
|
687
|
+
if (match) {
|
|
688
|
+
const runChar = match[match.length - 1];
|
|
689
|
+
if (formatStr[i + match.length] === runChar) {
|
|
690
|
+
let end = i + match.length;
|
|
691
|
+
while (formatStr[end] === runChar) end += 1;
|
|
692
|
+
throw new UnknownTokenError({
|
|
693
|
+
token: formatStr.slice(i, end),
|
|
694
|
+
format: formatStr,
|
|
695
|
+
message: `temporal-fmt: "${formatStr.slice(i, end)}" in format string "${formatStr}" isn't a recognized token \u2014 did you mean "${match}"?`
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
pieces.push({ kind: "token", value: match });
|
|
699
|
+
i += match.length;
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
appendLiteral(pieces, ch);
|
|
703
|
+
i += 1;
|
|
704
|
+
}
|
|
705
|
+
return pieces;
|
|
706
|
+
}
|
|
707
|
+
function appendLiteral(pieces, value) {
|
|
708
|
+
const last = pieces[pieces.length - 1];
|
|
709
|
+
if (last && last.kind === "literal") {
|
|
710
|
+
last.value += value;
|
|
711
|
+
} else {
|
|
712
|
+
pieces.push({ kind: "literal", value });
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
const defaultLocale = options.defaultLocale ?? DEFAULT_LOCALE;
|
|
716
|
+
return {
|
|
717
|
+
format(temporal, formatStr, opts = {}) {
|
|
718
|
+
if (formatStr.length > MAX_FORMAT_LENGTH) {
|
|
719
|
+
throw new Error(`temporal-fmt: format string exceeds maximum length of ${MAX_FORMAT_LENGTH} characters (got ${formatStr.length}).`);
|
|
720
|
+
}
|
|
721
|
+
const locale = opts.locale ?? defaultLocale;
|
|
722
|
+
const pieces = customTokenize(formatStr);
|
|
723
|
+
let result = "";
|
|
724
|
+
for (const piece of pieces) {
|
|
725
|
+
if (piece.kind === "literal") {
|
|
726
|
+
result += piece.value;
|
|
727
|
+
continue;
|
|
728
|
+
}
|
|
729
|
+
const handler = handlerByToken.get(piece.value);
|
|
730
|
+
/* c8 ignore start @preserve -- unreachable: customTokenize only ever produces a
|
|
731
|
+
`kind: 'token'` piece via sortedTokenStrings.find(...), and
|
|
732
|
+
handlerByToken is built from that same mergedTokens array, so
|
|
733
|
+
every token piece is guaranteed a handler entry. Guards against a
|
|
734
|
+
future customTokenize change that decouples the two lookups. */
|
|
735
|
+
if (!handler) throw new Error(`temporal-fmt: unknown token "${piece.value}"`);
|
|
736
|
+
/* c8 ignore stop @preserve */
|
|
737
|
+
if (temporal[handler.field] === void 0) {
|
|
738
|
+
throw new Error(
|
|
739
|
+
`temporal-fmt: token "${piece.value}" requires "${String(handler.field)}", which this Temporal object doesn't have.`
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
result += handler.handler(temporal, locale);
|
|
743
|
+
}
|
|
744
|
+
return result;
|
|
745
|
+
},
|
|
746
|
+
formatToParts(temporal, formatStr, opts = {}) {
|
|
747
|
+
if (formatStr.length > MAX_FORMAT_LENGTH) {
|
|
748
|
+
throw new Error(`temporal-fmt: format string exceeds maximum length of ${MAX_FORMAT_LENGTH} characters (got ${formatStr.length}).`);
|
|
749
|
+
}
|
|
750
|
+
const locale = opts.locale ?? defaultLocale;
|
|
751
|
+
const pieces = customTokenize(formatStr);
|
|
752
|
+
const out = [];
|
|
753
|
+
for (const piece of pieces) {
|
|
754
|
+
if (piece.kind === "literal") {
|
|
755
|
+
const last = out[out.length - 1];
|
|
756
|
+
/* c8 ignore start @preserve -- unreachable: customTokenize's own
|
|
757
|
+
appendLiteral() already merges adjacent literal chars/quoted
|
|
758
|
+
spans into a single piece before this loop ever sees them, so
|
|
759
|
+
two literal pieces are never adjacent here. Kept as a guard
|
|
760
|
+
against a future customTokenize change that stops merging. */
|
|
761
|
+
if (last && last.type === "literal") last.value += piece.value;
|
|
762
|
+
else out.push({ type: "literal", value: piece.value });
|
|
763
|
+
continue;
|
|
764
|
+
}
|
|
765
|
+
const handler = handlerByToken.get(piece.value);
|
|
766
|
+
/* c8 ignore start @preserve -- unreachable: customTokenize only emits
|
|
767
|
+
kind:'token' pieces found in sortedTokenStrings, the same array
|
|
768
|
+
handlerByToken is built from, so every token piece is guaranteed
|
|
769
|
+
a handler entry. Guards against future decoupling of the two. */
|
|
770
|
+
if (!handler) throw new Error(`temporal-fmt: unknown token "${piece.value}"`);
|
|
771
|
+
/* c8 ignore stop @preserve */
|
|
772
|
+
if (temporal[handler.field] === void 0) {
|
|
773
|
+
throw new Error(`temporal-fmt: token "${piece.value}" requires "${String(handler.field)}".`);
|
|
774
|
+
}
|
|
775
|
+
out.push({ type: "token", value: handler.handler(temporal, locale), token: piece.value });
|
|
776
|
+
}
|
|
777
|
+
return out;
|
|
778
|
+
},
|
|
779
|
+
compileFormat(formatStr) {
|
|
780
|
+
if (formatStr.length > MAX_FORMAT_LENGTH) {
|
|
781
|
+
throw new Error(`temporal-fmt: format string exceeds maximum length of ${MAX_FORMAT_LENGTH} characters (got ${formatStr.length}).`);
|
|
782
|
+
}
|
|
783
|
+
const pieces = customTokenize(formatStr);
|
|
784
|
+
return {
|
|
785
|
+
formatStr,
|
|
786
|
+
pieces: pieces.map((p) => p),
|
|
787
|
+
format(temporal, opts = {}) {
|
|
788
|
+
const locale = opts.locale ?? defaultLocale;
|
|
789
|
+
let result = "";
|
|
790
|
+
for (const piece of pieces) {
|
|
791
|
+
if (piece.kind === "literal") {
|
|
792
|
+
result += piece.value;
|
|
793
|
+
continue;
|
|
794
|
+
}
|
|
795
|
+
const handler = handlerByToken.get(piece.value);
|
|
796
|
+
/* c8 ignore start @preserve -- unreachable, see the same guard's comment
|
|
797
|
+
above in the un-compiled format(). */
|
|
798
|
+
if (!handler) throw new Error(`temporal-fmt: unknown token "${piece.value}"`);
|
|
799
|
+
/* c8 ignore stop @preserve */
|
|
800
|
+
if (temporal[handler.field] === void 0) {
|
|
801
|
+
throw new Error(`temporal-fmt: token "${piece.value}" requires "${String(handler.field)}".`);
|
|
802
|
+
}
|
|
803
|
+
result += handler.handler(temporal, locale);
|
|
804
|
+
}
|
|
805
|
+
return result;
|
|
806
|
+
},
|
|
807
|
+
formatToParts(temporal, opts = {}) {
|
|
808
|
+
const locale = opts.locale ?? defaultLocale;
|
|
809
|
+
const out = [];
|
|
810
|
+
for (const piece of pieces) {
|
|
811
|
+
if (piece.kind === "literal") {
|
|
812
|
+
const last = out[out.length - 1];
|
|
813
|
+
/* c8 ignore start @preserve -- unreachable, see the same guard's
|
|
814
|
+
comment above in the un-compiled formatToParts. */
|
|
815
|
+
if (last && last.type === "literal") last.value += piece.value;
|
|
816
|
+
else out.push({ type: "literal", value: piece.value });
|
|
817
|
+
continue;
|
|
818
|
+
}
|
|
819
|
+
const handler = handlerByToken.get(piece.value);
|
|
820
|
+
/* c8 ignore start @preserve -- unreachable, see the same guard's
|
|
821
|
+
comment above in the un-compiled formatToParts. */
|
|
822
|
+
if (!handler) throw new Error(`temporal-fmt: unknown token "${piece.value}"`);
|
|
823
|
+
/* c8 ignore stop @preserve */
|
|
824
|
+
if (temporal[handler.field] === void 0) {
|
|
825
|
+
throw new Error(`temporal-fmt: token "${piece.value}" requires "${String(handler.field)}".`);
|
|
826
|
+
}
|
|
827
|
+
out.push({ type: "token", value: handler.handler(temporal, locale), token: piece.value });
|
|
828
|
+
}
|
|
829
|
+
return out;
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
// src/modApi.ts
|
|
837
|
+
function buildModContextFor(modName) {
|
|
838
|
+
return {
|
|
839
|
+
registerLocale,
|
|
840
|
+
registerLocaleVocab,
|
|
841
|
+
registerRelativeGrammar,
|
|
842
|
+
createFormatter,
|
|
843
|
+
createHolidayCalendar,
|
|
844
|
+
overrideFormat(impl) {
|
|
845
|
+
const original = getFormatImpl();
|
|
846
|
+
setFormatOverride((...args) => impl(original, ...args), modName);
|
|
847
|
+
},
|
|
848
|
+
overrideParse(impl) {
|
|
849
|
+
const original = getParseImpl();
|
|
850
|
+
setParseOverride((...args) => impl(original, ...args), modName);
|
|
851
|
+
},
|
|
852
|
+
overrideCompileFormat(impl) {
|
|
853
|
+
const original = getCompileFormatImpl();
|
|
854
|
+
setCompileFormatOverride((...args) => impl(original, ...args), modName);
|
|
855
|
+
},
|
|
856
|
+
overrideCompileParser(impl) {
|
|
857
|
+
const original = getCompileParserImpl();
|
|
858
|
+
setCompileParserOverride((...args) => impl(original, ...args), modName);
|
|
859
|
+
},
|
|
860
|
+
overrideParseRelative(impl) {
|
|
861
|
+
const original = getParseRelativeImpl();
|
|
862
|
+
setParseRelativeOverride((...args) => impl(original, ...args), modName);
|
|
863
|
+
},
|
|
864
|
+
overrideExplainFormat(impl) {
|
|
865
|
+
const original = getExplainFormatImpl();
|
|
866
|
+
setExplainFormatOverride((...args) => impl(original, ...args), modName);
|
|
867
|
+
},
|
|
868
|
+
overrideTokenizeFormat(impl) {
|
|
869
|
+
const original = getTokenizeFormatImpl();
|
|
870
|
+
setTokenizeFormatOverride((...args) => impl(original, ...args), modName);
|
|
871
|
+
},
|
|
872
|
+
overrideListTokens(impl) {
|
|
873
|
+
const original = getListTokensImpl();
|
|
874
|
+
setListTokensOverride((...args) => impl(original, ...args), modName);
|
|
875
|
+
},
|
|
876
|
+
overrideTokenInfo(impl) {
|
|
877
|
+
const original = getTokenInfoImpl();
|
|
878
|
+
setTokenInfoOverride((...args) => impl(original, ...args), modName);
|
|
879
|
+
},
|
|
880
|
+
overrideIsValidFormat(impl) {
|
|
881
|
+
const original = getIsValidFormatImpl();
|
|
882
|
+
setIsValidFormatOverride((...args) => impl(original, ...args), modName);
|
|
883
|
+
},
|
|
884
|
+
overrideValidateFormat(impl) {
|
|
885
|
+
const original = getValidateFormatImpl();
|
|
886
|
+
setValidateFormatOverride((...args) => impl(original, ...args), modName);
|
|
887
|
+
},
|
|
888
|
+
overrideFieldForToken(impl) {
|
|
889
|
+
const original = getFieldForTokenImpl();
|
|
890
|
+
setFieldForTokenOverride((...args) => impl(original, ...args), modName);
|
|
891
|
+
},
|
|
892
|
+
overrideMonthsInYear(impl) {
|
|
893
|
+
const original = getMonthsInYearImpl();
|
|
894
|
+
setMonthsInYearOverride((...args) => impl(original, ...args), modName);
|
|
895
|
+
},
|
|
896
|
+
overrideIsLeapYear(impl) {
|
|
897
|
+
const original = getIsLeapYearImpl();
|
|
898
|
+
setIsLeapYearOverride((...args) => impl(original, ...args), modName);
|
|
899
|
+
},
|
|
900
|
+
overrideIsLeapMonth(impl) {
|
|
901
|
+
const original = getIsLeapMonthImpl();
|
|
902
|
+
setIsLeapMonthOverride((...args) => impl(original, ...args), modName);
|
|
903
|
+
},
|
|
904
|
+
overrideWeekOfYear(impl) {
|
|
905
|
+
const original = getWeekOfYearImpl();
|
|
906
|
+
setWeekOfYearOverride((...args) => impl(original, ...args), modName);
|
|
907
|
+
},
|
|
908
|
+
overrideWeekYear(impl) {
|
|
909
|
+
const original = getWeekYearImpl();
|
|
910
|
+
setWeekYearOverride((...args) => impl(original, ...args), modName);
|
|
911
|
+
},
|
|
912
|
+
overrideGetMonth(impl) {
|
|
913
|
+
const original = getGetMonthImpl();
|
|
914
|
+
setGetMonthOverride((...args) => impl(original, ...args), modName);
|
|
915
|
+
},
|
|
916
|
+
overrideGetWeekday(impl) {
|
|
917
|
+
const original = getGetWeekdayImpl();
|
|
918
|
+
setGetWeekdayOverride((...args) => impl(original, ...args), modName);
|
|
919
|
+
},
|
|
920
|
+
overrideIsEqual(impl) {
|
|
921
|
+
const original = getIsEqualImpl();
|
|
922
|
+
setIsEqualOverride((...args) => impl(original, ...args), modName);
|
|
923
|
+
},
|
|
924
|
+
overrideIsBefore(impl) {
|
|
925
|
+
const original = getIsBeforeImpl();
|
|
926
|
+
setIsBeforeOverride((...args) => impl(original, ...args), modName);
|
|
927
|
+
},
|
|
928
|
+
overrideIsAfter(impl) {
|
|
929
|
+
const original = getIsAfterImpl();
|
|
930
|
+
setIsAfterOverride((...args) => impl(original, ...args), modName);
|
|
931
|
+
},
|
|
932
|
+
overrideClamp(impl) {
|
|
933
|
+
const original = getClampImpl();
|
|
934
|
+
setClampOverride((...args) => impl(original, ...args), modName);
|
|
935
|
+
},
|
|
936
|
+
overrideIsBetween(impl) {
|
|
937
|
+
const original = getIsBetweenImpl();
|
|
938
|
+
setIsBetweenOverride((...args) => impl(original, ...args), modName);
|
|
939
|
+
},
|
|
940
|
+
overrideIsToday(impl) {
|
|
941
|
+
const original = getIsTodayImpl();
|
|
942
|
+
setIsTodayOverride((...args) => impl(original, ...args), modName);
|
|
943
|
+
},
|
|
944
|
+
overrideIsTomorrow(impl) {
|
|
945
|
+
const original = getIsTomorrowImpl();
|
|
946
|
+
setIsTomorrowOverride((...args) => impl(original, ...args), modName);
|
|
947
|
+
},
|
|
948
|
+
overrideIsYesterday(impl) {
|
|
949
|
+
const original = getIsYesterdayImpl();
|
|
950
|
+
setIsYesterdayOverride((...args) => impl(original, ...args), modName);
|
|
951
|
+
},
|
|
952
|
+
overrideIsSameDay(impl) {
|
|
953
|
+
const original = getIsSameDayImpl();
|
|
954
|
+
setIsSameDayOverride((...args) => impl(original, ...args), modName);
|
|
955
|
+
},
|
|
956
|
+
overrideIsSameWeek(impl) {
|
|
957
|
+
const original = getIsSameWeekImpl();
|
|
958
|
+
setIsSameWeekOverride((...args) => impl(original, ...args), modName);
|
|
959
|
+
},
|
|
960
|
+
overrideIsSameMonth(impl) {
|
|
961
|
+
const original = getIsSameMonthImpl();
|
|
962
|
+
setIsSameMonthOverride((...args) => impl(original, ...args), modName);
|
|
963
|
+
},
|
|
964
|
+
overrideIsSameQuarter(impl) {
|
|
965
|
+
const original = getIsSameQuarterImpl();
|
|
966
|
+
setIsSameQuarterOverride((...args) => impl(original, ...args), modName);
|
|
967
|
+
},
|
|
968
|
+
overrideIsSameYear(impl) {
|
|
969
|
+
const original = getIsSameYearImpl();
|
|
970
|
+
setIsSameYearOverride((...args) => impl(original, ...args), modName);
|
|
971
|
+
},
|
|
972
|
+
overrideIsWeekday(impl) {
|
|
973
|
+
const original = getIsWeekdayImpl();
|
|
974
|
+
setIsWeekdayOverride((...args) => impl(original, ...args), modName);
|
|
975
|
+
},
|
|
976
|
+
overrideFloor(impl) {
|
|
977
|
+
const original = getFloorImpl();
|
|
978
|
+
setFloorOverride((...args) => impl(original, ...args), modName);
|
|
979
|
+
},
|
|
980
|
+
overrideCeil(impl) {
|
|
981
|
+
const original = getCeilImpl();
|
|
982
|
+
setCeilOverride((...args) => impl(original, ...args), modName);
|
|
983
|
+
},
|
|
984
|
+
overrideTruncate(impl) {
|
|
985
|
+
const original = getTruncateImpl();
|
|
986
|
+
setTruncateOverride((...args) => impl(original, ...args), modName);
|
|
987
|
+
},
|
|
988
|
+
overrideParseRFC3339(impl) {
|
|
989
|
+
const original = getParseRFC3339Impl();
|
|
990
|
+
setParseRFC3339Override((...args) => impl(original, ...args), modName);
|
|
991
|
+
},
|
|
992
|
+
overrideFormatRFC3339(impl) {
|
|
993
|
+
const original = getFormatRFC3339Impl();
|
|
994
|
+
setFormatRFC3339Override((...args) => impl(original, ...args), modName);
|
|
995
|
+
},
|
|
996
|
+
overrideParseRFC2822(impl) {
|
|
997
|
+
const original = getParseRFC2822Impl();
|
|
998
|
+
setParseRFC2822Override((...args) => impl(original, ...args), modName);
|
|
999
|
+
},
|
|
1000
|
+
overrideParseHTTPDate(impl) {
|
|
1001
|
+
const original = getParseHTTPDateImpl();
|
|
1002
|
+
setParseHTTPDateOverride((...args) => impl(original, ...args), modName);
|
|
1003
|
+
},
|
|
1004
|
+
overrideFromUnixMicroseconds(impl) {
|
|
1005
|
+
const original = getFromUnixMicrosecondsImpl();
|
|
1006
|
+
setFromUnixMicrosecondsOverride((...args) => impl(original, ...args), modName);
|
|
1007
|
+
},
|
|
1008
|
+
overrideFromUnixNanoseconds(impl) {
|
|
1009
|
+
const original = getFromUnixNanosecondsImpl();
|
|
1010
|
+
setFromUnixNanosecondsOverride((...args) => impl(original, ...args), modName);
|
|
1011
|
+
},
|
|
1012
|
+
overrideToUnixSeconds(impl) {
|
|
1013
|
+
const original = getToUnixSecondsImpl();
|
|
1014
|
+
setToUnixSecondsOverride((...args) => impl(original, ...args), modName);
|
|
1015
|
+
},
|
|
1016
|
+
overrideToUnixMilliseconds(impl) {
|
|
1017
|
+
const original = getToUnixMillisecondsImpl();
|
|
1018
|
+
setToUnixMillisecondsOverride((...args) => impl(original, ...args), modName);
|
|
1019
|
+
},
|
|
1020
|
+
overrideToUnixMicroseconds(impl) {
|
|
1021
|
+
const original = getToUnixMicrosecondsImpl();
|
|
1022
|
+
setToUnixMicrosecondsOverride((...args) => impl(original, ...args), modName);
|
|
1023
|
+
},
|
|
1024
|
+
overrideToUnixNanoseconds(impl) {
|
|
1025
|
+
const original = getToUnixNanosecondsImpl();
|
|
1026
|
+
setToUnixNanosecondsOverride((...args) => impl(original, ...args), modName);
|
|
1027
|
+
},
|
|
1028
|
+
overrideParseSQL(impl) {
|
|
1029
|
+
const original = getParseSQLImpl();
|
|
1030
|
+
setParseSQLOverride((...args) => impl(original, ...args), modName);
|
|
1031
|
+
},
|
|
1032
|
+
overrideFormatSQL(impl) {
|
|
1033
|
+
const original = getFormatSQLImpl();
|
|
1034
|
+
setFormatSQLOverride((...args) => impl(original, ...args), modName);
|
|
1035
|
+
},
|
|
1036
|
+
overrideFormatDurationToParts(impl) {
|
|
1037
|
+
const original = getFormatDurationToPartsImpl();
|
|
1038
|
+
setFormatDurationToPartsOverride((...args) => impl(original, ...args), modName);
|
|
1039
|
+
},
|
|
1040
|
+
overrideParseDuration(impl) {
|
|
1041
|
+
const original = getParseDurationImpl();
|
|
1042
|
+
setParseDurationOverride((...args) => impl(original, ...args), modName);
|
|
1043
|
+
},
|
|
1044
|
+
overrideParseISODuration(impl) {
|
|
1045
|
+
const original = getParseISODurationImpl();
|
|
1046
|
+
setParseISODurationOverride((...args) => impl(original, ...args), modName);
|
|
1047
|
+
},
|
|
1048
|
+
overrideFormatISODuration(impl) {
|
|
1049
|
+
const original = getFormatISODurationImpl();
|
|
1050
|
+
setFormatISODurationOverride((...args) => impl(original, ...args), modName);
|
|
1051
|
+
},
|
|
1052
|
+
overrideBalanceDuration(impl) {
|
|
1053
|
+
const original = getBalanceDurationImpl();
|
|
1054
|
+
setBalanceDurationOverride((...args) => impl(original, ...args), modName);
|
|
1055
|
+
},
|
|
1056
|
+
overrideCompareDuration(impl) {
|
|
1057
|
+
const original = getCompareDurationImpl();
|
|
1058
|
+
setCompareDurationOverride((...args) => impl(original, ...args), modName);
|
|
1059
|
+
},
|
|
1060
|
+
overrideSubtractDuration(impl) {
|
|
1061
|
+
const original = getSubtractDurationImpl();
|
|
1062
|
+
setSubtractDurationOverride((...args) => impl(original, ...args), modName);
|
|
1063
|
+
},
|
|
1064
|
+
overrideGetLocale(impl) {
|
|
1065
|
+
const original = getGetLocaleImpl();
|
|
1066
|
+
setGetLocaleOverride((...args) => impl(original, ...args), modName);
|
|
1067
|
+
},
|
|
1068
|
+
overrideHasLocale(impl) {
|
|
1069
|
+
const original = getHasLocaleImpl();
|
|
1070
|
+
setHasLocaleOverride((...args) => impl(original, ...args), modName);
|
|
1071
|
+
},
|
|
1072
|
+
overrideCreateConfig(impl) {
|
|
1073
|
+
const original = getCreateConfigImpl();
|
|
1074
|
+
setCreateConfigOverride((...args) => impl(original, ...args), modName);
|
|
1075
|
+
},
|
|
1076
|
+
overrideMergeWithConfig(impl) {
|
|
1077
|
+
const original = getMergeWithConfigImpl();
|
|
1078
|
+
setMergeWithConfigOverride((...args) => impl(original, ...args), modName);
|
|
1079
|
+
},
|
|
1080
|
+
overrideListRegisteredGrammars(impl) {
|
|
1081
|
+
const original = getListRegisteredGrammarsImpl();
|
|
1082
|
+
setListRegisteredGrammarsOverride((...args) => impl(original, ...args), modName);
|
|
1083
|
+
},
|
|
1084
|
+
overrideInterval(impl) {
|
|
1085
|
+
const original = getIntervalImpl();
|
|
1086
|
+
setIntervalOverride((...args) => impl(original, ...args), modName);
|
|
1087
|
+
},
|
|
1088
|
+
overrideOverlaps(impl) {
|
|
1089
|
+
const original = getOverlapsImpl();
|
|
1090
|
+
setOverlapsOverride((...args) => impl(original, ...args), modName);
|
|
1091
|
+
},
|
|
1092
|
+
overrideIntersection(impl) {
|
|
1093
|
+
const original = getIntersectionImpl();
|
|
1094
|
+
setIntersectionOverride((...args) => impl(original, ...args), modName);
|
|
1095
|
+
},
|
|
1096
|
+
overrideUnion(impl) {
|
|
1097
|
+
const original = getUnionImpl();
|
|
1098
|
+
setUnionOverride((...args) => impl(original, ...args), modName);
|
|
1099
|
+
},
|
|
1100
|
+
overrideMergeIntervals(impl) {
|
|
1101
|
+
const original = getMergeIntervalsImpl();
|
|
1102
|
+
setMergeIntervalsOverride((...args) => impl(original, ...args), modName);
|
|
1103
|
+
},
|
|
1104
|
+
overrideFormatRangeToParts(impl) {
|
|
1105
|
+
const original = getFormatRangeToPartsImpl();
|
|
1106
|
+
setFormatRangeToPartsOverride((...args) => impl(original, ...args), modName);
|
|
1107
|
+
},
|
|
1108
|
+
overrideBetween(impl) {
|
|
1109
|
+
const original = getBetweenImpl();
|
|
1110
|
+
setBetweenOverride((...args) => impl(original, ...args), modName);
|
|
1111
|
+
},
|
|
1112
|
+
overrideParseRRule(impl) {
|
|
1113
|
+
const original = getParseRRuleImpl();
|
|
1114
|
+
setParseRRuleOverride((...args) => impl(original, ...args), modName);
|
|
1115
|
+
},
|
|
1116
|
+
overrideFormatRRule(impl) {
|
|
1117
|
+
const original = getFormatRRuleImpl();
|
|
1118
|
+
setFormatRRuleOverride((...args) => impl(original, ...args), modName);
|
|
1119
|
+
},
|
|
1120
|
+
overrideCreateBusinessCalendar(impl) {
|
|
1121
|
+
const original = getCreateBusinessCalendarImpl();
|
|
1122
|
+
setCreateBusinessCalendarOverride((...args) => impl(original, ...args), modName);
|
|
1123
|
+
},
|
|
1124
|
+
overrideSubtractBusinessDays(impl) {
|
|
1125
|
+
const original = getSubtractBusinessDaysImpl();
|
|
1126
|
+
setSubtractBusinessDaysOverride((...args) => impl(original, ...args), modName);
|
|
1127
|
+
},
|
|
1128
|
+
overrideNextHoliday(impl) {
|
|
1129
|
+
const original = getNextHolidayImpl();
|
|
1130
|
+
setNextHolidayOverride((...args) => impl(original, ...args), modName);
|
|
1131
|
+
},
|
|
1132
|
+
overridePreviousHoliday(impl) {
|
|
1133
|
+
const original = getPreviousHolidayImpl();
|
|
1134
|
+
setPreviousHolidayOverride((...args) => impl(original, ...args), modName);
|
|
1135
|
+
},
|
|
1136
|
+
overrideResolveZoned(impl) {
|
|
1137
|
+
const original = getResolveZonedImpl();
|
|
1138
|
+
setResolveZonedOverride((...args) => impl(original, ...args), modName);
|
|
1139
|
+
},
|
|
1140
|
+
overrideGetNextTransition(impl) {
|
|
1141
|
+
const original = getGetNextTransitionImpl();
|
|
1142
|
+
setGetNextTransitionOverride((...args) => impl(original, ...args), modName);
|
|
1143
|
+
},
|
|
1144
|
+
overrideGetPreviousTransition(impl) {
|
|
1145
|
+
const original = getGetPreviousTransitionImpl();
|
|
1146
|
+
setGetPreviousTransitionOverride((...args) => impl(original, ...args), modName);
|
|
1147
|
+
},
|
|
1148
|
+
overridePossibleInstantsFor(impl) {
|
|
1149
|
+
const original = getPossibleInstantsForImpl();
|
|
1150
|
+
setPossibleInstantsForOverride((...args) => impl(original, ...args), modName);
|
|
1151
|
+
},
|
|
1152
|
+
overrideGetAutocompleteData(impl) {
|
|
1153
|
+
const original = getGetAutocompleteDataImpl();
|
|
1154
|
+
setGetAutocompleteDataOverride((...args) => impl(original, ...args), modName);
|
|
1155
|
+
},
|
|
1156
|
+
overrideGetHoverDocs(impl) {
|
|
1157
|
+
const original = getGetHoverDocsImpl();
|
|
1158
|
+
setGetHoverDocsOverride((...args) => impl(original, ...args), modName);
|
|
1159
|
+
},
|
|
1160
|
+
overrideGetInlineDiagnostics(impl) {
|
|
1161
|
+
const original = getGetInlineDiagnosticsImpl();
|
|
1162
|
+
setGetInlineDiagnosticsOverride((...args) => impl(original, ...args), modName);
|
|
1163
|
+
},
|
|
1164
|
+
overridePreviewFormat(impl) {
|
|
1165
|
+
const original = getPreviewFormatImpl();
|
|
1166
|
+
setPreviewFormatOverride((...args) => impl(original, ...args), modName);
|
|
1167
|
+
},
|
|
1168
|
+
overrideGetDocUrl(impl) {
|
|
1169
|
+
const original = getGetDocUrlImpl();
|
|
1170
|
+
setGetDocUrlOverride((...args) => impl(original, ...args), modName);
|
|
1171
|
+
},
|
|
1172
|
+
overrideTranslateDateFnsFormatString(impl) {
|
|
1173
|
+
const original = getTranslateDateFnsFormatStringImpl();
|
|
1174
|
+
setTranslateDateFnsFormatStringOverride((...args) => impl(original, ...args), modName);
|
|
1175
|
+
}
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
function buildModContext() {
|
|
1179
|
+
return buildModContextFor("(unattributed)");
|
|
1180
|
+
}
|
|
1181
|
+
function buildTrackedModContext(modName, onRegister) {
|
|
1182
|
+
const base = buildModContextFor(modName);
|
|
1183
|
+
return {
|
|
1184
|
+
// Everything not called out below (all 81 zero-fan-out override
|
|
1185
|
+
// points from runtime.ts, plus createHolidayCalendar) passes through
|
|
1186
|
+
// untracked — see the comment on createHolidayCalendar's own case
|
|
1187
|
+
// above for why untracked is correct for it, and generate.mjs for
|
|
1188
|
+
// why we don't hand-list 81 identical `overrideXxx(impl) { base.
|
|
1189
|
+
// overrideXxx(impl); onRegister(...) }` pass-throughs here: none of
|
|
1190
|
+
// them have a shared key two mods could conflict on the way a locale
|
|
1191
|
+
// tag or token name does, so there's nothing meaningful to track.
|
|
1192
|
+
...base,
|
|
1193
|
+
registerLocale(locale, vocab) {
|
|
1194
|
+
onRegister({ kind: "locale", key: locale });
|
|
1195
|
+
base.registerLocale(locale, vocab);
|
|
1196
|
+
},
|
|
1197
|
+
registerLocaleVocab(locale, vocab) {
|
|
1198
|
+
onRegister({ kind: "localeVocab", key: locale });
|
|
1199
|
+
base.registerLocaleVocab(locale, vocab);
|
|
1200
|
+
},
|
|
1201
|
+
registerRelativeGrammar(grammar) {
|
|
1202
|
+
onRegister({ kind: "relativeGrammar", key: grammar.language });
|
|
1203
|
+
base.registerRelativeGrammar(grammar);
|
|
1204
|
+
},
|
|
1205
|
+
createFormatter(options) {
|
|
1206
|
+
for (const token of options?.tokens ?? []) {
|
|
1207
|
+
onRegister({ kind: "formatterTokens", key: token.name });
|
|
1208
|
+
}
|
|
1209
|
+
return base.createFormatter(options);
|
|
1210
|
+
},
|
|
1211
|
+
createHolidayCalendar(specs) {
|
|
1212
|
+
return base.createHolidayCalendar(specs);
|
|
1213
|
+
},
|
|
1214
|
+
overrideFormat(impl) {
|
|
1215
|
+
base.overrideFormat(impl);
|
|
1216
|
+
onRegister({ kind: "overrideFormat", key: "format" });
|
|
1217
|
+
},
|
|
1218
|
+
overrideParse(impl) {
|
|
1219
|
+
base.overrideParse(impl);
|
|
1220
|
+
onRegister({ kind: "overrideParse", key: "parse" });
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
function isMod(value) {
|
|
1225
|
+
if (typeof value !== "object" || value === null) return false;
|
|
1226
|
+
const v = value;
|
|
1227
|
+
if (typeof v.name !== "string" || v.name.length === 0) return false;
|
|
1228
|
+
if (typeof v.register !== "function") return false;
|
|
1229
|
+
if (v.requires !== void 0 && !(Array.isArray(v.requires) && v.requires.every((r) => typeof r === "string"))) return false;
|
|
1230
|
+
if (v.priority !== void 0 && typeof v.priority !== "number") return false;
|
|
1231
|
+
return true;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
// src/index.ts
|
|
1235
|
+
var format = (...args) => getFormatImpl()(...args);
|
|
1236
|
+
var parse = (...args) => getParseImpl()(...args);
|
|
1237
|
+
var compileFormat = (...args) => getCompileFormatImpl()(...args);
|
|
1238
|
+
var compileParser = (...args) => getCompileParserImpl()(...args);
|
|
1239
|
+
var parseRelative = (...args) => getParseRelativeImpl()(...args);
|
|
1240
|
+
var explainFormat = (...args) => getExplainFormatImpl()(...args);
|
|
1241
|
+
var tokenizeFormat = (...args) => getTokenizeFormatImpl()(...args);
|
|
1242
|
+
var listTokens = (...args) => getListTokensImpl()(...args);
|
|
1243
|
+
var tokenInfo = (...args) => getTokenInfoImpl()(...args);
|
|
1244
|
+
var isValidFormat = (...args) => getIsValidFormatImpl()(...args);
|
|
1245
|
+
var validateFormat = (...args) => getValidateFormatImpl()(...args);
|
|
1246
|
+
var fieldForToken = (...args) => getFieldForTokenImpl()(...args);
|
|
1247
|
+
var monthsInYear = (...args) => getMonthsInYearImpl()(...args);
|
|
1248
|
+
var isLeapYear = (...args) => getIsLeapYearImpl()(...args);
|
|
1249
|
+
var isLeapMonth = (...args) => getIsLeapMonthImpl()(...args);
|
|
1250
|
+
var weekOfYear = (...args) => getWeekOfYearImpl()(...args);
|
|
1251
|
+
var weekYear = (...args) => getWeekYearImpl()(...args);
|
|
1252
|
+
var getMonth = (...args) => getGetMonthImpl()(...args);
|
|
1253
|
+
var getWeekday = (...args) => getGetWeekdayImpl()(...args);
|
|
1254
|
+
var isEqual = (...args) => getIsEqualImpl()(...args);
|
|
1255
|
+
var isBefore2 = (...args) => getIsBeforeImpl()(...args);
|
|
1256
|
+
var isAfter2 = (...args) => getIsAfterImpl()(...args);
|
|
1257
|
+
var clamp = (...args) => getClampImpl()(...args);
|
|
1258
|
+
var isBetween = (...args) => getIsBetweenImpl()(...args);
|
|
1259
|
+
var isToday = (...args) => getIsTodayImpl()(...args);
|
|
1260
|
+
var isTomorrow = (...args) => getIsTomorrowImpl()(...args);
|
|
1261
|
+
var isYesterday = (...args) => getIsYesterdayImpl()(...args);
|
|
1262
|
+
var isSameDay = (...args) => getIsSameDayImpl()(...args);
|
|
1263
|
+
var isSameWeek = (...args) => getIsSameWeekImpl()(...args);
|
|
1264
|
+
var isSameMonth = (...args) => getIsSameMonthImpl()(...args);
|
|
1265
|
+
var isSameQuarter = (...args) => getIsSameQuarterImpl()(...args);
|
|
1266
|
+
var isSameYear = (...args) => getIsSameYearImpl()(...args);
|
|
1267
|
+
var isWeekday = (...args) => getIsWeekdayImpl()(...args);
|
|
1268
|
+
var floor = (...args) => getFloorImpl()(...args);
|
|
1269
|
+
var ceil = (...args) => getCeilImpl()(...args);
|
|
1270
|
+
var truncate = (...args) => getTruncateImpl()(...args);
|
|
1271
|
+
var parseRFC3339 = (...args) => getParseRFC3339Impl()(...args);
|
|
1272
|
+
var formatRFC3339 = (...args) => getFormatRFC3339Impl()(...args);
|
|
1273
|
+
var parseRFC2822 = (...args) => getParseRFC2822Impl()(...args);
|
|
1274
|
+
var parseHTTPDate = (...args) => getParseHTTPDateImpl()(...args);
|
|
1275
|
+
var fromUnixMicroseconds = (...args) => getFromUnixMicrosecondsImpl()(...args);
|
|
1276
|
+
var fromUnixNanoseconds = (...args) => getFromUnixNanosecondsImpl()(...args);
|
|
1277
|
+
var toUnixSeconds = (...args) => getToUnixSecondsImpl()(...args);
|
|
1278
|
+
var toUnixMilliseconds = (...args) => getToUnixMillisecondsImpl()(...args);
|
|
1279
|
+
var toUnixMicroseconds = (...args) => getToUnixMicrosecondsImpl()(...args);
|
|
1280
|
+
var toUnixNanoseconds = (...args) => getToUnixNanosecondsImpl()(...args);
|
|
1281
|
+
var parseSQL = (...args) => getParseSQLImpl()(...args);
|
|
1282
|
+
var formatSQL = (...args) => getFormatSQLImpl()(...args);
|
|
1283
|
+
var formatDurationToParts = (...args) => getFormatDurationToPartsImpl()(...args);
|
|
1284
|
+
var parseDuration = (...args) => getParseDurationImpl()(...args);
|
|
1285
|
+
var parseISODuration = (...args) => getParseISODurationImpl()(...args);
|
|
1286
|
+
var formatISODuration = (...args) => getFormatISODurationImpl()(...args);
|
|
1287
|
+
var balanceDuration = (...args) => getBalanceDurationImpl()(...args);
|
|
1288
|
+
var compareDuration = (...args) => getCompareDurationImpl()(...args);
|
|
1289
|
+
var subtractDuration = (...args) => getSubtractDurationImpl()(...args);
|
|
1290
|
+
var getLocale = (...args) => getGetLocaleImpl()(...args);
|
|
1291
|
+
var hasLocale = (...args) => getHasLocaleImpl()(...args);
|
|
1292
|
+
var createConfig = (...args) => getCreateConfigImpl()(...args);
|
|
1293
|
+
var mergeWithConfig = (...args) => getMergeWithConfigImpl()(...args);
|
|
1294
|
+
var listRegisteredGrammars = (...args) => getListRegisteredGrammarsImpl()(...args);
|
|
1295
|
+
var interval = (...args) => getIntervalImpl()(...args);
|
|
1296
|
+
var overlaps = (...args) => getOverlapsImpl()(...args);
|
|
1297
|
+
var intersection = (...args) => getIntersectionImpl()(...args);
|
|
1298
|
+
var union = (...args) => getUnionImpl()(...args);
|
|
1299
|
+
var mergeIntervals = (...args) => getMergeIntervalsImpl()(...args);
|
|
1300
|
+
var formatRangeToParts = (...args) => getFormatRangeToPartsImpl()(...args);
|
|
1301
|
+
var between = (...args) => getBetweenImpl()(...args);
|
|
1302
|
+
var parseRRule = (...args) => getParseRRuleImpl()(...args);
|
|
1303
|
+
var formatRRule = (...args) => getFormatRRuleImpl()(...args);
|
|
1304
|
+
var createBusinessCalendar = (...args) => getCreateBusinessCalendarImpl()(...args);
|
|
1305
|
+
var subtractBusinessDays = (...args) => getSubtractBusinessDaysImpl()(...args);
|
|
1306
|
+
var nextHoliday = (...args) => getNextHolidayImpl()(...args);
|
|
1307
|
+
var previousHoliday = (...args) => getPreviousHolidayImpl()(...args);
|
|
1308
|
+
var resolveZoned = (...args) => getResolveZonedImpl()(...args);
|
|
1309
|
+
var getNextTransition = (...args) => getGetNextTransitionImpl()(...args);
|
|
1310
|
+
var getPreviousTransition = (...args) => getGetPreviousTransitionImpl()(...args);
|
|
1311
|
+
var possibleInstantsFor = (...args) => getPossibleInstantsForImpl()(...args);
|
|
1312
|
+
var getAutocompleteData = (...args) => getGetAutocompleteDataImpl()(...args);
|
|
1313
|
+
var getHoverDocs = (...args) => getGetHoverDocsImpl()(...args);
|
|
1314
|
+
var getInlineDiagnostics = (...args) => getGetInlineDiagnosticsImpl()(...args);
|
|
1315
|
+
var previewFormat = (...args) => getPreviewFormatImpl()(...args);
|
|
1316
|
+
var getDocUrl = (...args) => getGetDocUrlImpl()(...args);
|
|
1317
|
+
var translateDateFnsFormatString = (...args) => getTranslateDateFnsFormatStringImpl()(...args);
|
|
1318
|
+
export {
|
|
1319
|
+
ALL_TOKEN_NAMES,
|
|
1320
|
+
AmbiguousInputError,
|
|
1321
|
+
DATE_FNS_TO_TEMPORAL_FMT,
|
|
1322
|
+
DAYJS_TO_TEMPORAL_FMT,
|
|
1323
|
+
DEFAULT_CONFIG,
|
|
1324
|
+
FORMAT_ONLY_TOKENS,
|
|
1325
|
+
FormatSyntaxError,
|
|
1326
|
+
InvalidCalendarError,
|
|
1327
|
+
InvalidDateError,
|
|
1328
|
+
InvalidDurationError,
|
|
1329
|
+
InvalidLocaleError,
|
|
1330
|
+
InvalidOffsetError,
|
|
1331
|
+
InvalidTimeError,
|
|
1332
|
+
InvalidTimeZoneError,
|
|
1333
|
+
OverrideConflictError,
|
|
1334
|
+
ParseMismatchError,
|
|
1335
|
+
SUPPORTED_NUMBERING_SYSTEMS,
|
|
1336
|
+
TOKEN_METADATA,
|
|
1337
|
+
TemporalFmtError,
|
|
1338
|
+
UnknownTokenError,
|
|
1339
|
+
add,
|
|
1340
|
+
addBusinessDays,
|
|
1341
|
+
addDays,
|
|
1342
|
+
addDuration,
|
|
1343
|
+
addHours,
|
|
1344
|
+
addMilliseconds,
|
|
1345
|
+
addMinutes,
|
|
1346
|
+
addMonths,
|
|
1347
|
+
addSeconds,
|
|
1348
|
+
addWeeks,
|
|
1349
|
+
addYears,
|
|
1350
|
+
analyzeFormat,
|
|
1351
|
+
applyNumbering,
|
|
1352
|
+
applyParseNumbering,
|
|
1353
|
+
asDateFieldView,
|
|
1354
|
+
assertDuration,
|
|
1355
|
+
assertInstant,
|
|
1356
|
+
assertPlainDate,
|
|
1357
|
+
assertPlainDateTime,
|
|
1358
|
+
assertPlainMonthDay,
|
|
1359
|
+
assertPlainTime,
|
|
1360
|
+
assertPlainYearMonth,
|
|
1361
|
+
assertTemporal,
|
|
1362
|
+
assertZonedDateTime,
|
|
1363
|
+
balanceDuration,
|
|
1364
|
+
between,
|
|
1365
|
+
buildModContext,
|
|
1366
|
+
buildModContextFor,
|
|
1367
|
+
buildTrackedModContext,
|
|
1368
|
+
ceil,
|
|
1369
|
+
clamp,
|
|
1370
|
+
compare,
|
|
1371
|
+
compareDuration,
|
|
1372
|
+
compileFormat,
|
|
1373
|
+
compileParser,
|
|
1374
|
+
convertDigits,
|
|
1375
|
+
convertDigitsToAscii,
|
|
1376
|
+
createBusinessCalendar,
|
|
1377
|
+
createConfig,
|
|
1378
|
+
createFormatter,
|
|
1379
|
+
createHolidayCalendar,
|
|
1380
|
+
dayOfYearHelper as dayOfYear,
|
|
1381
|
+
daysInMonth,
|
|
1382
|
+
daysInYear,
|
|
1383
|
+
difference2 as difference,
|
|
1384
|
+
differenceInBusinessDays,
|
|
1385
|
+
differenceInDays,
|
|
1386
|
+
differenceInHours,
|
|
1387
|
+
differenceInMilliseconds,
|
|
1388
|
+
differenceInMinutes,
|
|
1389
|
+
differenceInMonths,
|
|
1390
|
+
differenceInSeconds,
|
|
1391
|
+
differenceInWeeks,
|
|
1392
|
+
differenceInYears,
|
|
1393
|
+
endOf,
|
|
1394
|
+
explainFormat,
|
|
1395
|
+
fieldForToken,
|
|
1396
|
+
floor,
|
|
1397
|
+
format,
|
|
1398
|
+
formatDistance,
|
|
1399
|
+
formatDistanceToNow,
|
|
1400
|
+
formatDuration,
|
|
1401
|
+
formatDurationToParts,
|
|
1402
|
+
formatHTTPDate,
|
|
1403
|
+
formatISO,
|
|
1404
|
+
formatISODuration,
|
|
1405
|
+
formatRFC2822,
|
|
1406
|
+
formatRFC3339,
|
|
1407
|
+
formatRRule,
|
|
1408
|
+
formatRange,
|
|
1409
|
+
formatRangeToParts,
|
|
1410
|
+
formatRelative,
|
|
1411
|
+
formatRelativeToNow,
|
|
1412
|
+
formatSQL,
|
|
1413
|
+
formatToParts,
|
|
1414
|
+
fromUnixMicroseconds,
|
|
1415
|
+
fromUnixMilliseconds,
|
|
1416
|
+
fromUnixNanoseconds,
|
|
1417
|
+
fromUnixSeconds,
|
|
1418
|
+
getAutocompleteData,
|
|
1419
|
+
getDocUrl,
|
|
1420
|
+
getHoverDocs,
|
|
1421
|
+
getInlineDiagnostics,
|
|
1422
|
+
getLocale,
|
|
1423
|
+
getMonth,
|
|
1424
|
+
getNextTransition,
|
|
1425
|
+
getOffset,
|
|
1426
|
+
getOffsetNanoseconds,
|
|
1427
|
+
getPreviousTransition,
|
|
1428
|
+
getQuarter,
|
|
1429
|
+
getTimeZone,
|
|
1430
|
+
getTransitions,
|
|
1431
|
+
getWeekday,
|
|
1432
|
+
hasLocale,
|
|
1433
|
+
holidaysBetween,
|
|
1434
|
+
intersection,
|
|
1435
|
+
intersects,
|
|
1436
|
+
interval,
|
|
1437
|
+
contains as intervalContains,
|
|
1438
|
+
difference as intervalDifference,
|
|
1439
|
+
isAfter as intervalIsAfter,
|
|
1440
|
+
isBefore as intervalIsBefore,
|
|
1441
|
+
subtract as intervalSubtract,
|
|
1442
|
+
isAfter2 as isAfter,
|
|
1443
|
+
isBefore2 as isBefore,
|
|
1444
|
+
isBetween,
|
|
1445
|
+
isBusinessDay,
|
|
1446
|
+
isDST,
|
|
1447
|
+
isDuration,
|
|
1448
|
+
isEqual,
|
|
1449
|
+
isInstant,
|
|
1450
|
+
isLeapMonth,
|
|
1451
|
+
isLeapYear,
|
|
1452
|
+
isMod,
|
|
1453
|
+
isPlainDate,
|
|
1454
|
+
isPlainDateTime,
|
|
1455
|
+
isPlainMonthDay,
|
|
1456
|
+
isPlainTime,
|
|
1457
|
+
isPlainYearMonth,
|
|
1458
|
+
isSameDay,
|
|
1459
|
+
isSameMonth,
|
|
1460
|
+
isSameQuarter,
|
|
1461
|
+
isSameWeek,
|
|
1462
|
+
isSameYear,
|
|
1463
|
+
isTemporal,
|
|
1464
|
+
isToday,
|
|
1465
|
+
isTomorrow,
|
|
1466
|
+
isValidFormat,
|
|
1467
|
+
isWeekday,
|
|
1468
|
+
isWeekend,
|
|
1469
|
+
isYesterday,
|
|
1470
|
+
isZonedDateTime,
|
|
1471
|
+
listRegisteredGrammars,
|
|
1472
|
+
listTokens,
|
|
1473
|
+
max,
|
|
1474
|
+
mergeIntervals,
|
|
1475
|
+
mergeWithConfig,
|
|
1476
|
+
min,
|
|
1477
|
+
monthsInYear,
|
|
1478
|
+
nextBusinessDay,
|
|
1479
|
+
nextHoliday,
|
|
1480
|
+
overlaps,
|
|
1481
|
+
parse,
|
|
1482
|
+
parseDuration,
|
|
1483
|
+
parseHTTPDate,
|
|
1484
|
+
parseISO,
|
|
1485
|
+
parseISODuration,
|
|
1486
|
+
parseRFC2822,
|
|
1487
|
+
parseRFC3339,
|
|
1488
|
+
parseRRule,
|
|
1489
|
+
parseRelative,
|
|
1490
|
+
parseSQL,
|
|
1491
|
+
parseToParts,
|
|
1492
|
+
possibleInstantsFor,
|
|
1493
|
+
previewFormat,
|
|
1494
|
+
previousBusinessDay,
|
|
1495
|
+
previousHoliday,
|
|
1496
|
+
recurrence,
|
|
1497
|
+
registerLocale,
|
|
1498
|
+
registerLocaleVocab,
|
|
1499
|
+
registerRelativeGrammar,
|
|
1500
|
+
resolveZoned,
|
|
1501
|
+
round,
|
|
1502
|
+
roundDuration,
|
|
1503
|
+
roundDuration as roundDurationAlias,
|
|
1504
|
+
safeParse,
|
|
1505
|
+
setTemporal,
|
|
1506
|
+
skip,
|
|
1507
|
+
splitInterval,
|
|
1508
|
+
startOf,
|
|
1509
|
+
subtract2 as subtract,
|
|
1510
|
+
subtractBusinessDays,
|
|
1511
|
+
subtractDays,
|
|
1512
|
+
subtractDuration,
|
|
1513
|
+
subtractHours,
|
|
1514
|
+
subtractMilliseconds,
|
|
1515
|
+
subtractMinutes,
|
|
1516
|
+
subtractMonths,
|
|
1517
|
+
subtractSeconds,
|
|
1518
|
+
subtractWeeks,
|
|
1519
|
+
subtractYears,
|
|
1520
|
+
take,
|
|
1521
|
+
toUnixMicroseconds,
|
|
1522
|
+
toUnixMilliseconds,
|
|
1523
|
+
toUnixNanoseconds,
|
|
1524
|
+
toUnixSeconds,
|
|
1525
|
+
tokenInfo,
|
|
1526
|
+
tokenizeFormat,
|
|
1527
|
+
totalDuration,
|
|
1528
|
+
translateDateFnsFormatString,
|
|
1529
|
+
translateDayjsFormatString,
|
|
1530
|
+
truncate,
|
|
1531
|
+
tryParse,
|
|
1532
|
+
union,
|
|
1533
|
+
validateFormat,
|
|
1534
|
+
weekOfYear,
|
|
1535
|
+
weekYear
|
|
1536
|
+
};
|
|
59
1537
|
//# sourceMappingURL=index.js.map
|