gtz
Functions to provide simple timezone support for other Gleam datetime libraries.
Functions
pub fn local_name() -> String
Returns the name of the host system’s timezone.
Examples
gtz.local_name()
// -> "Europe/London"
pub fn timezone(name: String) -> Result(TimeZoneProvider, Nil)
Constructs a TimeZoneProvider type to be used with the Tempo package. Returns an error if the timezone is not valid.
Examples
import tempo/datetime
let assert Ok(tz) = gtz.timezone("America/New_York")
datetime.literal("2024-06-21T06:30:02.334Z")
|> datetime.to_timezone(tz)
|> datetime.to_string
// -> "2024-01-03T02:30:02.334-04:00"