Closed randomgambit closed 4 years ago
as.hms()
is deprecated in favor of as_hms()
, which no longer has a tz
argument: https://hms.tidyverse.org/reference/Deprecated.html.
Does with_tz()
give the results you expect?
library(tidyverse)
library(hms)
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:hms':
#>
#> hms
#> The following object is masked from 'package:base':
#>
#> date
tibble(gmt_time = c("2016-07-08 15:30:10"), value = c(1)) %>%
mutate(
gmt_time = ymd_hms(gmt_time),
est_time = with_tz(gmt_time, tz = "US/Eastern"),
mytz = tz(gmt_time),
myhour_utc_no = as_hms(gmt_time),
myhour_est_no = as_hms(est_time),
myhour_utc = as_hms(with_tz(gmt_time, "UTC")),
myhour_est = as_hms(with_tz(est_time, "US/Eastern"))
) %>%
glimpse()
#> Rows: 1
#> Columns: 8
#> $ gmt_time <dttm> 2016-07-08 15:30:10
#> $ value <dbl> 1
#> $ est_time <dttm> 2016-07-08 11:30:10
#> $ mytz <chr> "UTC"
#> $ myhour_utc_no <time> 15:30:10
#> $ myhour_est_no <time> 11:30:10
#> $ myhour_utc <time> 15:30:10
#> $ myhour_est <time> 11:30:10
Created on 2019-12-31 by the reprex package (v0.3.0)
Great. That is much less error prone
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.
Hello there
Consider this simple example with
hms_0.4.2
The current documentation says that
So I am surprised that
myhour_utc_no
is actually wrong and returns the time in my local timezone ('US/Eastern'
). Am I missing something here?Thanks!