Library
Module
Module type
Parameter
Class
Class type
A day of the day.
A day of the day.
type js =
< hours : Js_of_ocaml.Js.number Js_of_ocaml.Js.readonly_prop
; minutes : Js_of_ocaml.Js.number Js_of_ocaml.Js.readonly_prop
; seconds : Js_of_ocaml.Js.number Js_of_ocaml.Js.readonly_prop >
Js_of_ocaml.Js.t
make ~hours ~minutes ~int
is { hours; minutes; seconds }
if it represents a valid time of the day or a relevant error message otherwise.
val latest : t
latest
is {hours = 23; minutes = 59; seconds = 59}
val midnight : t
midnight
is {hours = 0; minutes = 0; seconds = 0}
val noon : t
noon
is {hours = 12; minutes = 0; seconds = 0}
val with_daytime : timezone:Timezone.t -> t -> Time.t -> Time.t
with_daytime ~timezone daytime time
is daytime
time of the day on the same date as time
in timezone
.
val of_time : timezone:Timezone.t -> Time.t -> t
of_time ~timezone time
is the time of the day at time
in timezone
.
val to_time : timezone:Timezone.t -> Date.t -> t -> Time.t
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.
include Base.Comparable.S with type t := t
include Base.Comparisons.S with type t := t
include Base.Comparisons.Infix with type t := t
compare t1 t2
returns 0 if t1
is equal to t2
, a negative integer if t1
is less than t2
, and a positive integer if t1
is greater than t2
.
ascending
is identical to compare
. descending x y = ascending y x
. These are intended to be mnemonic when used like List.sort ~compare:ascending
and List.sort
~cmp:descending
, since they cause the list to be sorted in ascending or descending order, respectively.
clamp_exn t ~min ~max
returns t'
, the closest value to t
such that between t' ~low:min ~high:max
is true.
Raises if not (min <= max)
.
val clamp : t -> min:t -> max:t -> t Base.Or_error.t
include Base.Comparator.S with type t := t
val comparator : (t, comparator_witness) Base.Comparator.comparator
module O : sig ... end
Convenience module to only pull operators.
val to_int : t -> int
to_int daytime
the number of seconds from midnight to daytime
.
of_int n
the daytime n
seconds after midnight or a relevant error message if the result is out of bounds.
val pp_opt :
?format:[ `_12 | `_24 ] ->
?precision:[ `Hours | `Minutes | `Seconds ] ->
?size:[ `Long | `Short ] ->
unit ->
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
.val to_tuple : t -> int * int * int
to_tuple { hours; minutes; seconds }
is (hours, minutes, seconds)
.
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 -> (int * int * int) -> t
of_tuple (hours, minutes, seconds)
is the corresponding time of the day