cToPOSIXct {RcppBDT}R Documentation

Parse POSIXct objects from character variables

Description

This function uses Rcpp to parse datetimes from strings. It returns a vector of POSIXct objects. These represent dates and time as (possibly fractional) seconds since the ‘epoch’ of January 1, 1970. A timezone can be set, if none is supplied ‘UTC’ is set.

Usage

cToPOSIXct(sv, fmt = "%Y-%m-%d %H:%M:%OS", tz = "UTC")

Arguments

sv

A vector of type character with datetime expressions in ISO format to be parsed and converted.

fmt

A format, defaults to the ISO format if unset

tz

A string with the timezone, defaults to ‘UTC’ if unset

Details

The default standard ISO format ‘YYYY-MM-DD HH:MM:SS.FFFFFFF’ is is used by default along with the UTC time zone.

This function is for comparison only.

Value

A vector of ‘POSIXct’ elements.

Author(s)

Dirk Eddelbuettel

See Also

Rcpp

Examples

times <- c("2004-03-21 12:45:33.123456",
          "2004-03-21 12:45:34")
cToPOSIXct(times)

[Package RcppBDT version 0.2.6 Index]