from_datetimeoffset {datetimeoffset} | R Documentation |
Convert to other datetime objects
Description
We register S3 methods to convert datetimeoffset()
objects to
other R datetime objects:
Usage
## S3 method for class 'datetimeoffset'
as.Date(x, ...)
## S3 method for class 'datetimeoffset'
as.POSIXct(x, tz = mode_tz(x), ..., fill = "")
## S3 method for class 'datetimeoffset'
as_date_time(x, zone = mode_tz(x), ..., fill = NA_character_)
## S3 method for class 'datetimeoffset'
as.POSIXlt(x, tz = mode_tz(x), ..., fill = "")
## S3 method for class 'datetimeoffset'
as_year_quarter_day(x, ..., start = NULL)
## S3 method for class 'datetimeoffset'
as_zoned_time(
x,
zone = mode_tz(x),
...,
ambiguous = "error",
nonexistent = "error",
fill = NA_character_
)
Arguments
x |
A |
... |
Ignored |
tz , zone |
What time zone to assume |
fill |
If timezone and UTC offset info is missing what
timezone to assume. See |
start |
The month to start the fiscal year in.
See |
ambiguous |
What to do when the "clock time" in the new time zone is ambiguous.
See |
nonexistent |
What to do when the "clock time" in the new time zone doesn't exist.
See |
Details
We register S3 methods for the following:
-
as.Date()
andclock::as_date()
returns the "local" date as abase::Date()
object -
as.POSIXct()
andclock::as_date_time()
returns the "local" datetime as abase::POSIXct()
object -
as.POSIXlt()
returns the "local" datetime as abase::POSIXlt()
object -
nanotime::as.nanotime()
returns the "global" datetime as ananotime::nanotime()
object -
parttime::as.parttime()
returns the "local" datetime as aparttime::parttime()
object -
clock::as_year_month_day()
returns aclock::year_month_day()
calendar -
clock::as_year_month_weekday()
returns aclock::year_month_weekday()
calendar -
clock::as_iso_year_week_day()
returns aclock::iso_year_week_day()
calendar -
clock::as_year_quarter_day()
returns aclock::year_quarter_day()
calendar -
clock::as_year_day()
returns aclock::year_day()
calendar -
clock::as_naive_time()
returns a "clock" naive-time -
clock::as_sys_time()
returns a "clock" sys-time -
clock::as_zoned_time()
returns a "clock" zoned-time -
clock::as_weekday()
returns aclock::weekday()
object
Value
A datetime object vector
Examples
# {base}
today <- as_datetimeoffset(Sys.Date())
now <- as_datetimeoffset(Sys.time())
as.Date(today)
as.Date(now)
as.POSIXct(now)
as.POSIXlt(now)
# {clock}
clock::as_date(today)
clock::as_date_time(now)
clock::as_year_month_day(now)
clock::as_year_month_weekday(now)
clock::as_iso_year_week_day(now)
clock::as_year_quarter_day(now)
clock::as_year_day(now)
clock::as_naive_time(now)
clock::as_sys_time(now)
clock::as_zoned_time(now)
clock::as_weekday(now)
if (requireNamespace("nanotime")) {
nanotime::as.nanotime(now)
}
if (requireNamespace("parttime")) {
parttime::as.parttime(now)
}