formatDatetime {RcppCCTZ}R Documentation

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.

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.

Value

A string vector with the requested format of the datetime objects

Note

Windows is now supported via the g++-4.9 compiler, but note that it provides an incomplete C++11 library. This means we had to port a time parsing routine, and that string formatting is more limited. As one example, CCTZ frequently uses "%F %T" which do not work on Windows; one has to use "%Y-%m-%d %H:%M:%S".

Author(s)

Dirk Eddelbuettel

Examples

## Not run: 
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

## End(Not run)

[Package RcppCCTZ version 0.2.12 Index]