Documents v0.10.0 · previews run the real runtime · experimental features are marked exp

time()

functionsince 0.10experimentalrequires runtime

The current instant, a datetime value. In CSS it is its epoch milliseconds. It is a value, not a timer.

On this page · 8 sections+

Syntax

time()

Parameters

None.

Return value

A datetime.

Example

resend.cssreactive
.resend { --until: state(time()); --now: state(time()); --waiting: state(false); }.resend button:on(click) { --waiting: set(true); --until: set(time() + 30s); --now: set(time()); }.resend:when(--waiting):on(every(250ms)) { --now: set(time()); }.resend:when(--waiting):on(after(30s)) { --waiting: set(false); }.resend .left { text: format(max(0, round(up, (--until - --now) / 1s)), "integer"); }
state()Function · hover any red tokenMakes each matching element the owner of an independent state with an initial value.Reference →

Behavior

  • Every time() in one task gives the same instant.
  • --x: state(time()) makes a datetime state.
  • A datetime ± a duration (30s, 500ms) is a datetime, in the same zone. A datetime − a datetime is a duration in ms. Anything else is an error: a plain number is never a time.
  • It compares with a datetime or with a number of epoch milliseconds, by instant.

Supported contexts

  • :on() actions: set(lower(event(value))).
  • :when() and when() conditions: :when(includes(--a, --b)).
  • Declarations, including text:: text: length(trim(--value)).
  • state(time()).

Limitations

  • A declaration or condition with time() is evaluated when its states change, not as time passes. Use every() or live() to follow the clock.
Experimental · syntax may change between minor versions