Library
Module
Module type
Parameter
Class
Class type
date
, time
and datetime
parse a string
and return the corresponding timestamp (as float
).
Times are always converted to UTC representation.
For each of these functions, a _lex
suffixed function read from a Lexing.lexbuf
instead of a string
.
datetime
functions also take an optional boolean reqtime
indicating if parsing must fail if a date is given and not a complete datetime. (Default is true).
Functions with _tz
in their name return a float * float option
representing timestamp * offset option (timezone)
. timestamp
will be the UTC time, and offset option
is just an information about the original timezone.
val date_lex : Lexing.lexbuf -> float
val time_tz_lex : Lexing.lexbuf -> float * float option
val time_lex : Lexing.lexbuf -> float
val datetime_tz_lex : ?reqtime:bool -> Lexing.lexbuf -> float * float option
val datetime_lex : ?reqtime:bool -> Lexing.lexbuf -> float
NB: fractionnal part of timestamps will be lost when printing with current implementation.
val pp_format : Format.formatter -> string -> float -> float -> unit
pp_format fmt format x tz
x
is the timestamp, and tz
the time zone offset.
The format
string is a character string which contains two types of objects: plain characters, which are simply copied to fmt
, and conversion specifications, each of which causes conversion and printing of (a part of) x
or tz
.
If you do not want to use a timezone, set it to 0.
Conversion specifications have the form %X
, where X can be:
Y
: YearM
: MonthD
: Dayh
: Hoursm
: Minutess
: SecondsZ
: Hours of tz
offset (with its sign)z
: Minutes of tz
offset (without sign)%
: The '%' characterval pp_date : Format.formatter -> float -> unit
"%Y-%M-%D" format.
val pp_date_basic : Format.formatter -> float -> unit
"%Y%M%D" format.
val pp_time : Format.formatter -> float -> unit
"%h:%m:%s" format.
val pp_time_basic : Format.formatter -> float -> unit
"%h%m%s" format.
val pp_datetime : Format.formatter -> float -> unit
"%Y-%M-%DT%h:%m:%s" format.
val pp_datetime_basic : Format.formatter -> float -> unit
"%Y%M%DT%h%m%s" format.
val pp_datetimezone : Format.formatter -> (float * float) -> unit
"%Y-%M-%DT%h:%m:%s%Z:%z" format.
val pp_datetimezone_basic : Format.formatter -> (float * float) -> unit
"%Y%M%DT%h%m%s%Z%z" format.