get_utc_offsets() and set_utc_offsets() gets/sets UTC offset strings
Arguments
- x
A
datetimeoffset()object- sep
Separator between hour and minute offsets. Either ":" or "".
- value
Replace UTC offset string
Value
get_utc_offsets() returns a character string of UTC offset info.
set_utc_offsets() returns a datetime (whose UTC offset info has been set).
See also
get_hour_offset(), set_hour_offset(), get_minute_offset(), and set_minute_offset()
allow getting/setting the separate individual hour/minute offset components with integers.
fill_utc_offsets() fills any missing UTC offsets using non-missing time zones.
Examples
dt <- as_datetimeoffset("2020-01-01T01:01")
get_utc_offsets(dt)
#> [1] NA
dt <- set_utc_offsets(dt, "-07:00")
get_utc_offsets(dt)
#> [1] "-07:00"
dt <- set_utc_offsets(dt, "+0800")
get_utc_offsets(dt)
#> [1] "+08:00"
dt <- set_utc_offsets(dt, "+00")
get_utc_offsets(dt)
#> [1] "+00"
dt <- set_utc_offsets(dt, NA_character_)
get_utc_offsets(dt)
#> [1] NA