package timmy-jsoo
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=6d1d9c3e2ccd8376c009e5b93b24de7e
sha512=96c844a6041f4cf42d1efa02ba12a3a184780beb64bfd5d5693a2338f57ad22d4793ff34a23a9a81a47954dbf489bc644077840d0435013494499b2b3405330b
doc/timmy-jsoo/Timmy_jsoo/Daytime/index.html
Module Timmy_jsoo.Daytime
include module type of struct include Timmy.Daytime end
Type
A time 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.tConstruction
val make :
hours:Base.int ->
minutes:Base.int ->
seconds:Base.int ->
(Timmy.Daytime.t, Base.string) Base.Result.tmake ~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.tlatest is {hours = 23; minutes = 59; seconds = 59}
val midnight : Timmy.Daytime.tmidnight is {hours = 0; minutes = 0; seconds = 0}
val noon : Timmy.Daytime.tnoon is {hours = 12; minutes = 0; seconds = 0}
Time manipulation
val with_daytime :
timezone:Timmy.Timezone.t ->
Timmy.Daytime.t ->
Timmy.Time.t ->
Timmy.Time.twith_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.ttruncate_seconds daytime is daytime with seconds set to 0.
val truncate_minutes : Timmy.Daytime.t -> Timmy.Daytime.ttruncate_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.tof_time ~timezone time is the time of the day at time in timezone.
val to_time :
timezone:Timmy.Timezone.t ->
Timmy.Date.t ->
Timmy.Daytime.t ->
Timmy.Time.tto_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 -> boolval compare : Timmy.Daytime.t -> Timmy.Daytime.t -> intcompare 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.
val min : Timmy.Daytime.t -> Timmy.Daytime.t -> Timmy.Daytime.tval max : Timmy.Daytime.t -> Timmy.Daytime.t -> Timmy.Daytime.tval ascending : Timmy.Daytime.t -> Timmy.Daytime.t -> intascending 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.
val descending : Timmy.Daytime.t -> Timmy.Daytime.t -> intval between :
Timmy.Daytime.t ->
low:Timmy.Daytime.t ->
high:Timmy.Daytime.t ->
boolbetween t ~low ~high means low <= t <= high
val clamp_exn :
Timmy.Daytime.t ->
min:Timmy.Daytime.t ->
max:Timmy.Daytime.t ->
Timmy.Daytime.tclamp_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 :
Timmy.Daytime.t ->
min:Timmy.Daytime.t ->
max:Timmy.Daytime.t ->
Timmy.Daytime.t Base__.Or_error.ttype comparator_witness = Timmy.Daytime.comparator_witnessval comparator :
(Timmy.Daytime.t, comparator_witness) Base__.Comparator.comparatorOperators
module O = Timmy.Daytime.OConvenience module to only pull operators.
include module type of O
include Base.Comparable.Infix with type t := Timmy__.Daytime.t
val (>=) : Timmy.Daytime.t -> Timmy.Daytime.t -> boolval (<=) : Timmy.Daytime.t -> Timmy.Daytime.t -> boolval (=) : Timmy.Daytime.t -> Timmy.Daytime.t -> boolval (>) : Timmy.Daytime.t -> Timmy.Daytime.t -> boolval (<) : Timmy.Daytime.t -> Timmy.Daytime.t -> boolval (<>) : Timmy.Daytime.t -> Timmy.Daytime.t -> boolval (+) :
Timmy.Daytime.t ->
Span.t ->
(Timmy.Daytime.t, Base.string) Base.Result.tdaytime + 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.intto_int daytime the number of seconds from midnight to daytime.
val of_int : Base.int -> (Timmy.Daytime.t, Base.string) Base.Result.tof_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.tpp 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.tpp_opt ~format ~precision ~size () f daytime pretty-prints daytime to f according to the given options.
format:`_12prints in a US-style twelve hour format (eg.12AM,1:30AM,12PM,1:30PM),`_24prints in twelve twenty-four hour format (eg.00:00,1:30,12:00,13:30). Default is`_24.precision:`Hoursdisplays only hours (eg.1PM,13),`Minutesalso displays minutes (eg.13:42,1:42PM) and`Secondsadditionally displays seconds (eg.13:42:51,1:42:51PM). Default is`Seconds.size:`Longdisplays null minutes and seconds (eg.12:42:00,13:00:00) while`Shortomits them (eg.12:42,13). Default is`Short.
Tuple
val to_tuple : Timmy.Daytime.t -> Base.int * Base.int * Base.intto_tuple { hours; minutes; seconds } is (hours, minutes, seconds).
val of_tuple :
(Base.int * Base.int * Base.int) ->
(Timmy.Daytime.t, Base.string) Base.Result.tof_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.tof_tuple (hours, minutes, seconds) is the corresponding time of the day