Skip to content
Prev 1406 / 15274 Next

ISO-8601 with time zone designator, format handling with fCalendar/chron

Try this:

library(chron)
x <- "2005-12-05T00:00:00+02:00"
datetime <- chron(as.Date(x), substring(x, 12, 19))
sgn <- switch(substring(x, 20, 20), "+" = +1, "-" = -1)
offset <- as.numeric(times(paste(substring(x, 21), "00", sep = ":")))
datetime + sgn * offset

# or perhaps the last line should be:
datetime - sgn * offset
On 5/31/07, jeam <eraslan.cem at gmail.com> wrote: