DurationDuration - conversions to various time units
A duration is represented in nanoseconds as an unsigned 64 bit integer. This has a range of up to 584 years, or 213503 days, or 5124095 hours, or 307445734 minutes, or 18446744073 seconds, or 18446744073709 milliseconds, or 18446744073709549 microseconds.
All functions converting to t raise Invalid_argument on out of bound or negative input.
%%VERSION%% - homepage
The type for a duration (in nanoseconds), exposed as an int64 to provide interoperability.
val pp : Format.formatter -> t -> unitpp ppf t prints the duration in a concise way.
val of_us : int -> tof_us us are the microseconds in nanoseconds.
val of_us_64 : int64 -> tof_us_64 us are the microseconds in nanoseconds.
val of_ms : int -> tof_ms ms are the milliseconds in nanoseconds.
val of_ms_64 : int64 -> tof_ms_64 ms are the milliseconds in nanoseconds.
val of_sec : int -> tof_sec s are the seconds in nanoseconds.
val of_sec_64 : int64 -> tof_sec_64 s are the seconds in nanoseconds.
val of_min : int -> tof_min m are the minutes in nanoseconds.
val of_hour : int -> tof_hour h are the hours in nanoseconds.
val of_day : int -> tof_day d are the days in nanoseconds.
val of_year : int -> tof_year y are the years in nanoseconds.
val of_f : float -> tof_f f is the floating point seconds in nanoseconds.
val to_us : t -> intto_us t are the microseconds of t.
val to_us_64 : t -> int64to_us_64 t are the microseconds of t.
val to_ms : t -> intto_ms t are the milliseconds of t.
val to_ms_64 : t -> int64to_ms_64 t are the milliseconds of t.
val to_sec : t -> intto_sec t are the seconds of t.
val to_sec_64 : t -> int64to_sec_64 t are the seconds of t.
val to_min : t -> intto_min t are the minutes of t.
val to_hour : t -> intto_hour t are the hours of t.
val to_day : t -> intto_day t are the days of t.
val to_year : t -> intto_year t are the years of t.
val to_f : t -> floatto_f t is the floating point representation of t.
val of_string_exn : string -> tof_string_exn str tries to parse str and calculate a duration. The user can specify a duration via metrics:
1ns for one nanoseconds1us, 1μs or 1µs for one microsecond1ms for one milliseconds1s for one second1m for one minute1h for one hour1d for one day1y/1a for one yearThe user can use multiple metrics but they can be used only once. 1d1d is invalid (you can use 2d) but 1d1y is valid and correspond to 1 year plus 1 day.
of_string is of_string_exn but it returns a result instead of raising an exception.