package timedesc

  1. Overview
  2. Docs
type t

Representation of time of day

type view = private {
  1. hour : int;
  2. minute : int;
  3. second : int;
  4. ns : int;
}
type 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
]
exception Error_exn of error

Constructors

val 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.

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

Comparison

val equal : t -> t -> bool

Accessors

val view : t -> view
val hour : t -> int
val minute : t -> int
val second : t -> int
val ns : t -> int
val is_leap_second : t -> bool

Conversion

val to_span : t -> Span.t
val of_span : Span.t -> t option
OCaml

Innovation. Community. Security.