time-zones | R Documentation |
time_at_tz
returns a date-time as it would appear in a
different time zone. The actual moment of time measured does not change,
just the time zone it is measured in. time_at_tz
defaults to the
Universal Coordinated time zone (UTC) when an unrecognized time zone is
supplied.
time_force_tz
returns the date-time that has the same clock
time as input time, but in the new time zone. Although the new date-time
has the same clock time (e.g. the same values in the seconds, minutes,
hours, etc.) it is a different moment of time than the input
date-time. Computation is vectorized over both time
and tz
arguments.
time_clock_at_tz
retrieves day clock time in specified time
zones. Computation is vectorized over both dt
and tz
arguments, tz
defaults to the timezone of time
.
time_at_tz(time, tz = "UTC")
time_force_tz(
time,
tz = "UTC",
tzout = tz[[1]],
roll_dst = c("boundary", "post")
)
time_clock_at_tz(time, tz = NULL, units = "secs")
time |
a date-time object (POSIXct, POSIXlt, Date) or a list of date-time objects. When a list, all contained elements are updated the new list is returned. |
tz |
a character string containing the time zone to convert to. R must
recognize the name contained in the string as a time zone on your
system. For |
tzout |
timezone of the output date-time vector. Meaningful only when
|
roll_dst |
same as in |
units |
passed directly to |
a POSIXct object with the updated time zone
x <- as.POSIXct("2009-08-07 00:00:00", tz = "America/New_York")
time_at_tz(x, "UTC")
time_force_tz(x, "UTC")
time_force_tz(x, "Europe/Amsterdam")
## DST skip:
y <- as.POSIXct("2010-03-14 02:05:05", tz = "UTC")
time_force_tz(y, "America/New_York", roll = "boundary")
time_force_tz(y, "America/New_York", roll = "post")
time_force_tz(y, "America/New_York", roll = "pre")
time_force_tz(y, "America/New_York", roll = "NA")
## DST skipped and repeated
y <- as.POSIXct(c("2010-03-14 02:05:05 UTC", "2014-11-02 01:35:00"), tz = "UTC")
time_force_tz(y, "America/New_York", roll_dst = c("NA", "pre"))
time_force_tz(y, "America/New_York", roll_dst = c("boundary", "post"))
## Heterogeneous time-zones:
x <- as.POSIXct(c("2009-08-07 00:00:01", "2009-08-07 01:02:03"), tz = "UTC")
time_force_tz(x, tz = c("America/New_York", "Europe/Amsterdam"))
time_force_tz(x, tz = c("America/New_York", "Europe/Amsterdam"), tzout = "America/New_York")
x <- as.POSIXct("2009-08-07 00:00:01", tz = "UTC")
time_force_tz(x, tz = c("America/New_York", "Europe/Amsterdam"))
## Local clock:
x <- as.POSIXct(c("2009-08-07 01:02:03", "2009-08-07 10:20:30"), tz = "UTC")
time_clock_at_tz(x, units = "secs")
time_clock_at_tz(x, units = "hours")
time_clock_at_tz(x, "Europe/Amsterdam")
x <- as.POSIXct("2009-08-07 01:02:03", tz = "UTC")
time_clock_at_tz(x, tz = c("America/New_York", "Europe/Amsterdam", "Asia/Shanghai"), unit = "hours")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.