View Source jhn_timestamp (jhn_stdlib v5.1.0)
A timestamp library based on: Date and Time on the Internet: Timestamps (rfc3339) Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content (rfc7231)
The timestamp is represented as follows:
posix : integer()
stamp : #{year => integer(), month => integer(), day => integer(), hour => integer(), minute => integer(), second => integer(), fraction => integer(), offset => Offset } Offset : 'Z' | #{sign => '+' | '-', hours => integer(), minutes => integer()}
The fraction and offset parts are optional
Summary
Functions
Decodes the binary or posix integer timestamp into a map representing a timestamp. Equivalent of decode(Binary, [])
Decodes the binary or posix integer timestamp into a map representing a timestamp. Decode will give an exception if the binary is not well formed timestamp. Options are: seconds (default) -> second precision milli -> milli second precision micro -> micro second precision nano -> nano second precision rfc7231 -> the binary is a rfc7231 compatible continue -> all remaining indata is returned when decoding a binary
Encodes the map as an iolist. Equivalent of encode(Stamp, [])
Encodes the Stamp as an iolist or binary. Encode will give an exception if the Stamp is not well formed. Options are: seconds (default) -> second precision (no fraction generated) milli -> milli second precision micro -> micro second precision nano -> nano second precision binary -> a binary is returned list -> a flat list is returned iolist -> an iolist is returned rfc7231 -> the returned string is rfc7231 compatible posix -> a posix integer timestamp is returned
Generates the timestamp as an iolist of precision seconds Equivalent of gen([])
Generates a timestamp and encode as an iolist, list, binary, or integer posix timestamp. Options are: seconds (default) -> second precision milli -> milli second precision micro -> micro second precision nano -> nano second precision binary -> a binary is returned list -> a flat list is returned iolist (default) -> an iolist is returned rfc7231 -> the returned string is rfc7231 compatible, and precision is seconds, e.g., posix -> a posix integer timestamp is returned
Types
Functions
Decodes the binary or posix integer timestamp into a map representing a timestamp. Equivalent of decode(Binary, [])
-spec decode(binary() | posix(), [opt()] | #opts{precision :: seconds | milli | micro | nano, continue :: boolean(), rfc7231 :: boolean(), return_type :: iolist | binary | list | posix}) -> stamp() | {stamp(), binary()}.
Decodes the binary or posix integer timestamp into a map representing a timestamp. Decode will give an exception if the binary is not well formed timestamp. Options are: seconds (default) -> second precision milli -> milli second precision micro -> micro second precision nano -> nano second precision rfc7231 -> the binary is a rfc7231 compatible continue -> all remaining indata is returned when decoding a binary
Encodes the map as an iolist. Equivalent of encode(Stamp, [])
-spec encode(stamp() | posix(), [opt()] | #opts{precision :: seconds | milli | micro | nano, continue :: boolean(), rfc7231 :: boolean(), return_type :: iolist | binary | list | posix}) -> iolist() | binary() | list() | posix().
Encodes the Stamp as an iolist or binary. Encode will give an exception if the Stamp is not well formed. Options are: seconds (default) -> second precision (no fraction generated) milli -> milli second precision micro -> micro second precision nano -> nano second precision binary -> a binary is returned list -> a flat list is returned iolist -> an iolist is returned rfc7231 -> the returned string is rfc7231 compatible posix -> a posix integer timestamp is returned
-spec gen() -> iolist().
Generates the timestamp as an iolist of precision seconds Equivalent of gen([])
-spec gen([opt()] | #opts{precision :: seconds | milli | micro | nano, continue :: boolean(), rfc7231 :: boolean(), return_type :: iolist | binary | list | posix}) -> list() | iolist() | binary() | posix().
Generates a timestamp and encode as an iolist, list, binary, or integer posix timestamp. Options are: seconds (default) -> second precision milli -> milli second precision micro -> micro second precision nano -> nano second precision binary -> a binary is returned list -> a flat list is returned iolist (default) -> an iolist is returned rfc7231 -> the returned string is rfc7231 compatible, and precision is seconds, e.g., posix -> a posix integer timestamp is returned