iso8601_read | R Documentation |
Read ISO 8601 strings into POSIXct, POSIXt.
iso8601_read(x, tz.name = NULL)
x |
(character) A vector of ISO 8601 strings created with 'iso8601_convert'. Vector contents must be one of dates and times, dates, or times. A mix of more than one type is not supported. A mix of input temporal resolution is supported for date and time data. |
tz.name |
(character) Time zone name used to override parsing of time zone offset listed in 'x'. See 'OlsonNames()' for valid options. |
'iso8601_read' provides a lightweight option for reading ISO 8601 strings created with 'iso8601_convert' into the POSIXct POXIXt class. This function uses regular expressions to extract the orders and time zone offset arguments and passess this info to 'lubridate::parse_date_time' for parsing.
Time zone offsets are parsed "as is", i.e. using Olson Names that do not recognize Day Light Savings time. For example a time zone offset of "+06" is parsed using the Olson Name "Etc/GMT-6". Date times without a time zone offset default to "UTC". Use the argument 'tz.name' to override the input data time zone.
(POSIXct, POSIXt) A vector of POSIXct POSIXt, unless the format is 'YYYY', in which case integer class data is returned.
# Time zone are automatically parsed datetimes <- iso8601_read('2012-05-01T13:23:00+05') attributes(datetimes) # Time zone defaults to 'UTC' when none is specified iso8601_read('2012-05-01T13:23:00') # Vairance of input temporal resolution is supported iso8601_read(c('2012-05-01T13:45:23+05', '2012-05-01T13:45+05', '2012-05-01T13+05')) # tz.name overrides input time zone iso8601_read('2012-05-01T13:45+09:30', tz.name = 'Etc/GMT+4') ## Not run: # Multiple time zones are not yet supported iso8601_read(c('2012-05-01T13-05', '2012-05-01T13-06')) iso8601_read(c('2012-05-01T13-05', '2012-05-01T13')) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.