Datetime object with optional UTC offsets and/or timezones
Source:R/datetimeoffset.r
datetimeoffset.Rddatetimeoffset() creates a datetime with possible UTC offset object.
It can be used to represent datetimes with possible UTC offsets
(without necessarily any knowledge of the time zone).
Usage
datetimeoffset(
year = NA_integer_,
month = NA_integer_,
day = NA_integer_,
hour = NA_integer_,
minute = NA_integer_,
second = NA_integer_,
nanosecond = NA_integer_,
subsecond_digits = NA_integer_,
hour_offset = NA_integer_,
minute_offset = NA_integer_,
tz = NA_character_
)Arguments
- year
Year (integer, optional)
- month
Month (integer, optional)
- day
Day (integer, optional)
- hour
Hour (integer, optional)
- minute
Minute (integer, optional)
- second
Second (integer, optional)
- nanosecond
Nanosecond (integer, optional)
- subsecond_digits
Number of digits used by fractional seconds (integer, optional)
- hour_offset
UTC offset in hours (integer, optional)
- minute_offset
UTC offset in minutes (integer, optional). Will be coerced to a non-negative value.
- tz
Time zone (character, optional)
Examples
datetimeoffset(2020)
#> <datetimeoffset[1]>
#> [1] 2020
datetimeoffset(2020, 5)
#> <datetimeoffset[1]>
#> [1] 2020-05
datetimeoffset(2020, 5, 15)
#> <datetimeoffset[1]>
#> [1] 2020-05-15
datetimeoffset(2020, 5, 15, 8)
#> <datetimeoffset[1]>
#> [1] 2020-05-15T08
datetimeoffset(2020, 5, 15, 8, 23)
#> <datetimeoffset[1]>
#> [1] 2020-05-15T08:23
datetimeoffset(2020, 5, 15, 8, 23, 16) # local time with unknown timezone
#> <datetimeoffset[1]>
#> [1] 2020-05-15T08:23:16
if ("US/Pacific" %in% OlsonNames())
datetimeoffset(2020, 5, 15, 8, 23, 16, tz = "US/Pacific")
#> <datetimeoffset[1]>
#> [1] 2020-05-15T08:23:16-07:00[US/Pacific]
datetimeoffset(2020, 5, 15, 8, 23, 16, tz = "GMT")
#> <datetimeoffset[1]>
#> [1] 2020-05-15T08:23:16Z
datetimeoffset(2020, 5, 15, 8, 23, 16, hour_offset = -7)
#> <datetimeoffset[1]>
#> [1] 2020-05-15T08:23:16-07
datetimeoffset(2020, 5, 15, 8, 23, 16, hour_offset = -7, minute_offset = 30)
#> <datetimeoffset[1]>
#> [1] 2020-05-15T08:23:16-07:30