flat_posixt_date | R Documentation |
POSIXt
vector to a specific date or hourflat_posixt_*
functions adjust the date or time of a
POSIXt
vector to a specific date or hour, with
UTC
as the default timezone.
These functions are particularly useful for performing time arithmetic on
time objects that lack a date reference (e.g., hms
objects).
flat_posixt_date(x, base = as.Date("1970-01-01"), force_tz = TRUE, tz = "UTC")
flat_posixt_hour(x, base = hms::parse_hm("00:00"), force_tz = TRUE, tz = "UTC")
x |
A |
base |
A |
force_tz |
A |
tz |
A |
A posixt
vector.
Other utility functions:
change_date()
,
extract_seconds()
,
fix_hms()
,
get_last_week()
,
round_time()
as.POSIXct("2020-01-01 05:55:55", tz = "America/Sao_Paulo") |>
flat_posixt_date()
#> [1] "1970-01-01 05:55:55 UTC" # Expected
c(
as.POSIXct("2020-01-01 05:55:55", tz = "America/Sao_Paulo"),
as.POSIXct("2020-01-01 18:40:05", tz = "America/Sao_Paulo")
) |>
flat_posixt_date()
#> [1] "1970-01-01 05:55:55 UTC" "1970-01-01 18:40:05 UTC" # Expected
as.POSIXct("2020-01-01 05:55:55", tz = "America/Sao_Paulo") |>
flat_posixt_hour(base = hms::parse_hm("00:01"))
#> [1] "2020-01-01 00:01:00 UTC" # Expected
c(
as.POSIXct("2020-01-01 05:55:55", tz = "America/Sao_Paulo"),
as.POSIXct("2020-01-01 18:40:05", tz = "America/Sao_Paulo")
) |>
flat_posixt_hour(base = hms::parse_hm("00:01"))
#> [1] "2020-01-01 00:01:00 UTC" "2020-01-01 00:01:00 UTC" # Expected
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.