mode_tz | R Documentation |
'mode_tz()' gets the most common time zone in the datetime object. If a tie we use the time zone used first. Intended for use when coercing from a datetime object that supports multiple heterogeneous time zones to a datetime object that only supports one time zone
mode_tz(x, ...)
## S3 method for class 'datetimeoffset'
mode_tz(x, tz = "", ...)
## Default S3 method:
mode_tz(x, ...)
x |
A datetime object. |
... |
Ignored |
tz |
A timezone string to use for missing time zones.
"" will be treated as equivalent to |
Timezone string
dt <- as_datetimeoffset(Sys.time())
print(mode_tz(dt))
if (all(c("America/Los_Angeles", "America/New_York") %in% OlsonNames())) {
dt <- as_datetimeoffset("2020-01-01",
tz = c("America/Los_Angeles", "America/New_York"))
print(mode_tz(dt))
print(Sys.timezone()) # timezone to be used for missing time zones
dt <- as_datetimeoffset("2020-01-01",
tz = c("America/New_York", NA_character_, NA_character_))
print(mode_tz(dt))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.