Module Timmy_jsoo.Timezone

include module type of Timmy.Timezone

Type

A timezone.

Construction

val of_gmt_offset_seconds : int -> t

of_gmt_offset_seconds s is a timezone with a fixed offset of s seconds from UTC. In other words, localtime = UTC + offset.

val of_implementation : offset_calendar_time_s: (date:(int * int * int) -> time:(int * int * int) -> int) -> offset_timestamp_s:(unix_timestamp:Stdlib.Int64.t -> int) -> string -> t

of_implementation ~offset_calendar_time_s ~offset_timestamp_s builds a timezone by providing an implementation of the offset computation from both a date and a timestamp (in seconds).

val utc : t

utc is the UTC timezone.

Usage

val gmt_offset_seconds_at_datetime : t -> date:(int * int * int) -> time:(int * int * int) -> int

gmt_offset_seconds_at_datetime tz ~date ~time is the number of seconds that offset from UTC, for the given date (year, month, day) and time (hour, minute, second).

Note: In case of an ambiguous date, any of the two valid Time.t will be picked depending on the implementation.

val gmt_offset_seconds_at_time : t -> Ptime.t -> int

gmt_offset_seconds_at_time tz timestamp is the number of seconds that offset from UTC, at the time given by a unix timestamp (Ptime.t). In other words, localtime = UTC + offset.

val name : t -> string

name tz is the IANA name of tz, if it could be determined.

Comparison

Timezones are comparable through their names.

val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (=) : t -> t -> bool
val (>) : t -> t -> bool
val (<) : t -> t -> bool
val (<>) : t -> t -> bool
val equal : t -> t -> bool
val compare : t -> t -> int
val min : t -> t -> t
val max : t -> t -> t
val ascending : t -> t -> int
val descending : t -> t -> int
val between : t -> low:t -> high:t -> bool
val clamp_exn : t -> min:t -> max:t -> t
val clamp : t -> min:t -> max:t -> t Base__.Or_error.t
type comparator_witness = Timmy.Timezone.comparator_witness
val comparator : (t, comparator_witness) Base__Comparator.comparator

Printing

val pp : t Fmt.t

pp fmt tz prints the name of tz to formatter fmt.

val native : t

native is a system specific implementation that relies on the underlying system to adjust for evolving timezones.