Reactive time management class that provides time-related utilities. Has a configurable update interval that defaults to a full minute to minimize wasteful reactivity, so it's suitable for any cases that need at best 1-minute precision, unless reconfigured.
inheritance
Cell<typeof TimeJson>
DEFAULT_INTERVAL
Default update interval in milliseconds (1 minute). The idea is to minimize reactivity and CPU usage for a common use case.
now
Current time that updates on the configured interval. This is reactive and can be used in derived computations.
type SvelteDate
now_ms
type number
now_timestamp
now_formatted_short_date
type string
now_formatted_datetime
type string
now_formatted_time
type string
interval
The interval in milliseconds between time updates.
type number
running
Whether the interval timer is currently running.
type boolean
constructor
type new (options: TimeOptions): Time
options
start
Starts the interval timer if it's not already running.
type (): boolean
booleanstop
Stops the interval timer if it's running.
type (): boolean
booleanrestart
Restarts the interval timer with a new interval.
type (interval?: number | undefined): void
interval?
number | undefinedvoidupdate_now
Updates the now to the current time immediately.
type (value?: number): void
value
numberDate.now()voiddestroy
Override Cell's destroy method to ensure timer cleanup.
type (): void
void