msgpack_timestamp_encode: 'MsgPack' Timestamp

Description Usage Arguments Value Examples

View source: R/functions.r

Description

Encodes a timestamp to the 'MsgPack' specifications.

Usage

1
2
3
msgpack_timestamp_encode(posix = NULL, seconds = NULL, nanoseconds = NULL)

msgpackTimestampEncode(posix = NULL, seconds = NULL, nanoseconds = NULL)

Arguments

posix

A POSIXct or POSIXlt or anything that can be coerced to a numeric.

seconds

The number of seconds since 1970-01-01 00:00:00 UTC. Can be negative. Don't use seconds and nanoseconds if you use posix (and vice versa).

nanoseconds

The number of nanoseconds since 1970-01-01 00:00:00 UTC. Must be less than 1,000,000,000 and greater than 0.

Value

A serialized timestamp that can be used as input to msgpack_pack. Briefly, this is an extension type -1 that is variable length, depending on the desired range and precision.

Examples

1
2
3
4
5
mt <- Sys.time()
attr(mt, "tzone") <- "UTC"
mp <- msgpack_pack(msgpack_timestamp_encode(mt))
mtu <- msgpack_timestamp_decode(msgpack_unpack(mp))
identical(mt, mtu)

Example output

[1] TRUE

RcppMsgPack documentation built on May 2, 2019, 3:44 a.m.