Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file ofday_intf.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139open!ImportopenStd_internalmoduletypeS=sig(** Time of day.
[t] represents a clock-face time of day. Usually this is equivalent to a time-offset
from midnight, and each [t] occurs exactly once in each calendar day. However, when
daylight saving time begins or ends, some clock face times (and therefore [t]'s) can
occur more than once per day or not at all, and e.g. 04:00 can occur three or five
hours after midnight, so knowing your current offset from midnight is *not* in
general equivalent to knowing the current [t].
(See {!Zone} for tools to help you cope with DST.)
There is one nonstandard representable value, [start_of_next_day], which can be
thought of as "24:00:00" in 24-hour time. It is essentially "00:00:00" on the next
day. By having this value, we allow comparisons against a strict upper bound on [t]
values. However, it has some odd properties; for example, [Time.of_date_ofday ~zone
date start_of_next_day |> Time.to_date ~zone] yields a different date.
Any [ofday] will satisfy [start_of_day <= ofday <= start_of_next_day]. *)typeunderlyingtypet=privateunderlying[@@derivingbin_io,sexp,sexp_grammar,typerep]includeComparable_binablewithtypet:=tincludeHashable_binablewithtypet:=tincludePretty_printer.Swithtypet:=tincludeRobustly_comparablewithtypet:=tincludeQuickcheck.S_rangewithtypet:=tmoduleSpan:Span_intf.S(** [of_string] supports and correctly interprets 12h strings with the following suffixes:
{v
"A", "AM", "A.M.", "A.M"
"P", "PM", "P.M.", "P.M"
v}
as well as the lowercase and space-prefixed versions of these suffixes.
[of_string] also fully supports 24h wall-clock times.
[to_string] only produces the 24h format. *)includeStringablewithtypet:=tvalcreate:?hr:int->?min:int->?sec:int->?ms:int->?us:int->?ns:int->unit->tvalto_parts:t->Span.Parts.t(** Smallest valid ofday. *)valstart_of_day:t(** Largest representable ofday; see notes above on how [start_of_next_day] behaves
differently from other ofday values. *)valstart_of_next_day:t(** A time very close to the end of a day. Not necessarily the largest representable
value before [start_of_next_day], but as close as possible such that using this
ofday with [Time.of_date_ofday] and [Time.to_date] should round-trip to the same
date. With floating-point representations of time, this may not be possible for
dates extremely far from epoch.
The clock-face time represented by [approximate_end_of_day] may vary with different
time and ofday representations, depending on their precision. *)valapproximate_end_of_day:t(** Note that these names are only really accurate on days without DST transitions. When
clocks move forward or back, [of_span_since_start_of_day_exn s] will not necessarily
occur [s] after that day's midnight. *)valto_span_since_start_of_day:t->Span.tvalof_span_since_start_of_day_exn:Span.t->tvalof_span_since_start_of_day:Span.t->t[@@deprecated"[since 2018-04] use [of_span_since_start_of_day_exn] instead"](** Reports whether a span represents a valid time since the start of the day, i.e.
whether [of_span_since_start_of_day_exn span] would succeed. *)valspan_since_start_of_day_is_valid:Span.t->bool(** [of_span_since_start_of_day_unchecked] does not validate that the [Span] represents
a valid [Ofday].
Behavior of other [Ofday] accessors is unspecified, but still safe (e.g., won't
segfault), if the input does not satisfy [span_since_start_of_day_is_valid]. *)valof_span_since_start_of_day_unchecked:Span.t->t(** [add t s] shifts the time of day [t] by the span [s]. It returns [None] if the
result is not in the same 24-hour day. *)valadd:t->Span.t->toptionvalsub:t->Span.t->toption(** [next t] return the next [t] (next t > t) or None if [t] = end of day. *)valnext:t->toption(** [prev t] return the previous [t] (prev t < t) or None if [t] = start of day. *)valprev:t->toption(** [diff t1 t2] returns the difference in time between two ofdays, as if they occurred
on the same 24-hour day. *)valdiff:t->t->Span.t(** Returns the time-span separating the two of-days, ignoring the hour information, and
assuming that the of-days represent times that are within a half-hour of each other.
This is useful for comparing two ofdays in unknown time-zones. *)valsmall_diff:t->t->Span.t(** Trailing groups of zeroes are trimmed such that the output is printed in terms of
the smallest non-zero units among nanoseconds, microseconds, milliseconds, or
seconds; or minutes if all of the above are zero. *)valto_string_trimmed:t->string(** HH:MM:SS, without any subsecond components. Seconds appear even if they are zero. *)valto_sec_string:t->string(** 24-hour times according to the ISO 8601 standard. This function can raise. *)valof_string_iso8601_extended:?pos:int->?len:int->string->t(** with milliseconds *)valto_millisecond_string:t->stringvalto_millisec_string:t->string[@@deprecated"[since 2018-04] use [to_millisecond_string] instead"]end