Module Time


module Time: sig  end
Time utility functions to fill in gaps in the Unix library and to be more to my liking.



Time-related structures



type timeval = {
   tv_sec : int32; (*Seconds*)
   tv_usec : int32; (*Microseconds*)
}
Structure for high-resolution time


Getting the time

These are like Unix.BLAH, but storing the time in int32 rather than float.

val time : unit -> int32
Return the current time
val gmtime : int32 -> Unix.tm
Take a time and return a Unix.tm using UTC
val localtime : int32 -> Unix.tm
Take a time and return a Unix.tm using the local time zone
val mktime : Unix.tm -> int32 * Unix.tm
Turn a Unix.tm into the current time plus a normalized Unix.tm
val gettimeofday : unit -> timeval
Return a high-precision time. Like Unix.gettimeofday, but returns a timeval instead of a float.


Manipulating time


val difftime : int32 -> int32 -> float
difftime past now returns the number of seconds between the two times


Pretty-printing a time


val format_tm : string -> Unix.tm -> string
Wrapper for the C strftime() function. See local documentation for it for information on the string argument (strftime()'s format argument)
val format_time : string -> int32 -> string
Same taking a time in seconds
val parse_tm : string -> string -> Unix.tm
Wrapper for the C strptime() function. The first argument is the format string, the second argument is string to parse. See man strptime for information on the format string
val parse_time : string -> string -> int32
Same returning time in seconds
val ctime : int32 -> string
Returns the time as a string with trailing newline
val asctime : Unix.tm -> string
Same as ctime but takes a Unix.tm
val time_string : int32 -> string
Time as a string without trailing newline
val tm_string : Unix.tm -> string
Same as time_string but takes a Unix.tm