iso_to_posix: Convert an ISO8601 date/time to POSIXct

View source: R/transforms_time.R

iso_to_posixR Documentation

Convert an ISO8601 date/time to POSIXct

Description

Convert an ISO8601 date/time to POSIXct

Usage

iso_to_posix(dtc, .time, .tz = "UTC", .day, .month)

Arguments

dtc

A ISO8601 formatted date/time

.time

If dtc is date-only, a time to use as an offset. If length is not 1 or same as dtc, .time is recycled with a warning.

.tz

The timezone for the dtc values. Default is UTC.

.day

If dtc is year-month only, a month to use a default. If length is not 1 or same as dtc, .time is recycled with a warning.

.month

If dtc is year only, a month to use a default. If length is not 1 or same as dtc, .time is recycled with a warning.

Details

The conversion does its best to guess at the format of the time and to fill in any missing parts, defaulting to Jan, the first of the month, and midnight. The default day, month, and time can be provided, but it's important to note that the infill of these values won't cross more than one division. That is, "1990" will default to "1990-01-01 00:00", even if .time is given as 06:35. The missing pieces must be filled in in order.

Value

date/time as R POSIXct native type.

Examples

iso_to_posix("2016-10-03T21:22:45")
iso_to_posix(c("2016-10-03","2016-10-03T12:34"),"09:00")
iso_to_posix(c("2016-10-03","2016-10-03","2016-10-03"), c("09:00", "10:10")) #gives a warning about length of .times
iso_to_posix(c("1980", "1980-06", "1980-06-15"), .time="09:34")
iso_to_posix(c("1980", "1980-06", "1980-06-15"), .time="09:34", .day=15, .month=6)

qPharmetra/PMDatR documentation built on April 7, 2024, 5:42 p.m.