@moltenship/calendar-temporal 1.0.0-rc.1 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/intervals/half-open.d.ts
2
1
  declare const validatedHalfOpenInterval: unique symbol;
3
2
  type HalfOpenIntervalComparator<TPoint> = (left: TPoint, right: TPoint) => number;
4
3
  type HalfOpenInterval<TPoint, TKind extends string> = Readonly<{
@@ -36,8 +35,6 @@ export declare function comparePlainTimes(left: Temporal.PlainTime, right: Tempo
36
35
  export declare function instantInterval(start: Temporal.Instant, end: Temporal.Instant): InstantInterval;
37
36
  export declare function plainDateInterval(start: Temporal.PlainDate, end: Temporal.PlainDate): PlainDateInterval;
38
37
  export declare function plainDateTimeInterval(start: Temporal.PlainDateTime, end: Temporal.PlainDateTime): PlainDateTimeInterval;
39
- //#endregion
40
- //#region src/intervals/operations.d.ts
41
38
  type HalfOpenIntervalSplit<TInterval> = readonly [interval: TInterval] | readonly [before: TInterval, after: TInterval];
42
39
  /** Tests whether an instant belongs to an instant interval using `[start, end)` semantics. */
43
40
  export declare function instantIntervalContains(interval: InstantInterval, instant: Temporal.Instant): boolean;
@@ -60,8 +57,6 @@ export declare function splitInstantInterval(interval: InstantInterval, splitAt:
60
57
  export declare function splitPlainDateInterval(interval: PlainDateInterval, splitAt: Temporal.PlainDate): HalfOpenIntervalSplit<PlainDateInterval>;
61
58
  /** Splits only at an interior date-time; endpoints and out-of-range points preserve the input. */
62
59
  export declare function splitPlainDateTimeInterval(interval: PlainDateTimeInterval, splitAt: Temporal.PlainDateTime): HalfOpenIntervalSplit<PlainDateTimeInterval>;
63
- //#endregion
64
- //#region src/plain-date/iteration.d.ts
65
60
  export declare const DEFAULT_PLAIN_DATE_ITERATION_LIMIT = 10000;
66
61
  interface PlainDateIterationOptions {
67
62
  /** Maximum values produced before rejecting an unexpectedly large traversal. */
@@ -71,8 +66,6 @@ interface PlainDateIterationOptions {
71
66
  }
72
67
  /** Lazily visits dates in a half-open interval and never reads the host timezone. */
73
68
  export declare function iteratePlainDates(range: PlainDateInterval, options?: PlainDateIterationOptions): Generator<Temporal.PlainDate, void, undefined>;
74
- //#endregion
75
- //#region src/grids/calendar-grid.d.ts
76
69
  type WeekStartsOn = 1 | 2 | 3 | 4 | 5 | 6 | 7;
77
70
  interface WeekRangeOptions {
78
71
  /** ISO day number: Monday is 1 and Sunday is 7. */
@@ -94,8 +87,6 @@ interface MonthGrid {
94
87
  export declare function weekRange(date: Temporal.PlainDate, options: WeekRangeOptions): PlainDateInterval;
95
88
  /** Builds a bounded month grid without locale, timezone, or current-time globals. */
96
89
  export declare function monthGrid(date: Temporal.PlainDate, options: MonthGridOptions): MonthGrid;
97
- //#endregion
98
- //#region src/plain-time/rounding.d.ts
99
90
  type PlainTimeRoundingMode = NonNullable<Temporal.RoundingOptions<Temporal.TimeUnit>["roundingMode"]>;
100
91
  type WallTimeSnapMode = "ceil" | "floor" | "nearest";
101
92
  interface PlainTimeRoundingOptions {
@@ -118,8 +109,6 @@ interface SnappedPlainTime {
118
109
  export declare function roundPlainTime(time: Temporal.PlainTime, options: PlainTimeRoundingOptions): Temporal.PlainTime;
119
110
  /** Snaps a wall-clock time to a midnight-anchored grid and reports a carry into the next day. */
120
111
  export declare function snapPlainTime(time: Temporal.PlainTime, options: WallTimeSnapOptions): SnappedPlainTime;
121
- //#endregion
122
- //#region src/instant/iteration.d.ts
123
112
  export declare const DEFAULT_INSTANT_ITERATION_LIMIT = 10000;
124
113
  interface InstantIterationOptions {
125
114
  /** Maximum values produced before rejecting an unexpectedly large traversal. */
@@ -129,8 +118,6 @@ interface InstantIterationOptions {
129
118
  }
130
119
  /** Lazily visits instant grid points in `[start, end)` with an explicit positive step. */
131
120
  export declare function iterateInstants(range: InstantInterval, options: InstantIterationOptions): Generator<Temporal.Instant, void, undefined>;
132
- //#endregion
133
- //#region src/instant/rounding.d.ts
134
121
  type InstantRoundingMode = NonNullable<Temporal.RoundingOptions<Temporal.TimeUnit>["roundingMode"]>;
135
122
  interface InstantRoundingOptions {
136
123
  readonly increment?: number;
@@ -142,15 +129,11 @@ interface InstantRoundingOptions {
142
129
  * Calendar grids are wall-clock grids: use `snapZonedDateTime` for those.
143
130
  */
144
131
  export declare function roundInstant(instant: Temporal.Instant, options: InstantRoundingOptions): Temporal.Instant;
145
- //#endregion
146
- //#region src/clock/calendar-clock.d.ts
147
132
  interface CalendarClock {
148
133
  instant(): Temporal.Instant;
149
134
  }
150
135
  export declare function createFixedClock(instant: Temporal.Instant): CalendarClock;
151
136
  export declare function createSystemClock(): CalendarClock;
152
- //#endregion
153
- //#region src/zoned/machine-keys.d.ts
154
137
  /** Stable absolute identity for maps, caches, and render models. */
155
138
  export declare function instantKey(instant: Temporal.Instant): string;
156
139
  /** Stable calendar-date identity; ISO dates have no calendar annotation. */
@@ -161,8 +144,6 @@ export declare function plainDateTimeKey(dateTime: Temporal.PlainDateTime): stri
161
144
  export declare function zonedDayKey(date: Temporal.PlainDate, timeZone: string): string;
162
145
  /** Stable wall-coordinate identity. It deliberately does not identify a fold occurrence. */
163
146
  export declare function zonedWallTimeKey(dateTime: Temporal.PlainDateTime, timeZone: string): string;
164
- //#endregion
165
- //#region src/zoned/projection.d.ts
166
147
  type TemporalDisambiguation = NonNullable<Temporal.DisambiguationOptions["disambiguation"]>;
167
148
  interface ZonedTimeEnvironment {
168
149
  readonly disambiguation: TemporalDisambiguation;
@@ -223,8 +204,6 @@ interface ZonedInstantProjection {
223
204
  export declare function resolveZonedWallTime(requestedWallTime: Temporal.PlainDateTime, environment: ZonedTimeEnvironment): ZonedWallTimeProjection;
224
205
  /** Projects an absolute instant while retaining the fields needed for stable rendering and editing. */
225
206
  export declare function projectInstantToZonedTime(instant: Temporal.Instant, timeZone: string): ZonedInstantProjection;
226
- //#endregion
227
- //#region src/zoned/rounding.d.ts
228
207
  interface ZonedWallTimeSnapOptions extends WallTimeSnapOptions {
229
208
  /** Occurrence chosen when the snapped wall time is repeated (fall-back). Defaults to `"earlier"`. */
230
209
  readonly fold?: "earlier" | "later";
@@ -245,8 +224,6 @@ export declare function snapZonedDateTime(zonedDateTime: Temporal.ZonedDateTime,
245
224
  * resolves to the transition instant.
246
225
  */
247
226
  export declare function snapZonedWallTime(wallTime: Temporal.PlainDateTime, options: ZonedWallTimeSnapOptions): Temporal.ZonedDateTime;
248
- //#endregion
249
- //#region src/zoned/day.d.ts
250
227
  export declare const DEFAULT_ZONED_DAY_SPLIT_LIMIT = 10000;
251
228
  interface ZonedDayRangeBase {
252
229
  readonly date: Temporal.PlainDate;
@@ -296,8 +273,6 @@ export declare function zonedDayRange(date: Temporal.PlainDate, timeZone: string
296
273
  export declare function zonedDayTransitions(date: Temporal.PlainDate, timeZone: string): readonly ZonedOffsetTransition[];
297
274
  /** Splits an absolute interval at actual zoned-day boundaries without inventing skipped dates. */
298
275
  export declare function splitInstantRangeByZonedDay(range: InstantInterval, timeZone: string, options?: SplitInstantRangeByZonedDayOptions): readonly ZonedDaySplit[];
299
- //#endregion
300
- //#region src/zoned/slots.d.ts
301
276
  export declare const DEFAULT_ZONED_SLOT_LIMIT = 10000;
302
277
  interface ZonedDaySlotsOptions extends ZonedTimeEnvironment {
303
278
  readonly limit?: number;
@@ -341,5 +316,4 @@ interface ZonedDaySlots {
341
316
  * transition inside a configured slot produces explicit sub-segments.
342
317
  */
343
318
  export declare function slotsInZonedDay(date: Temporal.PlainDate, options: ZonedDaySlotsOptions): ZonedDaySlots;
344
- //#endregion
345
319
  export type { AvailableZonedDayRange, CalendarClock, HalfOpenInterval, HalfOpenIntervalComparator, HalfOpenIntervalIssue, HalfOpenIntervalSplit, HalfOpenIntervalValidation, InstantInterval, InstantIterationOptions, InstantRoundingMode, InstantRoundingOptions, MonthGrid, MonthGridOptions, PlainDateInterval, PlainDateIterationOptions, PlainDateTimeInterval, PlainTimeRoundingMode, PlainTimeRoundingOptions, RejectedZonedWallTimeProjection, ResolvedZonedWallTimeProjection, SkippedZonedDayRange, SnappedPlainTime, SplitInstantRangeByZonedDayOptions, TemporalDisambiguation, WallTimeSnapMode, WallTimeSnapOptions, WeekRangeOptions, WeekStartsOn, ZonedDayRange, ZonedDaySlot, ZonedDaySlotOccurrence, ZonedDaySlotSegment, ZonedDaySlots, ZonedDaySlotsOptions, ZonedDaySplit, ZonedInstantProjection, ZonedOffsetTransition, ZonedTimeEnvironment, ZonedWallTimeAdjustment, ZonedWallTimeKind, ZonedWallTimeOccurrence, ZonedWallTimeProjection, ZonedWallTimeSelection, ZonedWallTimeSnapOptions };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/intervals/half-open.ts
1
+ // src/intervals/half-open.ts
2
2
  const validatedHalfOpenInterval = Symbol("validated-half-open-interval");
3
3
  var InvalidHalfOpenIntervalError = class extends RangeError {
4
4
  code = "start-not-before-end";
@@ -55,8 +55,7 @@ function plainDateInterval(start, end) {
55
55
  function plainDateTimeInterval(start, end) {
56
56
  return halfOpenInterval("plain-date-time", start, end, comparePlainDateTimes);
57
57
  }
58
- //#endregion
59
- //#region src/intervals/operations.ts
58
+ // src/intervals/operations.ts
60
59
  function intervalContainsPoint(interval, point, compare) {
61
60
  return compare(interval.start, point) <= 0 && compare(point, interval.end) < 0;
62
61
  }
@@ -126,8 +125,7 @@ function splitPlainDateInterval(interval, splitAt) {
126
125
  function splitPlainDateTimeInterval(interval, splitAt) {
127
126
  return splitInterval(interval, splitAt, comparePlainDateTimes, plainDateTimeInterval);
128
127
  }
129
- //#endregion
130
- //#region src/plain-date/iteration.ts
128
+ // src/plain-date/iteration.ts
131
129
  const DEFAULT_PLAIN_DATE_ITERATION_LIMIT = 1e4;
132
130
  function positiveInteger(value, code) {
133
131
  if (!Number.isSafeInteger(value) || value < 1) throw new RangeError(code);
@@ -147,8 +145,7 @@ function* iteratePlainDates(range, options = {}) {
147
145
  current = current.add({ days: stepDays });
148
146
  }
149
147
  }
150
- //#endregion
151
- //#region src/grids/calendar-grid.ts
148
+ // src/grids/calendar-grid.ts
152
149
  function assertWeekStartsOn(value) {
153
150
  if (!Number.isInteger(value) || value < 1 || value > 7) throw new RangeError("invalid-week-start");
154
151
  }
@@ -184,14 +181,12 @@ function monthGrid(date, options) {
184
181
  weeks: Object.freeze(weeks)
185
182
  });
186
183
  }
187
- //#endregion
188
- //#region src/internal/rounding-increment.ts
184
+ // src/internal/rounding-increment.ts
189
185
  /** Rejects increments that native Temporal would silently truncate, such as `1.5`. */
190
186
  function assertRoundingIncrement(increment, errorCode) {
191
187
  if (!Number.isSafeInteger(increment) || increment < 1) throw new RangeError(errorCode);
192
188
  }
193
- //#endregion
194
- //#region src/plain-time/rounding.ts
189
+ // src/plain-time/rounding.ts
195
190
  function wallTimeRoundingOptions(options, errorCode) {
196
191
  assertRoundingIncrement(options.increment, errorCode);
197
192
  return {
@@ -219,8 +214,7 @@ function snapPlainTime(time, options) {
219
214
  time: snapped.toPlainTime()
220
215
  });
221
216
  }
222
- //#endregion
223
- //#region src/internal/time-duration.ts
217
+ // src/internal/time-duration.ts
224
218
  const NANOSECONDS_PER_HOUR = 3600000000000n;
225
219
  const NANOSECONDS_PER_MINUTE = 60000000000n;
226
220
  const NANOSECONDS_PER_SECOND = 1000000000n;
@@ -236,8 +230,7 @@ function positiveTimeDuration(value, errorCode) {
236
230
  nanoseconds
237
231
  };
238
232
  }
239
- //#endregion
240
- //#region src/instant/iteration.ts
233
+ // src/instant/iteration.ts
241
234
  const DEFAULT_INSTANT_ITERATION_LIMIT = 1e4;
242
235
  function iterationLimit(value) {
243
236
  if (!Number.isSafeInteger(value) || value < 1) throw new RangeError("invalid-instant-iteration-limit");
@@ -258,8 +251,7 @@ function* iterateInstants(range, options) {
258
251
  current = current.add(step.duration);
259
252
  }
260
253
  }
261
- //#endregion
262
- //#region src/instant/rounding.ts
254
+ // src/instant/rounding.ts
263
255
  /**
264
256
  * Rounds an absolute instant on the Unix-epoch grid through the native Temporal operation.
265
257
  * Calendar grids are wall-clock grids: use `snapZonedDateTime` for those.
@@ -273,16 +265,14 @@ function roundInstant(instant, options) {
273
265
  smallestUnit: options.smallestUnit
274
266
  });
275
267
  }
276
- //#endregion
277
- //#region src/clock/calendar-clock.ts
268
+ // src/clock/calendar-clock.ts
278
269
  function createFixedClock(instant) {
279
270
  return Object.freeze({ instant: () => instant });
280
271
  }
281
272
  function createSystemClock() {
282
273
  return Object.freeze({ instant: () => globalThis.Temporal.Now.instant() });
283
274
  }
284
- //#endregion
285
- //#region src/zoned/machine-keys.ts
275
+ // src/zoned/machine-keys.ts
286
276
  /** Stable absolute identity for maps, caches, and render models. */
287
277
  function instantKey(instant) {
288
278
  return `instant:${instant.epochNanoseconds}`;
@@ -317,8 +307,7 @@ function zonedDayKey(date, timeZone) {
317
307
  function zonedWallTimeKey(dateTime, timeZone) {
318
308
  return zonedWallTimeKeyForTimeZoneId(dateTime, timeZoneIdentifier(timeZone));
319
309
  }
320
- //#endregion
321
- //#region src/zoned/projection.ts
310
+ // src/zoned/projection.ts
322
311
  function occurrence(zonedDateTime) {
323
312
  const instant = zonedDateTime.toInstant();
324
313
  return Object.freeze({
@@ -429,8 +418,7 @@ function projectInstantToZonedTime(instant, timeZone) {
429
418
  zonedDateTime
430
419
  });
431
420
  }
432
- //#endregion
433
- //#region src/zoned/rounding.ts
421
+ // src/zoned/rounding.ts
434
422
  const INVALID_INCREMENT = "invalid-zoned-date-time-rounding-increment";
435
423
  /** The transition instant that ends the gap containing `wallTime`: the gap's only real instant. */
436
424
  function gapTransition(wallTime, timeZone) {
@@ -460,8 +448,7 @@ function snapZonedWallTime(wallTime, options) {
460
448
  const resolved = snapped.toZonedDateTime(options.timeZone, { disambiguation: options.fold ?? "earlier" });
461
449
  return resolved.toPlainDateTime().equals(snapped) ? resolved : gapTransition(snapped, options.timeZone);
462
450
  }
463
- //#endregion
464
- //#region src/zoned/day.ts
451
+ // src/zoned/day.ts
465
452
  const DEFAULT_ZONED_DAY_SPLIT_LIMIT = 1e4;
466
453
  const MINIMUM_INSTANT_NANOSECONDS = -8640000000000000000000n;
467
454
  const MAXIMUM_INSTANT_NANOSECONDS = 8640000000000000000000n;
@@ -570,8 +557,7 @@ function splitInstantRangeByZonedDay(range, timeZone, options = {}) {
570
557
  }
571
558
  return Object.freeze(splits);
572
559
  }
573
- //#endregion
574
- //#region src/zoned/slots.ts
560
+ // src/zoned/slots.ts
575
561
  const NOMINAL_DAY_NANOSECONDS = 86400000000000n;
576
562
  const DEFAULT_ZONED_SLOT_LIMIT = 1e4;
577
563
  function carryoverOccurrence(start, end, timeZone) {
@@ -675,5 +661,4 @@ function slotsInZonedDay(date, options) {
675
661
  transitions
676
662
  });
677
663
  }
678
- //#endregion
679
664
  export { DEFAULT_INSTANT_ITERATION_LIMIT, DEFAULT_PLAIN_DATE_ITERATION_LIMIT, DEFAULT_ZONED_DAY_SPLIT_LIMIT, DEFAULT_ZONED_SLOT_LIMIT, InvalidHalfOpenIntervalError, compareInstants, comparePlainDateTimes, comparePlainDates, comparePlainTimes, createFixedClock, createSystemClock, halfOpenInterval, instantInterval, instantIntervalContains, instantIntervalContainsInterval, instantIntervalsIntersect, instantKey, intersectInstantIntervals, intersectPlainDateIntervals, intersectPlainDateTimeIntervals, iterateInstants, iteratePlainDates, monthGrid, plainDateInterval, plainDateIntervalContains, plainDateIntervalContainsInterval, plainDateIntervalsIntersect, plainDateKey, plainDateTimeInterval, plainDateTimeIntervalContains, plainDateTimeIntervalContainsInterval, plainDateTimeIntervalsIntersect, plainDateTimeKey, projectInstantToZonedTime, resolveZonedWallTime, roundInstant, roundPlainTime, slotsInZonedDay, snapPlainTime, snapZonedDateTime, snapZonedWallTime, splitInstantInterval, splitInstantRangeByZonedDay, splitPlainDateInterval, splitPlainDateTimeInterval, validateHalfOpenInterval, weekRange, zonedDayKey, zonedDayRange, zonedDayTransitions, zonedWallTimeKey };
package/package.json CHANGED
@@ -1,7 +1,19 @@
1
1
  {
2
2
  "name": "@moltenship/calendar-temporal",
3
- "version": "1.0.0-rc.1",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Framework-independent Temporal utilities for Moltenship Time.",
5
+ "keywords": [
6
+ "calendar",
7
+ "date",
8
+ "date-range",
9
+ "dst",
10
+ "framework-agnostic",
11
+ "temporal",
12
+ "temporal-api",
13
+ "time",
14
+ "timezone",
15
+ "typescript"
16
+ ],
5
17
  "homepage": "https://time.molten.sh/docs/api/temporal",
6
18
  "bugs": {
7
19
  "url": "https://github.com/Moltenship/time/issues"
@@ -30,12 +42,11 @@
30
42
  "devDependencies": {
31
43
  "fast-check": "^4.10.2",
32
44
  "typescript": "^7.0.2",
33
- "vite": "npm:@voidzero-dev/vite-plus-core@1.1.0",
34
- "vite-plus": "1.1.0"
45
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
46
+ "vite-plus": "1.4.0"
35
47
  },
36
48
  "scripts": {
37
49
  "build": "vp pack",
38
- "check": "vp check",
39
50
  "dev": "vp pack --watch",
40
51
  "test": "vp test --passWithNoTests"
41
52
  }