package timmy-jsoo

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include module type of struct include Timmy.Daytime end

A day of the day.

A day of the day.

Type

type t = private Timmy.Daytime.t = {
  1. hours : int;
  2. minutes : int;
  3. seconds : int;
}

A time of the day.

Construction

val make : hours:Base.int -> minutes:Base.int -> seconds:Base.int -> (Timmy.Daytime.t, Base.string) Base.Result.t

make ~hours ~minutes ~int is { hours; minutes; seconds } if it represents a valid time of the day or a relevant error message otherwise.

Well known values

val latest : Timmy.Daytime.t

latest is {hours = 23; minutes = 59; seconds = 59}

val midnight : Timmy.Daytime.t

midnight is {hours = 0; minutes = 0; seconds = 0}

val noon : Timmy.Daytime.t

noon is {hours = 12; minutes = 0; seconds = 0}

Time manipulation

val with_daytime : timezone:Timmy.Timezone.t -> Timmy.Daytime.t -> Timmy.Time.t -> Timmy.Time.t

with_daytime ~timezone daytime time is daytime time of the day on the same date as time in timezone.

val truncate_seconds : Timmy.Daytime.t -> Timmy.Daytime.t

truncate_seconds daytime is daytime with seconds set to 0.

val truncate_minutes : Timmy.Daytime.t -> Timmy.Daytime.t

truncate_minutes daytime is daytime with minutes and seconds set to 0.

Time conversions

val of_time : timezone:Timmy.Timezone.t -> Timmy.Time.t -> Timmy.Daytime.t

of_time ~timezone time is the time of the day at time in timezone.

to_time ~timezone date daytime is the time at daytime on date in timezone. When the date and datetime do not exist in timezone because of a time transition (eg. daylight saving), the returned time will be shifted to an existing hour. The manner in which the shift is applied is system dependant.

Comparison

include Base.Comparable.S with type t := t
val equal : Timmy.Daytime.t -> Timmy.Daytime.t -> bool
val compare : Timmy.Daytime.t -> Timmy.Daytime.t -> int
val ascending : Timmy.Daytime.t -> Timmy.Daytime.t -> int
val descending : Timmy.Daytime.t -> Timmy.Daytime.t -> int
val between : Timmy.Daytime.t -> low:Timmy.Daytime.t -> high:Timmy.Daytime.t -> bool
val clamp : Timmy.Daytime.t -> min:Timmy.Daytime.t -> max:Timmy.Daytime.t -> Timmy.Daytime.t Base__.Or_error.t
type comparator_witness = Timmy.Daytime.comparator_witness
val comparator : (Timmy.Daytime.t, comparator_witness) Base__Comparator.comparator

Operators

module O = Timmy.Daytime.O

Convenience module to only pull operators.

include module type of O

Convenience module to only pull operators.

Convenience module to only pull operators.

Convenience module to only pull operators.

Convenience module to only pull operators.

include Base.Comparable.Infix with type t := Timmy__.Daytime.t
val (>=) : Timmy.Daytime.t -> Timmy.Daytime.t -> bool
val (<=) : Timmy.Daytime.t -> Timmy.Daytime.t -> bool
val (=) : Timmy.Daytime.t -> Timmy.Daytime.t -> bool
val (>) : Timmy.Daytime.t -> Timmy.Daytime.t -> bool
val (<) : Timmy.Daytime.t -> Timmy.Daytime.t -> bool
val (<>) : Timmy.Daytime.t -> Timmy.Daytime.t -> bool
val (+) : Timmy.Daytime.t -> Span.t -> (Timmy.Daytime.t, Base.string) Base.Result.t

daytime + span is the daytime after span has elapsed, or a relevant error message if the result is out of bounds.

Scalar conversions

Integer

val to_int : Timmy.Daytime.t -> Base.int

to_int daytime the number of seconds from midnight to daytime.

val of_int : Base.int -> (Timmy.Daytime.t, Base.string) Base.Result.t

of_int n the daytime n seconds after midnight or a relevant error message if the result is out of bounds.

Pretty-print

val pp : Timmy.Daytime.t Fmt.t

pp f daytime prints daytime to f in RFC3339 format, eg. 12:43:51.

val pp_opt : ?format:[ `_12 | `_24 ] -> ?precision:[ `Hours | `Minutes | `Seconds ] -> ?size:[ `Long | `Short ] -> Base.unit -> Timmy.Daytime.t Fmt.t

pp_opt ~format ~precision ~size () f daytime pretty-prints daytime to f according to the given options.

  • format: `_12 prints in a US-style twelve hour format (eg. 12AM, 1:30AM, 12PM, 1:30PM), `_24 prints in twelve twenty-four hour format (eg. 00:00, 1:30, 12:00, 13:30). Default is `_24.
  • precision: `Hours displays only hours (eg. 1PM, 13), `Minutes also displays minutes (eg. 13:42, 1:42PM) and `Seconds additionally displays seconds (eg. 13:42:51, 1:42:51PM). Default is `Seconds.
  • size: `Long displays null minutes and seconds (eg. 12:42:00, 13:00:00) while `Short omits them (eg. 12:42, 13). Default is `Short.

Tuple

val to_tuple : Timmy.Daytime.t -> Base.int * Base.int * Base.int

to_tuple { hours; minutes; seconds } is (hours, minutes, seconds).

val of_tuple : (Base.int * Base.int * Base.int) -> (Timmy.Daytime.t, Base.string) Base.Result.t

of_tuple (hours, minutes, seconds) is the corresponding time of the day if it is valid or a relevant error message otherwise.

val of_tuple_exn : ?here:Base.Source_code_position.t -> (Base.int * Base.int * Base.int) -> Timmy.Daytime.t

of_tuple (hours, minutes, seconds) is the corresponding time of the day

  • raises Failure

    if the time of the day is invalid.

OCaml

Innovation. Community. Security.