Kantoor.Events.Zone (Kantoor v1.0.0)

Showing and writing event times in the user's time zone.

An event's start is a Kantoor.Dav.Ical moment: a date, or a wall-clock time that is floating, UTC or in a named zone. display/2 turns it into the wall clock the person sees; store/3 turns what they typed back into a moment.

With a user zone: UTC and named-zone times are converted into it (daylight saving included, each instant on its own date); floating times are shown as they are, since they mean "the same clock time wherever you are". With no user zone nothing is converted, as before: the time is shown in the zone it was written in. When a time falls in a gap (spring forward) the first valid moment after the gap is used; in an overlap (fall back) the earlier instant.

Summary

Functions

The wall clock to show for a moment.

The instant of a wall clock in a zone.

Converts a wall clock between two zones (unchanged if either is unknown).

The moment to write for a wall clock typed in the user's zone, given the moment that was stored before (nil for a new event). A new event is written in the user's zone (or default_zone, or floating); an existing one keeps its way of writing time (UTC, named zone, floating).

Types

moment()

@type moment() ::
  {:date, Date.t()}
  | {:naive, NaiveDateTime.t(), :floating | :utc | {:tzid, String.t()}}

Functions

display(arg1, zone)

@spec display(moment() | nil, String.t() | nil) :: NaiveDateTime.t() | nil

The wall clock to show for a moment.

local(naive, zone)

@spec local(NaiveDateTime.t(), String.t()) :: {:ok, DateTime.t()} | :error

The instant of a wall clock in a zone.

shift(naive, from, to)

@spec shift(NaiveDateTime.t(), String.t(), String.t()) :: NaiveDateTime.t()

Converts a wall clock between two zones (unchanged if either is unknown).

store(naive, arg2, user_zone, default_zone)

@spec store(NaiveDateTime.t(), moment() | nil, String.t() | nil, String.t() | nil) ::
  moment()

The moment to write for a wall clock typed in the user's zone, given the moment that was stored before (nil for a new event). A new event is written in the user's zone (or default_zone, or floating); an existing one keeps its way of writing time (UTC, named zone, floating).