Module OcsfmlSystem.Time

module Time: sig .. end
Module Time : time conversions utility

type t 
Represents a time value Time.t encapsulates a time value in a flexible way.

It allows to define a time value either as a number of seconds, milliseconds or microseconds. It also works the other way round: you can read a time value as either a number of seconds, milliseconds or microseconds.

By using such a flexible interface, the API doesn't impose any fixed type or resolution for time values, and let the user choose its own favorite representation.

Time values support the usual mathematical operations: you can add or subtract two times, multiply or divide a time by a number, compare two times, etc.

Since they represent a time span and not an absolute time value, times can also be negative.

Usage example:

      let t1 = Time.seconds 0.1 in
      let milli = Time.as_milliseconds t1 in // 100
      
      let t2 = Time.milliseconds 30  in
      let micro = Time.as_microseconds t2 in // 30000
      
      let t3 = Time.microseconds -800000L in
      let sec = Time.as_seconds t3 in // -0.8
      
      let update elapsed =
      position := position +. speed *. (Time.as_seconds elapsed)
      
      update (Time.milliseconds 100)
      

val as_seconds : t -> float
Return the time value as a number of seconds
Returns Time in seconds
val as_milliseconds : t -> int
Return the time value as a number of milliseconds
Returns Time in milliseconds
val as_microseconds : t -> int64
Return the time value as a number of microseconds
Returns Time in microseconds
val seconds : float -> t
Construct a time value from a number of seconds
Returns Time value constructed from the amount of seconds
val milliseconds : int -> t
Construct a time value from a number of milliseconds
Returns Time value constructed from the amount of milliseconds
val microseconds : int64 -> t
Construct a time value from a number of microseconds
Returns Time value constructed from the amount of microseconds
val add : t -> t -> t
val sub : t -> t -> t
val mul : t -> int64 -> t
val mul_float : t -> float -> t
val div : t -> int64 -> t
val div_float : t -> float -> t