Learn R Programming

CFtime (version 1.3.0)

CFtimestamp: Create a vector that represents CF timestamps

Description

This function generates a vector of character strings or POSIXcts that represent the date and time in a selectable combination for each offset.

Usage

CFtimestamp(cf, format = NULL, asPOSIX = FALSE)

Value

A character vector where each element represents a moment in time according to the format specifier. Time zone information is not represented.

Arguments

cf

CFtime. The CFtime instance that contains the offsets to use.

format

character. An atomic string with either of the values "date" or "timestamp". If the argument is not specified, the format used is "timestamp" if there is time information, "date" otherwise.

asPOSIX

logical. If TRUE, for "standard", "gregorian" and "proleptic_gregorian" calendars the output is a vector of POSIXct - for other calendars the result is NULL. Default value is FALSE.

Details

The character strings use the format YYYY-MM-DDThh:mm:ss±hh:mm, depending on the format specifier. The date in the string is not necessarily compatible with POSIXt - in the 360_day calendar 2017-02-30 is valid and 2017-03-31 is not.

For the "standard", "gregorian" and "proleptic_gregorian" calendars the output can also be generated as a vector of POSIXct values by specifying asPOSIX = TRUE.

Examples

Run this code
cf <- CFtime("hours since 2020-01-01", "standard", seq(0, 24, by = 0.25))
CFtimestamp(cf, "timestamp")

cf2 <- CFtime("days since 2002-01-21", "standard", 0:20)
tail(CFtimestamp(cf2, asPOSIX = TRUE))

tail(CFtimestamp(cf2))

tail(CFtimestamp(cf2 + 1.5))

Run the code above in your browser using DataLab