@charlite/react-temporal 0.0.0-stage → 1.1.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/LICENSE +21 -0
  3. package/README.md +178 -2
  4. package/dist/hooks/useTemporalAdd.d.ts +7 -0
  5. package/dist/hooks/useTemporalCalendar.d.ts +4 -0
  6. package/dist/hooks/useTemporalClock.d.ts +5 -0
  7. package/dist/hooks/useTemporalCompare.d.ts +7 -0
  8. package/dist/hooks/useTemporalCountdown.d.ts +5 -0
  9. package/dist/hooks/useTemporalCountdownStatus.d.ts +11 -0
  10. package/dist/hooks/useTemporalDiff.d.ts +5 -0
  11. package/dist/hooks/useTemporalDuration.d.ts +5 -0
  12. package/dist/hooks/useTemporalElapsed.d.ts +5 -0
  13. package/dist/hooks/useTemporalFormat.d.ts +7 -0
  14. package/dist/hooks/useTemporalFrom.d.ts +5 -0
  15. package/dist/hooks/useTemporalInterval.d.ts +6 -0
  16. package/dist/hooks/useTemporalLocalDate.d.ts +5 -0
  17. package/dist/hooks/useTemporalMonth.d.ts +5 -0
  18. package/dist/hooks/useTemporalNow.d.ts +6 -0
  19. package/dist/hooks/useTemporalParse.d.ts +3 -0
  20. package/dist/hooks/useTemporalRange.d.ts +5 -0
  21. package/dist/hooks/useTemporalRelative.d.ts +6 -0
  22. package/dist/hooks/useTemporalSafeParse.d.ts +5 -0
  23. package/dist/hooks/useTemporalSchedule.d.ts +9 -0
  24. package/dist/hooks/useTemporalStopwatch.d.ts +11 -0
  25. package/dist/hooks/useTemporalTimeZone.d.ts +4 -0
  26. package/dist/hooks/useTemporalWeek.d.ts +5 -0
  27. package/dist/hooks/useTemporalWithin.d.ts +5 -0
  28. package/dist/hooks/useTemporalYear.d.ts +5 -0
  29. package/dist/hooks/useTemporalZonedNow.d.ts +6 -0
  30. package/dist/index.cjs +507 -0
  31. package/dist/index.cjs.map +1 -0
  32. package/dist/index.d.ts +29 -0
  33. package/dist/index.esm.js +477 -0
  34. package/dist/index.esm.js.map +1 -0
  35. package/dist/internal/durationKey.d.ts +5 -0
  36. package/dist/internal/useLatest.d.ts +2 -0
  37. package/dist/internal/useTemporalTicker.d.ts +11 -0
  38. package/dist/temporal.d.ts +20 -0
  39. package/dist/types.d.ts +35 -0
  40. package/dist/utils/formatRelative.d.ts +6 -0
  41. package/dist/utils/parseTemporal.d.ts +2 -0
  42. package/docs/README.md +53 -0
  43. package/docs/api-reference.md +331 -0
  44. package/docs/getting-started.md +111 -0
  45. package/docs/installation.md +87 -0
  46. package/docs/migration.md +143 -0
  47. package/docs/polyfill.md +89 -0
  48. package/docs/typescript.md +86 -0
  49. package/package.json +117 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,94 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.1.0] - 2026-10-08
