RcppCCTZ (version 0.2.2)

formatDatetime: Format a Datetime vector as a string vector

Description

Format a Datetime vector

Usage

formatDatetime(dtv, fmt = "%Y-%m-%dT%H:%M:%E*S%Ez", lcltzstr = "UTC",
  tgttzstr = "UTC")

formatDouble(secv, nanov, fmt = "%Y-%m-%dT%H:%M:%E*S%Ez", tgttzstr = "UTC")

Arguments

dtv

A Datetime vector object to be formatted

fmt

A string with the format, which is based on strftime with some extensions; see the CCTZ documentation for details.

lcltzstr

The local timezone object for creation the CCTZ timepoint

tgttzstr

The target timezone for the desired format

secv

A numeric vector with seconds since the epoch

nanov

A numeric vector with nanoseconds since the epoch, complementing secv.

Value

A string vector with the requested format of the datetime objects

Details

An alternative to format.POSIXct based on the CCTZ library. The formatDouble variant uses two vectors for seconds since the epoch and fractional nanoseconds, respectively, to provide fuller resolution.

Examples

Run this code
now <- Sys.time()
formatDatetime(now)            # current (UTC) time, in full precision RFC3339
formatDatetime(now, tgttzstr="America/New_York")  # same but in NY
formatDatetime(now + 0:4)	   # vectorised

Run the code above in your browser using DataLab