package timedesc

  1. Overview
  2. Docs
type sign = [
  1. | `Pos
  2. | `Neg
]
type view = private {
  1. sign : sign;
  2. days : int;
  3. hours : int;
  4. minutes : int;
  5. seconds : int;
  6. ns : int;
}
type error = [
  1. | `Invalid_days of int
  2. | `Invalid_hours of int
  3. | `Invalid_minutes of int
  4. | `Invalid_seconds of int
  5. | `Invalid_ns of int
]
type error_f = [
  1. | `Invalid_days_f of float
  2. | `Invalid_hours_f of float
  3. | `Invalid_minutes_f of float
  4. | `Invalid_seconds_f of float
  5. | `Invalid_ns of int
]
exception Error_exn of error
exception Error_f_exn of error_f

Constructors

val make : ?sign:sign -> ?days:int -> ?hours:int -> ?minutes:int -> ?seconds:int -> ?ns:int -> unit -> (t, error) Stdlib.result

sign defaults to `Pos.

Returns Error if any of the arguments are negative.

  • raises Out_of_range

    if the value cannot be represented even after normalization

val make_exn : ?sign:sign -> ?days:int -> ?hours:int -> ?minutes:int -> ?seconds:int -> ?ns:int -> unit -> t
val make_frac : ?sign:sign -> ?days:float -> ?hours:float -> ?minutes:float -> ?seconds:float -> ?ns:int -> unit -> (t, error_f) Stdlib.result

sign defaults to `Pos.

Returns Error if any of the arguments are negative.

  • raises Out_of_range

    if the value cannot be represented even after normalization

val make_frac_exn : ?sign:sign -> ?days:float -> ?hours:float -> ?minutes:float -> ?seconds:float -> ?ns:int -> unit -> t

Viewer

val view : t -> view

Pretty-printing

val pp : ?format:string -> unit -> Stdlib.Format.formatter -> t -> unit

Pretty-printing for span. * * Default format string:

{days-nz: days }{hours-nz:X hours }{mins-nz:X mins }{secs:X}{sec-frac:.X} secs

Format string specification:

        {{                      Literal {
        {days:unit}             Number of days
                                Unit is the string used after the number to denote its unit
        {days-nz:unit}          Same as above, but does not display if number is zero

        {hours:cXunit}          Number of hour, sub-day
                                Character 'c' before 'X' is used for padding
                                (leave out character for no padding, e.g. {hours:Xunit})
                                Unit is the string used after the number to denote its unit
        {hours-nz:cXunit}       Same as above, but does not display if number is zero

        {mins:cXunit}           Number of minutes, sub-hour
                                Character 'c' before 'X' is used for padding
                                (leave out character for no padding, e.g. {mins:Xunit})
                                Unit is the string used after the number to denote its unit
        {mins-nz:cXunit}        Same as above, but does not display if number is zero

        {secs:cXunit}           Number of seconds, sub-minute
                                Character 'c' before 'X' is used for padding
                                (leave out character for no padding, e.g. {secs:Xunit})
                                Unit is the string used after the number to denote its unit
        {secs-nz:cXunit}        Same as above, but does not display if number is zero

        {sec-frac:cNXunit}      Fraction of second, sub-second
                                N determines the number of digits to take after decimal separator
                                If N is not specified, then the smallest number of digits required
                                after decimal separator for a lossless representation is used
                                Character c is used as the decimal separator
                                Unit is the string used after the number to denote its unit
        {secs-frac-nz:cNXunit}  Same as above, but does not display if nanosecond count is
                                zero

*

val to_string : ?format:string -> t -> string
OCaml

Innovation. Community. Security.