@vielzeug/timit 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # @vielzeug/timit
2
+
3
+ > Temporal-powered date and time utilities for modern TypeScript apps.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@vielzeug/timit)](https://www.npmjs.com/package/@vielzeug/timit) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ `@vielzeug/timit` provides ergonomic, type-safe helpers for the Temporal API: parsing, timezone conversion, date-time arithmetic (with DST safety), range checks, and formatting.
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ pnpm add @vielzeug/timit
13
+ # npm install @vielzeug/timit
14
+ # yarn add @vielzeug/timit
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```ts
20
+ import { d } from '@vielzeug/timit';
21
+
22
+ const meeting = '2026-03-21T10:30:00Z';
23
+ const meetingNY = d.asZoned(meeting, { tz: 'America/New_York' });
24
+ const reminder = d.add(meetingNY, { minutes: -15 });
25
+
26
+ console.log(d.format(reminder, { pattern: 'short', locale: 'en-US', tz: 'America/New_York' }));
27
+ ```
28
+
29
+ Or use individual imports:
30
+
31
+ ```ts
32
+ import { add, format, asZoned } from '@vielzeug/timit';
33
+ // same code, just without the "d." prefix
34
+ ```
35
+
36
+ ## API Quick Reference
37
+
38
+ ### Conversion
39
+ - `asInstant(input, options?)` — Normalize to canonical timeline value
40
+ - `asZoned(input, options?)` — View time in a specific timezone
41
+
42
+ ### Arithmetic
43
+ - `add(input, duration, options?)` — Add duration (DST-safe)
44
+ - `subtract(input, duration, options?)` — Subtract duration (DST-safe)
45
+ - `diff(start, end, options?)` — Compute duration between two times
46
+
47
+ ### Queries
48
+ - `now(tz?)` — Current time in timezone
49
+ - `within(value, start, end, options?)` — Check if time is in range
50
+
51
+ ### Formatting
52
+ - `format(input, options?)` — Format as string with `'short' | 'long' | 'iso' | 'date-only' | 'time-only'`
53
+ - `formatRange(start, end, options?)` — Format time span with browser `Intl.formatRange` fallback
54
+
55
+ ### Exports
56
+ - `Temporal` (from `@js-temporal/polyfill`) for advanced use
57
+
58
+ ## Why timit?
59
+
60
+ ✅ **Temporal-safe**: No fragile Date arithmetic or timezone math
61
+ ✅ **DST-aware**: Handles daylight-saving transitions correctly
62
+ ✅ **Intl-integrated**: Locale formatting without boilerplate
63
+ ✅ **Concise API**: Short, intuitive function names
64
+ ✅ **Polyfilled**: Works in runtimes without native Temporal
65
+
66
+
67
+ ## License
68
+
69
+ MIT © [Helmuth Saatkamp](https://github.com/helmuthdu) — part of the [Vielzeug](https://github.com/helmuthdu/vielzeug) monorepo.
70
+
71
+
72
+
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./timit.cjs`);let t=require(`@js-temporal/polyfill`);exports.Temporal=t.Temporal,exports.add=e.add,exports.asInstant=e.asInstant,exports.asZoned=e.asZoned,exports.d=e.d,exports.diff=e.diff,exports.format=e.format,exports.formatRange=e.formatRange,exports.now=e.now,exports.subtract=e.subtract,exports.within=e.within;
@@ -0,0 +1,2 @@
1
+ export * from './timit';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { Temporal as e, add as t, asInstant as n, asZoned as r, d as i, diff as a, format as o, formatRange as s, now as c, subtract as l, within as u } from "./timit.js";
2
+ export { e as Temporal, t as add, n as asInstant, r as asZoned, i as d, a as diff, o as format, s as formatRange, c as now, l as subtract, u as within };
package/dist/timit.cjs ADDED
@@ -0,0 +1,2 @@
1
+ let e=require(`@js-temporal/polyfill`);var t=`compatible`;function n(t){return t??e.Temporal.Now.timeZoneId()}function r(t){try{return e.Temporal.PlainDateTime.from(t)}catch{return e.Temporal.PlainDate.from(t).toPlainDateTime()}}function i(e){return e?{"date-only":{dateStyle:`short`},iso:{dateStyle:`full`,timeStyle:`long`},long:{dateStyle:`full`,timeStyle:`long`},short:{dateStyle:`short`,timeStyle:`short`},"time-only":{timeStyle:`short`}}[e]:{dateStyle:`medium`,timeStyle:`short`}}function a(t){return e.Temporal.Now.zonedDateTimeISO(n(t))}function o(i,a={}){if(i instanceof e.Temporal.Instant)return i;if(i instanceof e.Temporal.ZonedDateTime)return i.toInstant();if(i instanceof e.Temporal.PlainDateTime){let e=n(a.tz);return i.toZonedDateTime(e,{disambiguation:a.when??t}).toInstant()}if(i instanceof Date)return e.Temporal.Instant.fromEpochMilliseconds(i.getTime());if(typeof i==`number`)return e.Temporal.Instant.fromEpochMilliseconds(i);if(typeof i==`string`)try{return e.Temporal.Instant.from(i)}catch{if(!a.tz)throw TypeError(`String inputs without offset require a tz option.`);return r(i).toZonedDateTime(a.tz,{disambiguation:a.when??t}).toInstant()}throw TypeError(`Unsupported time input type.`)}function s(r,i={}){if(r instanceof e.Temporal.ZonedDateTime){if(!i.tz)return r;let e=n(i.tz);return r.withTimeZone(e)}let a=n(i.tz);return r instanceof e.Temporal.PlainDateTime?r.toZonedDateTime(a,{disambiguation:i.when??t}):o(r,i).toZonedDateTimeISO(a)}function c(e,t,n={}){return s(e,n).add(t)}function l(e,t,n={}){return s(e,n).subtract(t)}function u(e,t,n={}){let{tz:r}=n,i=s(e,{tz:r,when:n.when});return s(t,{tz:r,when:n.when}).since(i,{largestUnit:n.largestUnit,roundingIncrement:n.roundingIncrement,roundingMode:n.roundingMode,smallestUnit:n.smallestUnit})}function d(e,t,n,r={}){let i=o(e,r).epochNanoseconds,a=o(t,r).epochNanoseconds,s=o(n,r).epochNanoseconds;return i>=a&&i<=s}function f(e,t={}){let r=o(e,{tz:t.tz}),a=i(t.pattern);return new Intl.DateTimeFormat(t.locale,{...a,...t.intl,timeZone:n(t.tz)}).format(new Date(r.epochMilliseconds))}function p(e,t,r={}){let a=i(r.pattern),s=new Intl.DateTimeFormat(r.locale,{...a,...r.intl,timeZone:n(r.tz)}),c=new Date(o(e,{tz:r.tz}).epochMilliseconds),l=new Date(o(t,{tz:r.tz}).epochMilliseconds),u=s;return typeof u.formatRange==`function`?u.formatRange(c,l):`${s.format(c)} - ${s.format(l)}`}var m={add:c,asInstant:o,asZoned:s,diff:u,format:f,formatRange:p,now:a,subtract:l,within:d};exports.add=c,exports.asInstant=o,exports.asZoned=s,exports.d=m,exports.diff=u,exports.format=f,exports.formatRange=p,exports.now=a,exports.subtract=l,exports.within=d;
2
+ //# sourceMappingURL=timit.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timit.cjs","names":[],"sources":["../src/timit.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\nexport { Temporal };\n\nexport type DateTimeDisambiguation = 'compatible' | 'earlier' | 'later' | 'reject';\n\n/**\n * Supported input types for date/time operations.\n * - Temporal types preserve timezone and disambiguation info\n * - Date is silently converted to Instant (timezone lost)\n * - Numbers are treated as epoch milliseconds\n * - ISO strings can have offset; plain strings require `tz` option\n */\nexport type TimeInput = Date | Temporal.Instant | Temporal.PlainDateTime | Temporal.ZonedDateTime | number | string;\n\n/**\n * Time zone and disambiguation options for conversions.\n * - `tz`: Time zone ID (e.g., 'America/New_York'). Defaults to system timezone.\n * - `when`: How to resolve ambiguous local times during DST transitions.\n * 'earlier' | 'later' | 'compatible' (default) | 'reject'\n */\nexport interface TimeOptions {\n tz?: string;\n when?: DateTimeDisambiguation;\n}\n\n/**\n * Options for computing differences between times.\n * Extends TimeOptions and adds Temporal.Duration granularity control.\n */\nexport interface DifferenceOptions extends TimeOptions {\n largestUnit?: Temporal.DateTimeUnit;\n roundingIncrement?: number;\n roundingMode?: Temporal.RoundingMode;\n smallestUnit?: Temporal.DateTimeUnit;\n}\n\n/**\n * Common formatting patterns for human-readable output.\n * - 'iso': Full ISO-8601 style (e.g., \"Sunday, March 21, 2026, 10:15:30 AM\")\n * - 'short': Compact style (e.g., \"21/03/2026, 10:15 AM\")\n * - 'long': Expanded style (e.g., \"Sunday, March 21, 2026 at 10:15:30 AM\")\n * - 'date-only': Just the date (e.g., \"21/03/2026\")\n * - 'time-only': Just the time (e.g., \"10:15 AM\")\n */\nexport type FormatPattern = 'iso' | 'short' | 'long' | 'date-only' | 'time-only';\n\n/**\n * Options for formatting times as human-readable strings.\n * - `pattern`: Preset format (covers 80% of common cases)\n * - `locale`: BCP 47 language tag for localization\n * - `tz`: Time zone for display (affects wall-clock time shown)\n * - `intl`: Escape hatch for advanced Intl.DateTimeFormatOptions\n */\nexport interface FormatOptions {\n pattern?: FormatPattern;\n locale?: Intl.LocalesArgument;\n tz?: string;\n intl?: Intl.DateTimeFormatOptions;\n}\n\nconst DEFAULT_DISAMBIGUATION: DateTimeDisambiguation = 'compatible';\n\nfunction resolveTimeZone(tz?: string): string {\n return tz ?? Temporal.Now.timeZoneId();\n}\n\nfunction parsePlainDateTime(value: string): Temporal.PlainDateTime {\n try {\n return Temporal.PlainDateTime.from(value);\n } catch {\n return Temporal.PlainDate.from(value).toPlainDateTime();\n }\n}\n\nfunction resolveFormatPattern(pattern?: FormatPattern): Intl.DateTimeFormatOptions {\n if (!pattern) return { dateStyle: 'medium', timeStyle: 'short' };\n\n const patterns: Record<FormatPattern, Intl.DateTimeFormatOptions> = {\n 'date-only': { dateStyle: 'short' },\n iso: { dateStyle: 'full', timeStyle: 'long' },\n long: { dateStyle: 'full', timeStyle: 'long' },\n short: { dateStyle: 'short', timeStyle: 'short' },\n 'time-only': { timeStyle: 'short' },\n };\n\n return patterns[pattern];\n}\n\nexport function now(tz?: string): Temporal.ZonedDateTime {\n return Temporal.Now.zonedDateTimeISO(resolveTimeZone(tz));\n}\n\nexport function asInstant(input: TimeInput, options: TimeOptions = {}): Temporal.Instant {\n if (input instanceof Temporal.Instant) {\n return input;\n }\n\n if (input instanceof Temporal.ZonedDateTime) {\n return input.toInstant();\n }\n\n if (input instanceof Temporal.PlainDateTime) {\n const tz = resolveTimeZone(options.tz);\n\n return input\n .toZonedDateTime(tz, {\n disambiguation: options.when ?? DEFAULT_DISAMBIGUATION,\n })\n .toInstant();\n }\n\n if (input instanceof Date) {\n return Temporal.Instant.fromEpochMilliseconds(input.getTime());\n }\n\n if (typeof input === 'number') {\n return Temporal.Instant.fromEpochMilliseconds(input);\n }\n\n if (typeof input === 'string') {\n try {\n return Temporal.Instant.from(input);\n } catch {\n if (!options.tz) {\n throw new TypeError('String inputs without offset require a tz option.');\n }\n\n return parsePlainDateTime(input)\n .toZonedDateTime(options.tz, {\n disambiguation: options.when ?? DEFAULT_DISAMBIGUATION,\n })\n .toInstant();\n }\n }\n\n throw new TypeError('Unsupported time input type.');\n}\n\nexport function asZoned(input: TimeInput, options: TimeOptions = {}): Temporal.ZonedDateTime {\n if (input instanceof Temporal.ZonedDateTime) {\n if (!options.tz) {\n return input;\n }\n\n const tz = resolveTimeZone(options.tz);\n\n return input.withTimeZone(tz);\n }\n\n const tz = resolveTimeZone(options.tz);\n\n if (input instanceof Temporal.PlainDateTime) {\n return input.toZonedDateTime(tz, {\n disambiguation: options.when ?? DEFAULT_DISAMBIGUATION,\n });\n }\n\n return asInstant(input, options).toZonedDateTimeISO(tz);\n}\n\nexport function add(\n input: TimeInput,\n duration: Temporal.DurationLike,\n options: TimeOptions = {},\n): Temporal.ZonedDateTime {\n return asZoned(input, options).add(duration);\n}\n\nexport function subtract(\n input: TimeInput,\n duration: Temporal.DurationLike,\n options: TimeOptions = {},\n): Temporal.ZonedDateTime {\n return asZoned(input, options).subtract(duration);\n}\n\nexport function diff(start: TimeInput, end: TimeInput, options: DifferenceOptions = {}): Temporal.Duration {\n const { tz } = options;\n const startDateTime = asZoned(start, { tz, when: options.when });\n const endDateTime = asZoned(end, { tz, when: options.when });\n\n return endDateTime.since(startDateTime, {\n largestUnit: options.largestUnit,\n roundingIncrement: options.roundingIncrement,\n roundingMode: options.roundingMode,\n smallestUnit: options.smallestUnit,\n });\n}\n\nexport function within(input: TimeInput, start: TimeInput, end: TimeInput, options: TimeOptions = {}): boolean {\n const value = asInstant(input, options).epochNanoseconds;\n const lower = asInstant(start, options).epochNanoseconds;\n const upper = asInstant(end, options).epochNanoseconds;\n\n return value >= lower && value <= upper;\n}\n\nexport function format(input: TimeInput, options: FormatOptions = {}): string {\n const instant = asInstant(input, { tz: options.tz });\n const intlOptions = resolveFormatPattern(options.pattern);\n const formatter = new Intl.DateTimeFormat(options.locale, {\n ...intlOptions,\n ...options.intl,\n timeZone: resolveTimeZone(options.tz),\n });\n\n return formatter.format(new Date(instant.epochMilliseconds));\n}\n\nexport function formatRange(start: TimeInput, end: TimeInput, options: FormatOptions = {}): string {\n const intlOptions = resolveFormatPattern(options.pattern);\n const formatter = new Intl.DateTimeFormat(options.locale, {\n ...intlOptions,\n ...options.intl,\n timeZone: resolveTimeZone(options.tz),\n });\n const startDate = new Date(asInstant(start, { tz: options.tz }).epochMilliseconds);\n const endDate = new Date(asInstant(end, { tz: options.tz }).epochMilliseconds);\n\n const formatterWithRange = formatter as Intl.DateTimeFormat & {\n formatRange?: (startDate: Date, endDate: Date) => string;\n };\n\n if (typeof formatterWithRange.formatRange === 'function') {\n return formatterWithRange.formatRange(startDate, endDate);\n }\n\n return `${formatter.format(startDate)} - ${formatter.format(endDate)}`;\n}\n\n/**\n * Namespace object for date/time operations.\n * Provides a grouped API similar to Validit's \"v\" pattern.\n *\n * @example\n * ```ts\n * import { d } from '@vielzeug/timit';\n *\n * d.now('UTC')\n * d.asInstant(input, { tz: 'Europe/Berlin' })\n * d.asZoned(instant)\n * d.add(time, { hours: 1 })\n * d.subtract(time, { minutes: 30 })\n * d.diff(start, end)\n * d.within(time, start, end)\n * d.format(time, { pattern: 'short' })\n * d.formatRange(start, end)\n * ```\n */\nexport const d = {\n add,\n asInstant,\n asZoned,\n diff,\n format,\n formatRange,\n now,\n subtract,\n within,\n} as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AS,EAGpC,SAAgB,EAAO,EAAkB,EAAyB,EAAE,CAAU,CAC5E,IAAM,EAAU,EAAU,EAAO,CAAE,GAAI,EAAQ,GAAI,CAAC,CAC9C,EAAc,EAAqB,EAAQ,QAAQ,CAOzD,OANkB,IAAI,KAAK,eAAe,EAAQ,OAAQ,CACxD,GAAG,EACH,GAAG,EAAQ,KACX,SAAU,EAAgB,EAAQ,GAAG,CACtC,CAAC,CAEe,OAAO,IAAI,KAAK,EAAQ,kBAAkB,CAAC,CAG9D,SAAgB,EAAY,EAAkB,EAAgB,EAAyB,EAAE,CAAU,CACjG,IAAM,EAAc,EAAqB,EAAQ,QAAQ,CACnD,EAAY,IAAI,KAAK,eAAe,EAAQ,OAAQ,CACxD,GAAG,EACH,GAAG,EAAQ,KACX,SAAU,EAAgB,EAAQ,GAAG,CACtC,CAAC,CACI,EAAY,IAAI,KAAK,EAAU,EAAO,CAAE,GAAI,EAAQ,GAAI,CAAC,CAAC,kBAAkB,CAC5E,EAAU,IAAI,KAAK,EAAU,EAAK,CAAE,GAAI,EAAQ,GAAI,CAAC,CAAC,kBAAkB,CAExE,EAAqB,EAQ3B,OAJI,OAAO,EAAmB,aAAgB,WACrC,EAAmB,YAAY,EAAW,EAAQ,CAGpD,GAAG,EAAU,OAAO,EAAU,CAAC,KAAK,EAAU,OAAO,EAAQ,GAsBtE,IAAa,EAAI,CACf,MACA,YACA,UACA,OACA,SACA,cACA,MACA,WACA,SACD"}
@@ -0,0 +1,93 @@
1
+ import { Temporal } from '@js-temporal/polyfill';
2
+ export { Temporal };
3
+ export type DateTimeDisambiguation = 'compatible' | 'earlier' | 'later' | 'reject';
4
+ /**
5
+ * Supported input types for date/time operations.
6
+ * - Temporal types preserve timezone and disambiguation info
7
+ * - Date is silently converted to Instant (timezone lost)
8
+ * - Numbers are treated as epoch milliseconds
9
+ * - ISO strings can have offset; plain strings require `tz` option
10
+ */
11
+ export type TimeInput = Date | Temporal.Instant | Temporal.PlainDateTime | Temporal.ZonedDateTime | number | string;
12
+ /**
13
+ * Time zone and disambiguation options for conversions.
14
+ * - `tz`: Time zone ID (e.g., 'America/New_York'). Defaults to system timezone.
15
+ * - `when`: How to resolve ambiguous local times during DST transitions.
16
+ * 'earlier' | 'later' | 'compatible' (default) | 'reject'
17
+ */
18
+ export interface TimeOptions {
19
+ tz?: string;
20
+ when?: DateTimeDisambiguation;
21
+ }
22
+ /**
23
+ * Options for computing differences between times.
24
+ * Extends TimeOptions and adds Temporal.Duration granularity control.
25
+ */
26
+ export interface DifferenceOptions extends TimeOptions {
27
+ largestUnit?: Temporal.DateTimeUnit;
28
+ roundingIncrement?: number;
29
+ roundingMode?: Temporal.RoundingMode;
30
+ smallestUnit?: Temporal.DateTimeUnit;
31
+ }
32
+ /**
33
+ * Common formatting patterns for human-readable output.
34
+ * - 'iso': Full ISO-8601 style (e.g., "Sunday, March 21, 2026, 10:15:30 AM")
35
+ * - 'short': Compact style (e.g., "21/03/2026, 10:15 AM")
36
+ * - 'long': Expanded style (e.g., "Sunday, March 21, 2026 at 10:15:30 AM")
37
+ * - 'date-only': Just the date (e.g., "21/03/2026")
38
+ * - 'time-only': Just the time (e.g., "10:15 AM")
39
+ */
40
+ export type FormatPattern = 'iso' | 'short' | 'long' | 'date-only' | 'time-only';
41
+ /**
42
+ * Options for formatting times as human-readable strings.
43
+ * - `pattern`: Preset format (covers 80% of common cases)
44
+ * - `locale`: BCP 47 language tag for localization
45
+ * - `tz`: Time zone for display (affects wall-clock time shown)
46
+ * - `intl`: Escape hatch for advanced Intl.DateTimeFormatOptions
47
+ */
48
+ export interface FormatOptions {
49
+ pattern?: FormatPattern;
50
+ locale?: Intl.LocalesArgument;
51
+ tz?: string;
52
+ intl?: Intl.DateTimeFormatOptions;
53
+ }
54
+ export declare function now(tz?: string): Temporal.ZonedDateTime;
55
+ export declare function asInstant(input: TimeInput, options?: TimeOptions): Temporal.Instant;
56
+ export declare function asZoned(input: TimeInput, options?: TimeOptions): Temporal.ZonedDateTime;
57
+ export declare function add(input: TimeInput, duration: Temporal.DurationLike, options?: TimeOptions): Temporal.ZonedDateTime;
58
+ export declare function subtract(input: TimeInput, duration: Temporal.DurationLike, options?: TimeOptions): Temporal.ZonedDateTime;
59
+ export declare function diff(start: TimeInput, end: TimeInput, options?: DifferenceOptions): Temporal.Duration;
60
+ export declare function within(input: TimeInput, start: TimeInput, end: TimeInput, options?: TimeOptions): boolean;
61
+ export declare function format(input: TimeInput, options?: FormatOptions): string;
62
+ export declare function formatRange(start: TimeInput, end: TimeInput, options?: FormatOptions): string;
63
+ /**
64
+ * Namespace object for date/time operations.
65
+ * Provides a grouped API similar to Validit's "v" pattern.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * import { d } from '@vielzeug/timit';
70
+ *
71
+ * d.now('UTC')
72
+ * d.asInstant(input, { tz: 'Europe/Berlin' })
73
+ * d.asZoned(instant)
74
+ * d.add(time, { hours: 1 })
75
+ * d.subtract(time, { minutes: 30 })
76
+ * d.diff(start, end)
77
+ * d.within(time, start, end)
78
+ * d.format(time, { pattern: 'short' })
79
+ * d.formatRange(start, end)
80
+ * ```
81
+ */
82
+ export declare const d: {
83
+ readonly add: typeof add;
84
+ readonly asInstant: typeof asInstant;
85
+ readonly asZoned: typeof asZoned;
86
+ readonly diff: typeof diff;
87
+ readonly format: typeof format;
88
+ readonly formatRange: typeof formatRange;
89
+ readonly now: typeof now;
90
+ readonly subtract: typeof subtract;
91
+ readonly within: typeof within;
92
+ };
93
+ //# sourceMappingURL=timit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timit.d.ts","sourceRoot":"","sources":["../src/timit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,MAAM,MAAM,sBAAsB,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEnF;;;;;;GAMG;AACH,MAAM,MAAM,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CAAC,aAAa,CAExB;AAED,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,QAAQ,CAAC,YAAY,EAC/B,OAAO,GAAE,WAAgB,GACxB,QAAQ,CAAC,aAAa,CAExB;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,GAAE,iBAAsB,GAAG,QAAQ,CAAC,QAAQ,CAWzG;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAM7G;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CAU5E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CAmBjG;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,CAAC;;;;;;;;;;CAUJ,CAAC"}
package/dist/timit.js ADDED
@@ -0,0 +1,119 @@
1
+ import { Temporal as e } from "@js-temporal/polyfill";
2
+ //#region src/timit.ts
3
+ var t = "compatible";
4
+ function n(t) {
5
+ return t ?? e.Now.timeZoneId();
6
+ }
7
+ function r(t) {
8
+ try {
9
+ return e.PlainDateTime.from(t);
10
+ } catch {
11
+ return e.PlainDate.from(t).toPlainDateTime();
12
+ }
13
+ }
14
+ function i(e) {
15
+ return e ? {
16
+ "date-only": { dateStyle: "short" },
17
+ iso: {
18
+ dateStyle: "full",
19
+ timeStyle: "long"
20
+ },
21
+ long: {
22
+ dateStyle: "full",
23
+ timeStyle: "long"
24
+ },
25
+ short: {
26
+ dateStyle: "short",
27
+ timeStyle: "short"
28
+ },
29
+ "time-only": { timeStyle: "short" }
30
+ }[e] : {
31
+ dateStyle: "medium",
32
+ timeStyle: "short"
33
+ };
34
+ }
35
+ function a(t) {
36
+ return e.Now.zonedDateTimeISO(n(t));
37
+ }
38
+ function o(i, a = {}) {
39
+ if (i instanceof e.Instant) return i;
40
+ if (i instanceof e.ZonedDateTime) return i.toInstant();
41
+ if (i instanceof e.PlainDateTime) {
42
+ let e = n(a.tz);
43
+ return i.toZonedDateTime(e, { disambiguation: a.when ?? t }).toInstant();
44
+ }
45
+ if (i instanceof Date) return e.Instant.fromEpochMilliseconds(i.getTime());
46
+ if (typeof i == "number") return e.Instant.fromEpochMilliseconds(i);
47
+ if (typeof i == "string") try {
48
+ return e.Instant.from(i);
49
+ } catch {
50
+ if (!a.tz) throw TypeError("String inputs without offset require a tz option.");
51
+ return r(i).toZonedDateTime(a.tz, { disambiguation: a.when ?? t }).toInstant();
52
+ }
53
+ throw TypeError("Unsupported time input type.");
54
+ }
55
+ function s(r, i = {}) {
56
+ if (r instanceof e.ZonedDateTime) {
57
+ if (!i.tz) return r;
58
+ let e = n(i.tz);
59
+ return r.withTimeZone(e);
60
+ }
61
+ let a = n(i.tz);
62
+ return r instanceof e.PlainDateTime ? r.toZonedDateTime(a, { disambiguation: i.when ?? t }) : o(r, i).toZonedDateTimeISO(a);
63
+ }
64
+ function c(e, t, n = {}) {
65
+ return s(e, n).add(t);
66
+ }
67
+ function l(e, t, n = {}) {
68
+ return s(e, n).subtract(t);
69
+ }
70
+ function u(e, t, n = {}) {
71
+ let { tz: r } = n, i = s(e, {
72
+ tz: r,
73
+ when: n.when
74
+ });
75
+ return s(t, {
76
+ tz: r,
77
+ when: n.when
78
+ }).since(i, {
79
+ largestUnit: n.largestUnit,
80
+ roundingIncrement: n.roundingIncrement,
81
+ roundingMode: n.roundingMode,
82
+ smallestUnit: n.smallestUnit
83
+ });
84
+ }
85
+ function d(e, t, n, r = {}) {
86
+ let i = o(e, r).epochNanoseconds, a = o(t, r).epochNanoseconds, s = o(n, r).epochNanoseconds;
87
+ return i >= a && i <= s;
88
+ }
89
+ function f(e, t = {}) {
90
+ let r = o(e, { tz: t.tz }), a = i(t.pattern);
91
+ return new Intl.DateTimeFormat(t.locale, {
92
+ ...a,
93
+ ...t.intl,
94
+ timeZone: n(t.tz)
95
+ }).format(new Date(r.epochMilliseconds));
96
+ }
97
+ function p(e, t, r = {}) {
98
+ let a = i(r.pattern), s = new Intl.DateTimeFormat(r.locale, {
99
+ ...a,
100
+ ...r.intl,
101
+ timeZone: n(r.tz)
102
+ }), c = new Date(o(e, { tz: r.tz }).epochMilliseconds), l = new Date(o(t, { tz: r.tz }).epochMilliseconds), u = s;
103
+ return typeof u.formatRange == "function" ? u.formatRange(c, l) : `${s.format(c)} - ${s.format(l)}`;
104
+ }
105
+ var m = {
106
+ add: c,
107
+ asInstant: o,
108
+ asZoned: s,
109
+ diff: u,
110
+ format: f,
111
+ formatRange: p,
112
+ now: a,
113
+ subtract: l,
114
+ within: d
115
+ };
116
+ //#endregion
117
+ export { e as Temporal, c as add, o as asInstant, s as asZoned, m as d, u as diff, f as format, p as formatRange, a as now, l as subtract, d as within };
118
+
119
+ //# sourceMappingURL=timit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timit.js","names":[],"sources":["../src/timit.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\nexport { Temporal };\n\nexport type DateTimeDisambiguation = 'compatible' | 'earlier' | 'later' | 'reject';\n\n/**\n * Supported input types for date/time operations.\n * - Temporal types preserve timezone and disambiguation info\n * - Date is silently converted to Instant (timezone lost)\n * - Numbers are treated as epoch milliseconds\n * - ISO strings can have offset; plain strings require `tz` option\n */\nexport type TimeInput = Date | Temporal.Instant | Temporal.PlainDateTime | Temporal.ZonedDateTime | number | string;\n\n/**\n * Time zone and disambiguation options for conversions.\n * - `tz`: Time zone ID (e.g., 'America/New_York'). Defaults to system timezone.\n * - `when`: How to resolve ambiguous local times during DST transitions.\n * 'earlier' | 'later' | 'compatible' (default) | 'reject'\n */\nexport interface TimeOptions {\n tz?: string;\n when?: DateTimeDisambiguation;\n}\n\n/**\n * Options for computing differences between times.\n * Extends TimeOptions and adds Temporal.Duration granularity control.\n */\nexport interface DifferenceOptions extends TimeOptions {\n largestUnit?: Temporal.DateTimeUnit;\n roundingIncrement?: number;\n roundingMode?: Temporal.RoundingMode;\n smallestUnit?: Temporal.DateTimeUnit;\n}\n\n/**\n * Common formatting patterns for human-readable output.\n * - 'iso': Full ISO-8601 style (e.g., \"Sunday, March 21, 2026, 10:15:30 AM\")\n * - 'short': Compact style (e.g., \"21/03/2026, 10:15 AM\")\n * - 'long': Expanded style (e.g., \"Sunday, March 21, 2026 at 10:15:30 AM\")\n * - 'date-only': Just the date (e.g., \"21/03/2026\")\n * - 'time-only': Just the time (e.g., \"10:15 AM\")\n */\nexport type FormatPattern = 'iso' | 'short' | 'long' | 'date-only' | 'time-only';\n\n/**\n * Options for formatting times as human-readable strings.\n * - `pattern`: Preset format (covers 80% of common cases)\n * - `locale`: BCP 47 language tag for localization\n * - `tz`: Time zone for display (affects wall-clock time shown)\n * - `intl`: Escape hatch for advanced Intl.DateTimeFormatOptions\n */\nexport interface FormatOptions {\n pattern?: FormatPattern;\n locale?: Intl.LocalesArgument;\n tz?: string;\n intl?: Intl.DateTimeFormatOptions;\n}\n\nconst DEFAULT_DISAMBIGUATION: DateTimeDisambiguation = 'compatible';\n\nfunction resolveTimeZone(tz?: string): string {\n return tz ?? Temporal.Now.timeZoneId();\n}\n\nfunction parsePlainDateTime(value: string): Temporal.PlainDateTime {\n try {\n return Temporal.PlainDateTime.from(value);\n } catch {\n return Temporal.PlainDate.from(value).toPlainDateTime();\n }\n}\n\nfunction resolveFormatPattern(pattern?: FormatPattern): Intl.DateTimeFormatOptions {\n if (!pattern) return { dateStyle: 'medium', timeStyle: 'short' };\n\n const patterns: Record<FormatPattern, Intl.DateTimeFormatOptions> = {\n 'date-only': { dateStyle: 'short' },\n iso: { dateStyle: 'full', timeStyle: 'long' },\n long: { dateStyle: 'full', timeStyle: 'long' },\n short: { dateStyle: 'short', timeStyle: 'short' },\n 'time-only': { timeStyle: 'short' },\n };\n\n return patterns[pattern];\n}\n\nexport function now(tz?: string): Temporal.ZonedDateTime {\n return Temporal.Now.zonedDateTimeISO(resolveTimeZone(tz));\n}\n\nexport function asInstant(input: TimeInput, options: TimeOptions = {}): Temporal.Instant {\n if (input instanceof Temporal.Instant) {\n return input;\n }\n\n if (input instanceof Temporal.ZonedDateTime) {\n return input.toInstant();\n }\n\n if (input instanceof Temporal.PlainDateTime) {\n const tz = resolveTimeZone(options.tz);\n\n return input\n .toZonedDateTime(tz, {\n disambiguation: options.when ?? DEFAULT_DISAMBIGUATION,\n })\n .toInstant();\n }\n\n if (input instanceof Date) {\n return Temporal.Instant.fromEpochMilliseconds(input.getTime());\n }\n\n if (typeof input === 'number') {\n return Temporal.Instant.fromEpochMilliseconds(input);\n }\n\n if (typeof input === 'string') {\n try {\n return Temporal.Instant.from(input);\n } catch {\n if (!options.tz) {\n throw new TypeError('String inputs without offset require a tz option.');\n }\n\n return parsePlainDateTime(input)\n .toZonedDateTime(options.tz, {\n disambiguation: options.when ?? DEFAULT_DISAMBIGUATION,\n })\n .toInstant();\n }\n }\n\n throw new TypeError('Unsupported time input type.');\n}\n\nexport function asZoned(input: TimeInput, options: TimeOptions = {}): Temporal.ZonedDateTime {\n if (input instanceof Temporal.ZonedDateTime) {\n if (!options.tz) {\n return input;\n }\n\n const tz = resolveTimeZone(options.tz);\n\n return input.withTimeZone(tz);\n }\n\n const tz = resolveTimeZone(options.tz);\n\n if (input instanceof Temporal.PlainDateTime) {\n return input.toZonedDateTime(tz, {\n disambiguation: options.when ?? DEFAULT_DISAMBIGUATION,\n });\n }\n\n return asInstant(input, options).toZonedDateTimeISO(tz);\n}\n\nexport function add(\n input: TimeInput,\n duration: Temporal.DurationLike,\n options: TimeOptions = {},\n): Temporal.ZonedDateTime {\n return asZoned(input, options).add(duration);\n}\n\nexport function subtract(\n input: TimeInput,\n duration: Temporal.DurationLike,\n options: TimeOptions = {},\n): Temporal.ZonedDateTime {\n return asZoned(input, options).subtract(duration);\n}\n\nexport function diff(start: TimeInput, end: TimeInput, options: DifferenceOptions = {}): Temporal.Duration {\n const { tz } = options;\n const startDateTime = asZoned(start, { tz, when: options.when });\n const endDateTime = asZoned(end, { tz, when: options.when });\n\n return endDateTime.since(startDateTime, {\n largestUnit: options.largestUnit,\n roundingIncrement: options.roundingIncrement,\n roundingMode: options.roundingMode,\n smallestUnit: options.smallestUnit,\n });\n}\n\nexport function within(input: TimeInput, start: TimeInput, end: TimeInput, options: TimeOptions = {}): boolean {\n const value = asInstant(input, options).epochNanoseconds;\n const lower = asInstant(start, options).epochNanoseconds;\n const upper = asInstant(end, options).epochNanoseconds;\n\n return value >= lower && value <= upper;\n}\n\nexport function format(input: TimeInput, options: FormatOptions = {}): string {\n const instant = asInstant(input, { tz: options.tz });\n const intlOptions = resolveFormatPattern(options.pattern);\n const formatter = new Intl.DateTimeFormat(options.locale, {\n ...intlOptions,\n ...options.intl,\n timeZone: resolveTimeZone(options.tz),\n });\n\n return formatter.format(new Date(instant.epochMilliseconds));\n}\n\nexport function formatRange(start: TimeInput, end: TimeInput, options: FormatOptions = {}): string {\n const intlOptions = resolveFormatPattern(options.pattern);\n const formatter = new Intl.DateTimeFormat(options.locale, {\n ...intlOptions,\n ...options.intl,\n timeZone: resolveTimeZone(options.tz),\n });\n const startDate = new Date(asInstant(start, { tz: options.tz }).epochMilliseconds);\n const endDate = new Date(asInstant(end, { tz: options.tz }).epochMilliseconds);\n\n const formatterWithRange = formatter as Intl.DateTimeFormat & {\n formatRange?: (startDate: Date, endDate: Date) => string;\n };\n\n if (typeof formatterWithRange.formatRange === 'function') {\n return formatterWithRange.formatRange(startDate, endDate);\n }\n\n return `${formatter.format(startDate)} - ${formatter.format(endDate)}`;\n}\n\n/**\n * Namespace object for date/time operations.\n * Provides a grouped API similar to Validit's \"v\" pattern.\n *\n * @example\n * ```ts\n * import { d } from '@vielzeug/timit';\n *\n * d.now('UTC')\n * d.asInstant(input, { tz: 'Europe/Berlin' })\n * d.asZoned(instant)\n * d.add(time, { hours: 1 })\n * d.subtract(time, { minutes: 30 })\n * d.diff(start, end)\n * d.within(time, start, end)\n * d.format(time, { pattern: 'short' })\n * d.formatRange(start, end)\n * ```\n */\nexport const d = {\n add,\n asInstant,\n asZoned,\n diff,\n format,\n formatRange,\n now,\n subtract,\n within,\n} as const;\n"],"mappings":";;AA6DA,IAAM,IAAiD;AAEvD,SAAS,EAAgB,GAAqB;AAC5C,QAAO,KAAM,EAAS,IAAI,YAAY;;AAGxC,SAAS,EAAmB,GAAuC;AACjE,KAAI;AACF,SAAO,EAAS,cAAc,KAAK,EAAM;SACnC;AACN,SAAO,EAAS,UAAU,KAAK,EAAM,CAAC,iBAAiB;;;AAI3D,SAAS,EAAqB,GAAqD;AAWjF,QAVK,IAE+D;EAClE,aAAa,EAAE,WAAW,SAAS;EACnC,KAAK;GAAE,WAAW;GAAQ,WAAW;GAAQ;EAC7C,MAAM;GAAE,WAAW;GAAQ,WAAW;GAAQ;EAC9C,OAAO;GAAE,WAAW;GAAS,WAAW;GAAS;EACjD,aAAa,EAAE,WAAW,SAAS;EACpC,CAEe,KAVK;EAAE,WAAW;EAAU,WAAW;EAAS;;AAalE,SAAgB,EAAI,GAAqC;AACvD,QAAO,EAAS,IAAI,iBAAiB,EAAgB,EAAG,CAAC;;AAG3D,SAAgB,EAAU,GAAkB,IAAuB,EAAE,EAAoB;AACvF,KAAI,aAAiB,EAAS,QAC5B,QAAO;AAGT,KAAI,aAAiB,EAAS,cAC5B,QAAO,EAAM,WAAW;AAG1B,KAAI,aAAiB,EAAS,eAAe;EAC3C,IAAM,IAAK,EAAgB,EAAQ,GAAG;AAEtC,SAAO,EACJ,gBAAgB,GAAI,EACnB,gBAAgB,EAAQ,QAAQ,GACjC,CAAC,CACD,WAAW;;AAGhB,KAAI,aAAiB,KACnB,QAAO,EAAS,QAAQ,sBAAsB,EAAM,SAAS,CAAC;AAGhE,KAAI,OAAO,KAAU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9
+ "module": "./dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "source": "./src/index.ts",
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs"
17
+ }
18
+ },
19
+ "scripts": {
20
+ "build": "vite build && pnpm run build:types",
21
+ "build:types": "tsc -p tsconfig.declarations.json",
22
+ "fix": "eslint --fix src",
23
+ "lint": "eslint src",
24
+ "prepublishOnly": "pnpm run build",
25
+ "preview": "vite preview",
26
+ "test": "vitest"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public",
30
+ "registry": "https://registry.npmjs.org/"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^25.5.0",
34
+ "typescript": "~6.0.2",
35
+ "vite": "^8.0.2",
36
+ "vitest": "^4.1.1"
37
+ },
38
+ "dependencies": {
39
+ "@js-temporal/polyfill": "^0.5.1"
40
+ }
41
+ }
42
+