Timezones and Locales
When running Rigs through slipway run
the system timezone and locale are used.
When running Rigs through slipway serve
the user timezone and locale are taken
from the timezone field
and the locale field
of the slipway_serve.json
configuration file, falling back to the system timezone or locale if either is not found.
The timezone is used when evaluating playlists, and is also made available to Components
through the TZ
environment variable within the Component (in other words it is not a host environment variable, which
you would need to access through the Host API).
- In Javascript Components the timezone can be accessed through the
process.env.TZ
field. - In Rust, you would access it through
std::env::var("TZ")
.
For example, in Javascript you could log the current time, taking into account the user's specified timezone, as follows:
const tz = process.env.TZ;
console.log(`Current Date/Time: ${Temporal.Now.plainDateTimeISO(tz).toString()}`);
The locale is also made available to Components
through the LC
and LC_ALL
environment variable within the Component.
Rig Context
In addition to being made available to Components through the TZ
and LC
environment variables, the timezone and locale
are also added to the Rig's context
, and can be accessed by using
the $.context.timezone
or $.context.locale
queries.