feat: Add support for temporal api#203
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces the Temporal API (via temporal-polyfill) and refactors several date/time code paths to use Temporal.Instant for more consistent time handling across the app.
Changes:
- Add
temporal-polyfilland initialize it on both server (hooks.server.ts) and client (hooks.client.ts), plus global typings (app.d.ts). - Migrate multiple UI/code paths from
DatetoTemporal.Instant(terminal timestamps, hubs created_at fields, OAuth signup expiry parsing). - Add new Temporal utility helpers (
src/lib/utils/temporal.ts) and rewire renderers/components to use them.
Reviewed changes
Copilot reviewed 18 out of 20 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/routes/terminal/types.ts | Switch terminal line timestamps from Date to Temporal.Instant. |
| src/routes/terminal/TerminalContext.svelte.ts | Generate timestamps using Temporal.Now.instant() instead of SvelteDate. |
| src/routes/terminal/SerialTerminal.svelte | Format terminal timestamps using Temporal.Instant. |
| src/routes/(meta)/sitemap.xml/+server.ts | Generate sitemap lastmod using Temporal. |
| src/routes/(app)/shares/public/dialog-publicshare-create.svelte | Convert expiration selection logic to Temporal.Instant and new duration formatting. |
| src/routes/(app)/settings/api-tokens/dialog-token-create.svelte | Convert token expiration selection logic to Temporal.Instant and new duration formatting. |
| src/routes/(app)/hubs/columns.ts | Update hub/shocker created_at types to Temporal.Instant. |
| src/routes/(app)/hubs/+page.svelte | Convert API-provided Date fields to Temporal.Instant for display. |
| src/routes/(app)/hubs/[hubId=guid]/update/+page.svelte | Refactor relative-time formatting to use Temporal computations. |
| src/lib/utils/temporal.ts | Add helper utilities for Instant conversions and duration formatting. |
| src/lib/utils/index.ts | Export new Temporal utilities. |
| src/lib/signalr/handlers/Log.ts | Use Temporal.Instant.from(...) for log timestamp output. |
| src/lib/components/Table/ColumnUtils.ts | Migrate date renderers to Temporal-based formatting helpers. |
| src/lib/api/next/transformers/OAuthSignupData.ts | Parse expiresAt into a Temporal.Instant with validation. |
| src/lib/api/next/models/OAuthSignupData.ts | Update expiresAt type to Temporal.Instant. |
| src/hooks.server.ts | Ensure Temporal polyfill is loaded on the server. |
| src/hooks.client.ts | Ensure Temporal polyfill is loaded before client initialization. |
| src/app.d.ts | Add global Temporal typings reference. |
| package.json | Add temporal-polyfill dependency. |
| pnpm-lock.yaml | Lockfile updates for temporal-polyfill and temporal-spec. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
# Conflicts: # package.json
…al tests
- SerialTerminal formatTime: switch from toLocaleString (locale-dependent
length) to toPlainTime().toString({ smallestUnit: 'second' }) for a
guaranteed fixed-width HH:MM:SS that matches the 8-char column filler.
- sitemap: use Temporal.Now.plainDateISO('UTC') so lastmod is always the
UTC calendar date, consistent with the previous new Date().toISOString()
behaviour.
- dialog-publicshare-create: send null (not undefined) for expiresOn when
no expiry is selected, preserving prior API behaviour where the backend
may distinguish missing vs explicit null.
- Add temporal.test.ts covering durationBetween, formatDuration, and
formatElapsed across unit boundaries, sign handling, and round-trips.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request migrates the codebase from using the built-in JavaScript
Dateobject to the modernTemporalAPI for all date and time handling. It introduces thetemporal-polyfilldependency to ensure compatibility across environments, refactors type definitions, utility functions, and UI components to useTemporal.Instant, and updates expiration logic and formatting throughout the application. This results in more robust, accurate, and maintainable time and date management.