9
+
10
+ ### Added
11
+
12
+ - `hasNativeTemporal()` runtime probe.
13
+ - Hooks: `useTemporalFrom`, `useTemporalSafeParse`, `useTemporalElapsed`, `useTemporalStopwatch`, `useTemporalLocalDate`, `useTemporalCompare`, `useTemporalWithin`, `useTemporalAdd`, `useTemporalCountdownStatus`.
14
+ - `pauseWhenHidden` option on live clock hooks (battery-friendly tab background behavior).
15
+ - `onComplete` / `intervalMs` options on `useTemporalCountdown`.
16
+ - `runIfPast` option on `useTemporalSchedule`.
17
+
18
+ ### Changed
19
+
20
+ - Default polyfill fallback is **`temporal-polyfill`** (smaller, spec-current) instead of `@js-temporal/polyfill` (`@js-temporal/polyfill` remains an optional peer for apps that prefer it).
21
+ - TypeScript types sourced from `temporal-polyfill`.
22
+ - Clock hooks share `useTemporalTicker`; interval hooks use stable duration dependency keys.
23
+ - `useTemporalRelative` unit selection prefers the finest unit with magnitude ≥ 1 (e.g. 90 minutes, not 2 hours).
24
+ - `useTemporalSchedule` runs immediately when the target instant is already past (configurable).
25
+
26
+ ## [1.0.0] - 2026-10-08
27
+
28
+ ### Added
29
+
30
+ - [Open Knowledge Format (OKF) v0.2](https://github.com/GoogleCloudPlatform/open-knowledge-format) bundle in `knowledge/` for agent-friendly project context.
31
+ - `AGENTS.md` entry point linking OKF concepts, docs, and tooling.
32
+ - `.nvmrc` targeting Node.js 26.
33
+
34
+ ### Changed
35
+
36
+ - **BREAKING**: Minimum Node.js version raised to **26** (`engines` field).
37
+ - Replaced **Jest** with **Vitest** (`vitest.config.ts`, `vitest.setup.ts`).
38
+ - Migrated to **ESLint 10** flat config (`eslint.config.js`).
39
+ - Documentation updated for Node.js 26 native Temporal, Vitest, and OKF.
40
+
41
+ ## [0.0.3] - 2026-07-05
42
+
43
+ ### Added
44
+
45
+ - Native Temporal support: uses `globalThis.Temporal` when available (Chrome 144+, Firefox 139+, Edge 144+), with automatic polyfill fallback.
46
+ - `getTemporal()` utility and re-exported `Temporal` namespace from the package.
47
+ - `useTemporalClock` — configurable-interval live clock hook.
48
+ - `useTemporalZonedNow` — live `ZonedDateTime` for any IANA time zone.
49
+ - `useTemporalNow` options: `intervalMs` and `timeZone`.
50
+ - TypeScript type exports (`TemporalInstant`, `TemporalPlainDate`, `UseTemporalNowOptions`, etc.).
51
+ - `Intl.RelativeTimeFormat` in `useTemporalRelative` for locale-aware output ("in 3 hours", "2 days ago").
52
+ - `useTemporalFormat` now uses Temporal's native `toLocaleString` and accepts any formattable Temporal type.
53
+ - Full documentation in the `docs/` folder.
54
+ - Documentation for 2026 Temporal adoption, browser support, and polyfill setup.
55
+
56
+ ### Changed
57
+
58
+ - `react` and `react-dom` are peer dependencies only (no longer direct dependencies).
59
+ - Polyfill is no longer bundled — externalized via Rollup; install `@js-temporal/polyfill` or `temporal-polyfill` for non-native environments.
60
+ - `useTemporalDuration` and `useTemporalDiff` now use `until()` instead of manual epoch arithmetic.
61
+ - `useTemporalRelative` output format changed to `Intl.RelativeTimeFormat` strings.
62
+ - `useTemporalFormat` signature now accepts `(obj, locales?, options?)` instead of `(obj, options?)`.
63
+ - Minimum Node.js version raised to 22.
64
+ - Peer dependencies expanded to React 17, 18, and 19.
65
+ - CI updated to Node.js 22.
66
+ - Migrated tests from deprecated `@testing-library/react-hooks` to `@testing-library/react`.
67
+
68
+ ### Fixed
69
+
70
+ - `useTemporalCountdown` uses `until().total('seconds')` for correct remaining time.
71
+ - `useTemporalSchedule` uses a ref for the callback to avoid stale closures.
72
+
73
+ ## [0.0.2] - 2025-07-23
74
+
75
+ ### Changed
76
+
77
+ - `react` and `react-dom` accept `^17.0.0` versions instead of exact `17.0.0`.
78
+
79
+ ## [0.0.1] - 2025-07-21
80
+
81
+ ### Added
82
+
83
+ - Initial release of `react-temporal`.
84
+ - 15 custom React hooks for date and time management using the JavaScript Temporal API.
85
+ - Example usage files for every hook in `examples/`.
86
+ - Comprehensive test suite for all hooks in `src/__tests__/`.
87
+ - Documentation and usage instructions in `README.md`.
88
+ - Semantic versioning and changelog support.
89
+
90
+ [1.1.0]: https://github.com/charlite/react-temporal/compare/v1.0.0...v1.1.0
91
+ [1.0.0]: https://github.com/charlite/react-temporal/compare/v0.0.3...v1.0.0
92
+ [0.0.3]: https://github.com/charlite/react-temporal/compare/v0.0.2...v0.0.3
93
+ [0.0.2]: https://github.com/charlite/react-temporal/compare/v0.0.1...v0.0.2
94
+ [0.0.1]: https://github.com/charlite/react-temporal/releases/tag/v0.0.1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Charlie Rios
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,179 @@
1
- # Temporary Holding Version
1
+ # react-temporal
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm version](https://badge.fury.io/js/react-temporal.svg)](https://www.npmjs.com/package/@xarlizard/react-temporal)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
6
+ [![CI](https://github.com/charlite/react-temporal/actions/workflows/ci.yml/badge.svg)](https://github.com/charlite/react-temporal/actions/workflows/ci.yml)
7
+
8
+ **react-temporal** is a React hooks library for date and time, built on the JavaScript [Temporal API](https://tc39.es/proposal-temporal/). Temporal reached **Stage 4** in 2026 and ships natively in Chrome 144+, Firefox 139+, Edge 144+, and **Node.js 26+**. This library uses native Temporal when available and falls back to a polyfill for Safari, older browsers, and test environments.
9
+
10
+ Replace `Date`, Moment.js, and most `date-fns` use cases with immutable, time-zone-aware Temporal types — wrapped in idiomatic React hooks.
11
+
12
+ 📖 **[Full documentation](./docs/README.md)** — getting started, API reference, polyfill guide, and TypeScript types.
13
+
14
+ 🤖 **[Agent guide (OKF v0.2)](./AGENTS.md)** — machine-readable knowledge in [`knowledge/`](./knowledge/index.md).
15
+
16
+ ---
17
+
18
+ ## Why Temporal in 2026?
19
+
20
+ | | Legacy `Date` | Temporal |
21
+ | --- | --- | --- |
22
+ | Immutability | Mutable | Immutable value objects |
23
+ | Time zones | Error-prone offsets | First-class `ZonedDateTime` |
24
+ | Arithmetic | Millisecond hacks | `add`, `subtract`, `until`, `since` |
25
+ | Parsing | Implementation-defined | Strict ISO 8601 |
26
+ | Browser support | Everywhere | Chrome 144+, Firefox 139+, Edge 144+ |
27
+ | Node.js | Legacy APIs | **26+** native Temporal (polyfill optional) |
28
+
29
+ ---
30
+
31
+ ## Install
32
+
33
+ ```bash
34
+ npm install react-temporal
35
+ ```
36
+
37
+ ### Polyfill (Safari, older browsers, Node < 26)
38
+
39
+ Native Temporal is used automatically when available. For environments without it, install one polyfill:
40
+
41
+ ```bash
42
+ # Smaller production polyfill (~20 KB gzip) — recommended
43
+ npm install temporal-polyfill
44
+
45
+ # Official reference implementation (~44 KB gzip)
46
+ npm install @js-temporal/polyfill
47
+ ```
48
+
49
+ For `temporal-polyfill`, add this once at your app entry point:
50
+
51
+ ```ts
52
+ import 'temporal-polyfill/global';
53
+ ```
54
+
55
+ `temporal-polyfill` is installed automatically as an optional dependency and used as the fallback when native Temporal is unavailable (`@js-temporal/polyfill` remains supported as an optional peer if you install it yourself).
56
+
57
+ ---
58
+
59
+ ## Usage
60
+
61
+ All hooks are named exports. Import `Temporal` from the package or from your polyfill:
62
+
63
+ ```tsx
64
+ import { useTemporalNow, useTemporalZonedNow, Temporal } from 'react-temporal';
65
+
66
+ function Clock() {
67
+ const now = useTemporalNow();
68
+ const tokyo = useTemporalZonedNow('Asia/Tokyo');
69
+
70
+ return (
71
+ <div>
72
+ <p>UTC: {now.toString()}</p>
73
+ <p>Tokyo: {tokyo.toLocaleString()}</p>
74
+ </div>
75
+ );
76
+ }
77
+ ```
78
+
79
+ ### Configurable clock
80
+
81
+ ```tsx
82
+ import { useTemporalNow, useTemporalClock } from 'react-temporal';
83
+
84
+ // Update every 100 ms for a smooth timer UI
85
+ const now = useTemporalClock({ intervalMs: 100 });
86
+
87
+ // Or get zoned time with a custom interval
88
+ const local = useTemporalNow({ timeZone: 'Europe/Madrid', intervalMs: 5000 });
89
+ ```
90
+
91
+ ---
92
+
93
+ ## Hooks
94
+
95
+ | Hook | Description |
96
+ | --- | --- |
97
+ | `useTemporalNow` | Current `Instant` or `ZonedDateTime` (with `timeZone` option), auto-updating |
98
+ | `useTemporalClock` | Current `Instant` with configurable tick interval |
99
+ | `useTemporalZonedNow` | Current `ZonedDateTime` for an IANA time zone |
100
+ | `useTemporalInterval` | Run a callback on a `Duration` interval |
101
+ | `useTemporalDuration` | `Duration` between two instants (`start.until(end)`) |
102
+ | `useTemporalCalendar` | Validate and return a calendar ID |
103
+ | `useTemporalTimeZone` | Validate and return a time zone ID |
104
+ | `useTemporalFormat` | Locale-aware formatting via `toLocaleString` |
105
+ | `useTemporalRange` | Inclusive array of `PlainDate` between two dates |
106
+ | `useTemporalRelative` | Relative time via `Intl.RelativeTimeFormat` ("in 3 hours") |
107
+ | `useTemporalCountdown` | Seconds remaining until a target instant |
108
+ | `useTemporalSchedule` | `setTimeout` aligned to a target instant |
109
+ | `useTemporalParse` | Parse an ISO string to `Instant` |
110
+ | `useTemporalDiff` | `Duration` difference between two instants |
111
+ | `useTemporalWeek` | All dates in the ISO week (Mon–Sun) |
112
+ | `useTemporalMonth` | All dates in a month |
113
+ | `useTemporalYear` | First day of each month in a year |
114
+ | `useTemporalFrom` | Parse ISO strings into any Temporal type |
115
+ | `useTemporalSafeParse` | Non-throwing parse (`{ value, error }`) |
116
+ | `useTemporalElapsed` | Seconds since an instant (live) |
117
+ | `useTemporalStopwatch` | Live `{ elapsed, seconds }` from a start instant |
118
+ | `useTemporalLocalDate` | Today's `PlainDate` in a time zone |
119
+ | `useTemporalCompare` | Memoized `Temporal.*.compare` |
120
+ | `useTemporalWithin` | Inclusive range check for instants or dates |
121
+ | `useTemporalAdd` | Memoized `.add(duration)` |
122
+ | `useTemporalCountdownStatus` | `{ seconds, isComplete }` countdown |
123
+
124
+ See [`examples/`](examples/README.md) for copy-paste examples, or the [`docs/`](docs/README.md) folder for full documentation.
125
+
126
+ ---
127
+
128
+ ## Utilities
129
+
130
+ | Export | Description |
131
+ | --- | --- |
132
+ | `Temporal` | The Temporal namespace (native or polyfill) |
133
+ | `getTemporal()` | Explicit resolver — native first, polyfill fallback |
134
+ | `hasNativeTemporal()` | Whether `globalThis.Temporal` is available |
135
+
136
+ ---
137
+
138
+ ## TypeScript
139
+
140
+ Full type exports are included. Types are sourced from `temporal-polyfill` and work with native Temporal at runtime:
141
+
142
+ ```ts
143
+ import type { TemporalInstant, TemporalPlainDate, UseTemporalNowOptions } from 'react-temporal';
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Testing
149
+
150
+ ```bash
151
+ npm test
152
+ ```
153
+
154
+ Unit tests use **Vitest** and live in [`src/__tests__/`](src/__tests__/).
155
+
156
+ ---
157
+
158
+ ## Development
159
+
160
+ ```bash
161
+ git clone https://github.com/charlite/react-temporal.git
162
+ cd react-temporal
163
+ nvm use 26 # requires Node.js 26+
164
+ npm install
165
+ npm test
166
+ npm run build
167
+ ```
168
+
169
+ ---
170
+
171
+ ## Contributing
172
+
173
+ Contributions are welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md) and the [OKF knowledge bundle](./knowledge/index.md) for agent-oriented context.
174
+
175
+ ---
176
+
177
+ ## License
178
+
179
+ MIT © [charlite](https://github.com/charlite)
@@ -0,0 +1,7 @@
1
+ import type { TemporalDurationLike, TemporalInstant, TemporalPlainDate } from '../types';
2
+ type Addable = TemporalInstant | TemporalPlainDate;
3
+ /**
4
+ * Memoized `temporal.add(duration)` for PlainDate or Instant values.
5
+ */
6
+ export declare function useTemporalAdd<T extends Addable>(value: T, duration: TemporalDurationLike): T;
7
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Validates and returns the calendar ID for a given calendar name.
3
+ */
4
+ export declare function useTemporalCalendar(id: string): string;
@@ -0,0 +1,5 @@
1
+ import type { UseTemporalClockOptions, TemporalInstant } from '../types';
2
+ /**
3
+ * Returns the current Temporal.Instant, updating at a configurable interval.
4
+ */
5
+ export declare function useTemporalClock(options?: UseTemporalClockOptions): TemporalInstant;
@@ -0,0 +1,7 @@
1
+ import type { TemporalInstant, TemporalPlainDate } from '../types';
2
+ type Comparable = TemporalInstant | TemporalPlainDate;
3
+ /**
4
+ * Memoized Temporal compare result: negative if `a` is before `b`, positive if after, 0 if equal.
5
+ */
6
+ export declare function useTemporalCompare(a: Comparable, b: Comparable): number;
7
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { TemporalInstant, UseTemporalCountdownOptions } from '../types';
2
+ /**
3
+ * Returns the remaining seconds until a target Temporal.Instant.
4
+ */
5
+ export declare function useTemporalCountdown(target: TemporalInstant, options?: UseTemporalCountdownOptions): number;
@@ -0,0 +1,11 @@
1
+ import type { TemporalInstant, UseTemporalCountdownOptions } from '../types';
2
+ export interface TemporalCountdownStatus {
3
+ /** Whole seconds remaining (0 when complete). */
4
+ seconds: number;
5
+ /** True when the target instant has been reached or passed. */
6
+ isComplete: boolean;
7
+ }
8
+ /**
9
+ * Countdown with structured status (seconds + completion flag).
10
+ */
11
+ export declare function useTemporalCountdownStatus(target: TemporalInstant, options?: UseTemporalCountdownOptions): TemporalCountdownStatus;
@@ -0,0 +1,5 @@
1
+ import type { TemporalInstant } from '../types';
2
+ /**
3
+ * Returns the difference between two instants as a Temporal.Duration.
4
+ */
5
+ export declare function useTemporalDiff(a: TemporalInstant, b: TemporalInstant): import("temporal-spec").Temporal.Duration;
@@ -0,0 +1,5 @@
1
+ import type { TemporalInstant } from '../types';
2
+ /**
3
+ * Returns a Temporal.Duration between two instants.
4
+ */
5
+ export declare function useTemporalDuration(start: TemporalInstant, end: TemporalInstant): import("temporal-spec").Temporal.Duration;
@@ -0,0 +1,5 @@
1
+ import type { TemporalInstant, UseTemporalClockOptions } from '../types';
2
+ /**
3
+ * Returns elapsed whole seconds since a past `Temporal.Instant` (0 if the instant is in the future).
4
+ */
5
+ export declare function useTemporalElapsed(since: TemporalInstant, options?: UseTemporalClockOptions): number;
@@ -0,0 +1,7 @@
1
+ import type { TemporalInstant, TemporalPlainDate, TemporalPlainTime, TemporalPlainDateTime, TemporalZonedDateTime } from '../types';
2
+ type FormattableTemporal = TemporalInstant | TemporalPlainDate | TemporalPlainTime | TemporalPlainDateTime | TemporalZonedDateTime;
3
+ /**
4
+ * Formats a Temporal object using Intl via Temporal's toLocaleString.
5
+ */
6
+ export declare function useTemporalFormat(temporalObj: FormattableTemporal, locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
7
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { TemporalParseKind, TemporalParsedValue } from '../types';
2
+ /**
3
+ * Parses an ISO string into the requested Temporal type (memoized on `input`).
4
+ */
5
+ export declare function useTemporalFrom<K extends TemporalParseKind>(kind: K, input: string): TemporalParsedValue<K>;
@@ -0,0 +1,6 @@
1
+ import type { TemporalDurationLike } from '../types';
2
+ /**
3
+ * Runs a callback at a given Temporal.Duration interval.
4
+ * Duration values are normalized for stable effect dependencies.
5
+ */
6
+ export declare function useTemporalInterval(callback: () => void, duration: TemporalDurationLike): void;
@@ -0,0 +1,5 @@
1
+ import type { TemporalPlainDate, UseTemporalClockOptions } from '../types';
2
+ /**
3
+ * Returns today's calendar date in the given IANA time zone, updating across midnight.
4
+ */
5
+ export declare function useTemporalLocalDate(timeZone: string, options?: UseTemporalClockOptions): TemporalPlainDate;
@@ -0,0 +1,5 @@
1
+ import type { TemporalPlainDate } from '../types';
2
+ /**
3
+ * Returns all dates in the month of a given Temporal.PlainDate.
4
+ */
5
+ export declare function useTemporalMonth(date: TemporalPlainDate): import("temporal-spec").Temporal.PlainDate[];
@@ -0,0 +1,6 @@
1
+ import type { UseTemporalNowOptions, TemporalInstant, TemporalZonedDateTime } from '../types';
2
+ /**
3
+ * Returns the current time as a Temporal.Instant (or ZonedDateTime when timeZone is set),
4
+ * updating at the configured interval.
5
+ */
6
+ export declare function useTemporalNow(options?: UseTemporalNowOptions): TemporalInstant | TemporalZonedDateTime;
@@ -0,0 +1,3 @@
1
+ import type { TemporalInstant } from '../types';
2
+ /** Parses an ISO string to Temporal.Instant. */
3
+ export declare function useTemporalParse(isoString: string): TemporalInstant;
@@ -0,0 +1,5 @@
1
+ import type { TemporalPlainDate } from '../types';
2
+ /**
3
+ * Returns an array of Temporal.PlainDate between start and end (inclusive).
4
+ */
5
+ export declare function useTemporalRange(start: TemporalPlainDate, end: TemporalPlainDate): import("temporal-spec").Temporal.PlainDate[];
@@ -0,0 +1,6 @@
1
+ import type { TemporalInstant } from '../types';
2
+ /**
3
+ * Returns a locale-aware relative time string between two instants
4
+ * (e.g. "in 3 hours", "2 days ago") using Intl.RelativeTimeFormat.
5
+ */
6
+ export declare function useTemporalRelative(from: TemporalInstant, to: TemporalInstant, locales?: string | string[], options?: Intl.RelativeTimeFormatOptions): string;
@@ -0,0 +1,5 @@
1
+ import type { TemporalParseKind, TemporalParsedValue, TemporalSafeParseResult } from '../types';
2
+ /**
3
+ * Like `useTemporalFrom`, but returns `{ value, error }` instead of throwing.
4
+ */
5
+ export declare function useTemporalSafeParse<K extends TemporalParseKind>(kind: K, input: string): TemporalSafeParseResult<TemporalParsedValue<K>>;
@@ -0,0 +1,9 @@
1
+ import type { TemporalInstant } from '../types';
2
+ export interface UseTemporalScheduleOptions {
3
+ /** When true (default), run immediately if the instant is already in the past. */
4
+ runIfPast?: boolean;
5
+ }
6
+ /**
7
+ * Schedules a callback to run at a specific Temporal.Instant.
8
+ */
9
+ export declare function useTemporalSchedule(callback: () => void, instant: TemporalInstant, options?: UseTemporalScheduleOptions): void;
@@ -0,0 +1,11 @@
1
+ import type { TemporalDuration, TemporalInstant, UseTemporalClockOptions } from '../types';
2
+ export interface UseTemporalStopwatchResult {
3
+ /** Elapsed time from `start` until now. */
4
+ elapsed: TemporalDuration;
5
+ /** Whole seconds elapsed (floor). */
6
+ seconds: number;
7
+ }
8
+ /**
9
+ * Live stopwatch from a fixed start instant, updating on an interval.
10
+ */
11
+ export declare function useTemporalStopwatch(start: TemporalInstant, options?: UseTemporalClockOptions): UseTemporalStopwatchResult;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Validates and returns the time zone ID for a given IANA time zone name.
3
+ */
4
+ export declare function useTemporalTimeZone(id: string): string;
@@ -0,0 +1,5 @@
1
+ import type { TemporalPlainDate } from '../types';
2
+ /**
3
+ * Returns all dates in the ISO week (Monday–Sunday) containing the given PlainDate.
4
+ */
5
+ export declare function useTemporalWeek(date: TemporalPlainDate): import("temporal-spec").Temporal.PlainDate[];
@@ -0,0 +1,5 @@
1
+ import type { TemporalInstant, TemporalPlainDate } from '../types';
2
+ /**
3
+ * True when `value` is inclusively between `start` and `end`.
4
+ */
5
+ export declare function useTemporalWithin(value: TemporalInstant | TemporalPlainDate, start: TemporalInstant | TemporalPlainDate, end: TemporalInstant | TemporalPlainDate): boolean;
@@ -0,0 +1,5 @@
1
+ import type { TemporalPlainDate } from '../types';
2
+ /**
3
+ * Returns the first day of each month in the year of a given Temporal.PlainDate.
4
+ */
5
+ export declare function useTemporalYear(date: TemporalPlainDate): import("temporal-spec").Temporal.PlainDate[];
@@ -0,0 +1,6 @@
1
+ import type { UseTemporalClockOptions, TemporalZonedDateTime } from '../types';
2
+ /**
3
+ * Returns the current Temporal.ZonedDateTime for the given IANA time zone,
4
+ * updating at a configurable interval.
5
+ */
6
+ export declare function useTemporalZonedNow(timeZone: string, options?: UseTemporalClockOptions): TemporalZonedDateTime;