Module type Time_sig.S


module type S = sig .. end
Common operations for all time representations.
Since 2.0 (this signature was before inlined in interface of Time).


Datatypes


type t 
Type of a time.
type field = [ `Hour | `Minute | `Second ] 
The different fields of a time.

Second


type second 
Type of a second.
Since 2.0 (was an integer in previous versions).
module Second: Time_sig.Second  with type t = second
Second implementation

Constructors


val make : int -> int -> second -> t
make hour minute second makes the time hour-minute-second.
val lmake : ?hour:int -> ?minute:int -> ?second:second -> unit -> t
Labelled version of make. The default value is 0 for each argument.
Since 1.05
val now : unit -> t
The current time based on Time_Zone.current ().
val midnight : unit -> t
midnight () is midnight (expressed in the current time zone). So, it has always the same behaviour as make 0 0 0.
val midday : unit -> t
midday () is midday (expressed in the current time zone). So, it has always the same behaviour as make 12 0 0.

Conversions


val convert : t -> Time_Zone.t -> Time_Zone.t -> t
convert t t1 t2 converts the time t expressed in the time zone t1 to the same time expressed in the time zone t2.
val from_gmt : t -> t
from_gmt t is equivalent to convert t Time_Zone.GMT (Time_Zone.current ()).
val to_gmt : t -> t
to_gmt t is equivalent to convert t (Time_Zone.current ()) Time_Zone.GMT.
val normalize : t -> t * int
normalize t returns t such that hour t belongs to [0; 24[. The second component of the result is the number of days needed by the modification.

Getters


val hour : t -> int
Hour.
val minute : t -> int
Minute.
val second : t -> second
Second.
val to_seconds : t -> second
Number of seconds of a time.
val to_minutes : t -> float
Number of minutes of a time. The resulting fractional part represents seconds.
val to_hours : t -> float
Number of hours of a time. The resulting fractional part represents minutes and seconds.

Times are comparable


val equal : t -> t -> bool
Equality function between two times.
Since 1.09.0
See also Utils.Comparable.equal.
val compare : t -> t -> int
Comparison function between two times.
See also Utils.Comparable.compare.
val hash : t -> int
Hash function for times.
Since 2.0
See also Utils.Comparable.hash.

Boolean operations on times


val is_pm : t -> bool
Return true is the time is before midday in the current time zone; false otherwise.
val is_am : t -> bool
Return true is the time is after midday in the current time zone; false otherwise.

Coercions


val from_seconds : second -> t
Inverse of to_seconds.
val from_minutes : float -> t
Inverse of to_minutes.
val from_hours : float -> t
Inverse of to_hours.

Period


module Period: sig .. end
A period is the number of seconds between two times.

Arithmetic operations on times and periods


val add : t -> Period.t -> t
app t p returns t + p.
val sub : t -> t -> Period.t
sub t1 t2 returns the period between t1 and t2.
val rem : t -> Period.t -> t
rem t p is equivalent to add t (Period.opp p).
val next : t -> field -> t
next t f returns the time corresponding to the next specified field.
val prev : t -> field -> t
prev t f returns the time corresponding to the previous specified field.