Module Time


module Time: sig .. end
Our time module. This module wraps up unix times, including various convenience functions for accessing them.

module Span: sig .. end
A timespan.
module Ofday: sig .. end
A time of day.
module Date: sig .. end
String conversions
type t 
A date+time.
include Hashable
include Comparable
include Robustly_comparable
include Sexpable
include Binable
include Stringable
include Floatable

Basic operations on times

val add : t -> Span.t -> t
add t s adds the span s to time t and returns the resulting time.

NOTE: adding spans as a means of adding days is not accurate, and may run into trouble due to shifts in daylight savings time, float arithmetic issues, and leap seconds. See the comment at the top of TZ.mli for a more complete discussion of some of the issues of time-keeping. For spans that cross date boundaries, use date functions instead.

val sub : t -> Span.t -> t
sub t s subtracts the span s from time t and returns the resulting time. See important note for add.
val diff : t -> t -> Span.t
diff t1 t2 returns time t1 minus time t2.
val abs_diff : t -> t -> Span.t
diff t1 t2 returns the absolute span of time t1 minus time t2.

Constants

val min_value : t
Minimum value.
val max_value : t
Maximum value.

Conversions

val of_date_ofday : Date.t -> Ofday.t -> t
All these conversion functions use the current time zone. Unless marked _utc, in which case they use Universal Coordinated Time
val to_date_ofday : t -> Date.t * Ofday.t
val of_date_ofday_utc : Date.t -> Ofday.t -> t
Assume the specified date and time of day are UTC
val to_date_ofday_utc : t -> Date.t * Ofday.t
Produce the current UTC date and time of day
val to_date : t -> Date.t
val to_ofday : t -> Ofday.t

Other string conversions
val to_filename_string : t -> string
to_filename_string t converts t to string with format YYYY-MM-DD_HH-MM-SS.mmm which is suitable for using in filenames

of_filename_string s converts s that has format YYYY-MM-DD_HH-MM-SS.mmm into time

val of_filename_string : string -> t
val to_string_fix_proto : [ `Local | `Utc ] -> t -> string
val of_string_fix_proto : [ `Local | `Utc ] -> string -> t
val to_string_old : t -> string
val to_string_trimmed : t -> string
to_string_trimmed t Same as to_string, but removes trailing seconds and milliseconds if they are 0
val of_date_time_strings : string -> string -> t
val pp : Format.formatter -> t -> unit

Miscellaneous

val now : unit -> t
Returns the current time.
val pause : Span.t -> unit
Pause (and don't throw an exception)
val ofday_occurrence : Ofday.t -> [ `right_after | `right_before ] -> t -> t
ofday_occurrence ofday side now returns a Time.t that is the occurrence of ofday which is the latest occurrence before now or the earliest occurrence after now, according to side. NOTE: This function is a little bit wrong near daylight savings time
val ofday_occurrence_utc : Ofday.t -> [ `right_after | `right_before ] -> t -> t