package mirage-ptime
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=60e5a926b7d0286f64842c0f6f99595ed7fe7e2a783740750009f663dcd12f28
sha512=c8f6ba732bf103fa6509708f58e4f7fe3b317d3c35d62662df2454a04cc3278f036eee125a4a6d12f4cd24d3c6aaf49bb46f3fc5a76bff5c6282c915de0a631f
doc/mirage-ptime.unix/Mirage_ptime/index.html
Module Mirage_ptimeSource
include module type of struct include Ptime_clock end
POSIX clock
now () is the current POSIX time, by definition always on the UTC timeline.
Raises Sys_error, see error handling.
period () is a positive POSIX time span representing the clock's period (if available).
System time zone offset
current_tz_offset_s () is the system's current local time zone offset to UTC in seconds, if known. This is the duration local time - UTC time in seconds.
POSIX clock raw interface
now_d_ps () is (d, ps) representing POSIX time occuring at d * 86'400e12 + ps POSIX picoseconds from the epoch 1970-01-01 00:00:00 UTC. ps is in the range [0;86_399_999_999_999_999L].
Raises Sys_error, see error handling
period_d_ps () is if available Some (d, ps) representing the clock's picosecond period d * 86'400e12 + ps. ps is in the range [0;86_399_999_999_999_999L].
Error handling
The functions now and now_d_ps raise Sys_error whenever they can't determine the current time or that it doesn't fit in Ptime's well-defined range. This exception should only be catched at the toplevel of your program to log it and abort the program. It indicates a serious error condition in the system.
All the other functions, whose functionality is less essential, simply silently return None if they can't determine the information either because it is unavailable or because an error occured.
Platform support
- Platforms with a POSIX clock (includes Linux) use
clock_gettimewithCLOCK_REALTIME. - On Darwin
gettimeofdayis used. - On Windows
GetSystemTimeandGetTimeZoneInformationare used. - On JavaScript
Date.now ()andDate.prototype.getTimezoneOffsetare used.