package timedesc

  1. Overview
  2. Docs

Module Timedesc.TimeSource

Sourcetype t

Representation of time of day

Sourcetype view = private {
  1. hour : int;
  2. minute : int;
  3. second : int;
  4. ns : int;
}
Sourcetype error = [
  1. | `Invalid_hour of int
  2. | `Invalid_minute of int
  3. | `Invalid_second of int
  4. | `Invalid_s_frac of float
  5. | `Invalid_ns of int
]
Sourceexception Error_exn of error

Constructors

Sourceval make : ?ns:int -> ?s_frac:float -> hour:int -> minute:int -> second:int -> unit -> (t, error) result

Constructs t from specification of the time of day.

Leap second can be specified by providing 60 for second. Note that leap second informtation is lost upon translation to timestamp(s), specifically second 60 is treated as second 59.

24:00:00 is treated as 23:59:59.999_999_999.

Nanosecond used is the addition of ns and s_frac * 10^9.

Returns Error `Invalid_hour if hour < 0 || 24 < hour.

Returns Error `Invalid_hour if hour = 24 and minute <> 0 || second <> 0 || total ns <> 0.

Returns Error `Invalid_minute if minute < 0 || 59 < minute.

Returns Error `Invalid_second if second < 0 || 60 < second.

Returns Error `Invalid_ns if s_frac < 0.0.

Returns Error `Invalid_ns if ns < 0.

Returns Error `Invalid_ns if total ns >= 10^9.

Sourceval make_exn : ?ns:int -> ?s_frac:float -> hour:int -> minute:int -> second:int -> unit -> t

Comparison

Sourceval equal : t -> t -> bool

Viewer

Sourceval view : t -> view

Accessors

Sourceval hour : t -> int
Sourceval minute : t -> int
Sourceval second : t -> int
Sourceval ns : t -> int
Sourceval is_leap_second : t -> bool

Conversion

Sourceval to_span : t -> Span.t
Sourceval of_span : Span.t -> t option

Pretty printing

Sourceval pp_rfc3339 : ?frac_s:int -> unit -> Format.formatter -> t -> unit
Sourceval pp_rfc3339_milli : Format.formatter -> t -> unit
Sourceval pp_rfc3339_micro : Format.formatter -> t -> unit
Sourceval pp_rfc3339_nano : Format.formatter -> t -> unit
Sourceval to_rfc3339 : ?frac_s:int -> t -> string
Sourceval to_rfc3339_milli : t -> string
Sourceval to_rfc3339_micro : t -> string
Sourceval to_rfc3339_nano : t -> string

Parsing

Sourceval of_iso8601 : string -> (t, string) result
Sourceval of_iso8601_exn : string -> t
OCaml

Innovation. Community. Security.