index ↓

time

client.time

Wall clock, locale, and timezone for a webapp. The connected phone supplies all three. get returns them on demand and onChanged reports every later update.

requests

you ask, the daemon answers. await the tagged result and check .ok

get(): Promise<TypedRequestResult<TimeSnapshot, never>>

push form: onSnapshot (subscribe instead of awaiting)

Returns the current wall clock, locale, and timezone.

const res = await client.time.get();
if (res.ok) {
  console.log(res.response.time);
}

events

the daemon pushes these unprompted. subscribing returns an unsubscribe function

onChanged(handler: (TimeSnapshot) => void): () => void

const off = client.time.onChanged((snapshot) => {
  console.log(snapshot.time);
});
// call off() to unsubscribe

types

shapes referenced above, as the sdk types them

type TimeSnapshot = {
  time: TimeInfo;
};

The device has no battery-backed clock, so the phone is the time authority. Read the zone from tzIana; when it is null, use utcOffsetMinutes plus dstOffsetMinutes.

type TimeInfo = {
  tzIana?: string; // IANA zone identifier, for example `America/Denver`.
  locale?: string;
  wallClockUnixS?: number;
  utcOffsetMinutes?: number;
  dstOffsetMinutes?: number;
};