package timere

  1. Overview
  2. Docs
type t = private {
  1. year : int;
  2. month : month;
  3. day : int;
  4. hour : int;
  5. minute : int;
  6. second : int;
  7. tz_info : tz_info;
}
val make : tz:Time_zone.t -> year:int -> month:month -> day:int -> hour:int -> minute:int -> second:int -> t option

Constructs a date time providing only a time zone.

A precise offset is inferred if possible.

Note that this may yield a ambiguous date time if the time zone has varying offsets, e.g. DST.

See make_precise for the most precise construction.

val make_exn : tz:Time_zone.t -> year:int -> month:month -> day:int -> hour:int -> minute:int -> second:int -> t
  • raises Invalid_argument

    if make fails

val make_precise : ?tz:Time_zone.t -> year:int -> month:month -> day:int -> hour:int -> minute:int -> second:int -> tz_offset_s:tz_offset_s -> unit -> t option

Constructs a date time providing time zone offset in seconds, and optionally a time zone.

If a time zone is provided, then the offset is checked against the time zone record to make sure the time zone does use said offset for the particular date time.

val make_precise_exn : ?tz:Time_zone.t -> year:int -> month:month -> day:int -> hour:int -> minute:int -> second:int -> tz_offset_s:tz_offset_s -> unit -> t
  • raises Invalid_argument

    if make_precise fails

type 'a local_result = [
  1. | `Single of 'a
  2. | `Ambiguous of 'a * 'a
]

Result for when a local date time may be involved, e.g. using a date time with no precise time zone offset attached.

  • `Single is yielded when the date time maps to exactly one 'a. This happens when date time carries an accurate offset, or when the date time is not affected by any offset shifts (thus an accurate offset can be inferred).
  • `Ambiguous is yielded when date time maps to more than one (exactly two) 'a. This happens when DST ends and "goes back an hour" for instance.
val to_timestamp : t -> timestamp local_result
val to_timestamp_single : t -> timestamp
  • raises Invalid_argument

    if to_timestamp does not yield a `Single result

val min_of_timestamp_local_result : timestamp local_result -> timestamp
val max_of_timestamp_local_result : timestamp local_result -> timestamp
val of_timestamp : ?tz_of_date_time:Time_zone.t -> timestamp -> t option
val equal : t -> t -> bool
val min : t
val max : t
val now : ?tz_of_date_time:Time_zone.t -> unit -> t
val to_string : ?format:string -> t -> string

Pretty printing for date time.

Default format string:

{year} {mon:Xxx} {mday:0X} {hour:0X}:{min:0X}:{sec:0X} \
{tzoff-sign}{tzoff-hour:0X}:{tzoff-min:0X}:{tzoff-sec:0X}

Format string specification:

{{               literal {
{year}           year
{mon:Xxx}        abbreviated month name (e.g. Jan), casing of 'x' controls the casing
{mon:Xx*}        full month name (e.g. January), casing of first 'x' controls casing of first letter,
                 casing of second 'x' controls casing of following letters
{mday:cX}        month day (e.g.  1) character 'c' before 'X' is used for padding
                 (leave out character for no padding)
{wday:Xxx}       abbreviated weekday name (e.g. Sun), the casing of 'x' controls the casing
{wday:Xx*}       full weekday name (e.g. Sunday), casing of first 'x' controls casing of first letter,
                 casing of second 'x' controls casing of following letters
{hour:cX}        hour in 24-hour format, character 'c' before 'X' determines padding
                 (leave out character for no padding)
{12hour:cX}      hour in 12-hour format, character 'c' before 'X' determines padding
                 (leave out character for no padding)
{min:cX}         minute, character 'c' before 'X' determines padding
                 (leave out character for no padding)
{sec:cX}         second, character 'c' before 'X' determines padding
                 (leave out character for no padding)
{tzoff-sign}     time zone offset sign ('+' or '-')
                 yields "N/A" if time zone offset is not available
{tzoff-hour:cX}  time zone offset hour, follows same padding rule as "{hour:cX}"
                 yields "N/A" if time zone offset is not available
{tzoff-min:cX}   time zone offset minute, follows same padding rule as "{min:cX}"
                 yields "N/A" if time zone offset is not available
{tzoff-sec:cX}   time zone offset second, follows same padding rule as "{sec:cX}"
                 yields "N/A" if time zone offset is not available
val pp : ?format:string -> unit -> Stdlib.Format.formatter -> t -> unit
val to_rfc3339 : t -> string
val of_iso8601 : string -> (t, string) Stdlib.result
OCaml

Innovation. Community. Security.