package timere
Module Timere.Date_timeSource
ns may be >= 10^9 to represent leap second, but always remains < 2 * 10^9.
s is always >= 0 and < 60, even when second 60 is used during construction. In other words, second 60 is represented via ns field.
val make :
?tz:Time_zone.t ->
?ns:int ->
?frac:float ->
year:int ->
month:month ->
day:int ->
hour:int ->
minute:int ->
second:int ->
unit ->
t optionConstructs a date time providing only a time zone (defaults to local time zone).
Nanosecond used is the addition of ns and frac * number of nanoseconds in one second.
A precise offset is inferred if possible.
Note that this may yield a ambiguous date time if the time zone has varying offsets, e.g. DST.
See make_unambiguous for the more precise construction.
Leap second can be specified by providing 60 for second. Note that leap second informtation is lost upon translation to timestamp(s), specifically second 60 is treated as second 59.
val make_exn :
?tz:Time_zone.t ->
?ns:int ->
?frac:float ->
year:int ->
month:month ->
day:int ->
hour:int ->
minute:int ->
second:int ->
unit ->
tval make_unambiguous :
?tz:Time_zone.t ->
?ns:int ->
?frac:float ->
year:int ->
month:month ->
day:int ->
hour:int ->
minute:int ->
second:int ->
tz_offset:Duration.t ->
unit ->
t optionConstructs a date time providing time zone offset in seconds, and optionally a time zone.
Nanosecond used is the addition of ns and frac * number of nanoseconds in one second.
If a time zone is provided, then the offset is checked against the time zone record to make sure the time zone does use said offset for the particular date time..
Same leap second handling and error handling as make.
val make_unambiguous_exn :
?tz:Time_zone.t ->
?ns:int ->
?frac:float ->
year:int ->
month:month ->
day:int ->
hour:int ->
minute:int ->
second:int ->
tz_offset:Duration.t ->
unit ->
tResult for when a local date time may be involved, e.g. using a date time with no precise time zone offset attached.
`Singleis yielded when the date time maps to exactly one'a. This happens when date time carries an accurate offset, or when the date time is not affected by any offset shifts (thus an accurate offset can be inferred).`Ambiguousis yielded when date time maps to more than one (exactly two)'a. This happens when DST ends and "goes back an hour" for instance.
to_timestamp loses information about leap second
Pretty printing for date time.
Default format string:
{year} {mon:Xxx} {day:0X} {hour:0X}:{min:0X}:{sec:0X} \
{tzoff-sign}{tzoff-hour:0X}:{tzoff-min:0X}:{tzoff-sec:0X}Format string specification:
{{ literal {
{year} year
{mon:Xxx} abbreviated month name (e.g. Jan), casing of 'x' controls the casing
{mon:Xx*} full month name (e.g. January), casing of first 'x' controls casing of first letter,
casing of second 'x' controls casing of following letters
{mon:cX} month in number form (e.g. 01) character 'c' before 'X' is used for padding
(leave out character for no padding)
{day:cX} month day (e.g. 1) character 'c' before 'X' is used for padding
(leave out character for no padding)
{wday:Xxx} abbreviated weekday name (e.g. Sun), the casing of 'x' controls the casing
{wday:Xx*} full weekday name (e.g. Sunday), casing of first 'x' controls casing of first letter,
casing of second 'x' controls casing of following letters
{hour:cX} hour in 24-hour format, character 'c' before 'X' determines padding
(leave out character for no padding)
{12hour:cX} hour in 12-hour format, character 'c' before 'X' determines padding
(leave out character for no padding)
{min:cX} minute, character 'c' before 'X' determines padding
(leave out character for no padding)
{sec:cX} second, character 'c' before 'X' determines padding
(leave out character for no padding)
{ns} nanosecond
{sec-frac:N} fraction of second (only digits)
N determines the number of digits to take after decimal point
result is rounded to closest fraction of said precision
{tzoff-sign} time zone offset sign ('+' or '-')
raises Date_time_cannot_deduce_tz_offset_s if time zone offset cannot be calculated
{tzoff-hour:cX} time zone offset hour, follows same padding rule as "{hour:cX}"
raises Date_time_cannot_deduce_tz_offset_s if time zone offset cannot be calculated
{tzoff-min:cX} time zone offset minute, follows same padding rule as "{min:cX}"
raises Date_time_cannot_deduce_tz_offset_s if time zone offset cannot be calculated
{tzoff-sec:cX} time zone offset second, follows same padding rule as "{sec:cX}"
raises Date_time_cannot_deduce_tz_offset_s if time zone offset cannot be calculatedString conversion using pp.
Returns None instead of raising exception when time zone offset cannot be deduced but required by the format string
frac_s defaults to as many digits as required for a lossless representation.
String conversion using pp_rfc3339.
Returns None if time zone offset cannot be deduced instead of raising exception.
Parses a subset of ISO8601, up to 9 fractional digits for second (nanosecond precision).
If more than 9 fractional digits are provided, then only the first 9 digits are used, i.e. no rounding.