time.svelte.ts

Declarations
#

4 declarations

view source

Time
#

time.svelte.ts view source

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

extends:
  • 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.

static

now

Current time that updates on the configured interval. This is reactive and can be used in derived computations.

type SvelteDate

readonly

now_ms

type number

readonly

now_timestamp

readonly

now_formatted_short_date

type string

readonly

now_formatted_datetime

type string

readonly

now_formatted_time

type string

readonly

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

returns boolean

stop

Stops the interval timer if it's running.

type (): boolean

returns boolean

restart

Restarts the interval timer with a new interval.

type (interval?: number | undefined): void

interval?
type number | undefined
optional
returns void

update_now

Updates the now to the current time immediately.

type (value?: number): void

value
type number
default Date.now()
returns void

destroy

Override Cell's destroy method to ensure timer cleanup.

type (): void

returns void

TimeJson
#

time.svelte.ts view source

ZodObject<{ id: ZodDefault<$ZodBranded<ZodUUID, "Uuid">>; created: ZodDefault<$ZodBranded<ZodISODateTime, "Datetime">>; updated: ZodDefault<...>; }, $strict>

TimeJsonInput
#

TimeOptions
#

time.svelte.ts view source

TimeOptions

Options for configuring a Time instance.

inheritance

extends:
  • CellOptions<typeof TimeJson>

interval

Interval in milliseconds for updating now.

type number

autostart

Whether to automatically start the timer on initialization.

type boolean

Depends on
#

Imported by
#