package timedesc

  1. Overview
  2. Docs

Module Timedesc.TimestampSource

Timestamp specific functions

Constants

Sourceval min_val : t
Sourceval max_val : t

Now

Sourceval now : unit -> t

Re-export from Span

Conversion

Sourceval to_s_ns : t -> int64 * int
Sourceval to_float_s : t -> float

Returns span in seconds, fraction represents subsecond span.

Representation is the same as result from Unix.gettimeofday.

Sourceval of_float_s : float -> t

Convert from span in seconds, fraction represents subsecond span

Representation is the same as result from Unix.gettimeofday.

Accessors

Sourceval get_s : t -> int64
Sourceval get_ns_offset : t -> int

Comparison

Sourceval equal : t -> t -> bool
Sourceval lt : t -> t -> bool
Sourceval le : t -> t -> bool
Sourceval gt : t -> t -> bool
Sourceval ge : t -> t -> bool
Sourceval compare : t -> t -> int

Arithmetic

Sourceval add : t -> t -> t
Sourceval sub : t -> t -> t
Sourceval succ : t -> t
Sourceval pred : t -> t
Sourceval neg : t -> t
Sourceval abs : t -> t
Sourceval max : t -> t -> t
Sourceval min : t -> t -> t
Sourceval ceil : t -> t
Sourceval floor : t -> t
Sourceval round : t -> t
Sourceval (<) : t -> t -> bool
Sourceval (<=) : t -> t -> bool
Sourceval (>) : t -> t -> bool
Sourceval (>=) : t -> t -> bool
Sourceval (=) : t -> t -> bool
Sourceval (<>) : t -> t -> bool
Sourceval (-) : t -> t -> t
Sourceval (+) : t -> t -> t

Pretty printing

Sourceval pp : ?display_using_tz:Time_zone.t -> ?format:string -> unit -> Format.formatter -> t -> unit

Pretty printing for timestamp.

Follows same format string rules and default format string as pp.

Sourceval to_string : ?display_using_tz:Time_zone.t -> ?format:string -> timestamp -> string
Sourceval pp_rfc3339 : ?frac_s:int -> unit -> Format.formatter -> t -> unit

Pretty prints according to RFC3339, e.g. 2020-01-20T13:00:00.0001+10.

frac_s determines the number of fractional digits to include.

Sourceval pp_rfc3339_milli : Format.formatter -> t -> unit
Sourceval pp_rfc3339_micro : Format.formatter -> t -> unit
Sourceval pp_rfc3339_nano : Format.formatter -> t -> unit
Sourceval to_rfc3339 : ?frac_s:int -> t -> string
Sourceval to_rfc3339_milli : t -> string
Sourceval to_rfc3339_micro : t -> string
Sourceval to_rfc3339_nano : t -> string
Sourceval pp_iso8601 : ?frac_s:int -> unit -> Format.formatter -> t -> unit

Alias to pp_rfc3339

Sourceval pp_iso8601_milli : Format.formatter -> t -> unit
Sourceval pp_iso8601_micro : Format.formatter -> t -> unit
Sourceval pp_iso8601_nano : Format.formatter -> t -> unit
Sourceval to_iso8601 : ?frac_s:int -> t -> string

Alias to to_rfc3339

Sourceval to_iso8601_milli : t -> string
Sourceval to_iso8601_micro : t -> string
Sourceval to_iso8601_nano : t -> string
Sourceval pp_rfc9110 : Format.formatter -> t -> unit

Warning: Subsecond value is truncated

Sourceval to_rfc9110 : t -> string

Warning: Subsecond value is truncated

Sourceval pp_http : Format.formatter -> t -> unit

Alias to pp_rfc9110

Sourceval to_http : t -> string

Alias to to_rfc9110

Parsing

Sourceval of_iso8601 : string -> (t, string) result

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.

Sourceval of_iso8601_exn : string -> t
Sourceval of_rfc9110 : string -> (t, string) result
Sourceval of_rfc9110_exn : string -> t
Sourceval of_http : string -> (t, string) result

Alias to of_rfc9110

Sourceval of_http_exn : string -> t

Alias to of_rfc9110_exn

OCaml

Innovation. Community. Security.