Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning when two different timezones are joined #3059

Closed
danielsjf opened this issue Aug 28, 2017 · 3 comments
Closed

Add warning when two different timezones are joined #3059

danielsjf opened this issue Aug 28, 2017 · 3 comments
Labels
feature a feature request or enhancement

Comments

@danielsjf
Copy link

This relates to this issue: #2643

The decision was taken to convert to UTC when two different posixct columns are joined. Indeed, the timezone is often only used for presentation, but some functions such as lubridate::year() work on the current timezone. Therefore such a decision could have an impact.

There is a warning if factors and characters are joined. It would be convenient to have a similar warning if the timezones don't match.

library(tidyverse)
#> Loading tidyverse: ggplot2
#> Loading tidyverse: tibble
#> Loading tidyverse: tidyr
#> Loading tidyverse: readr
#> Loading tidyverse: purrr
#> Loading tidyverse: dplyr
#> Conflicts with tidy packages ----------------------------------------------
#> filter(): dplyr, stats
#> lag():    dplyr, stats

tib_cet <- tibble(date = ISOdate(2016,1,1,0:2, tz = 'CET'), val_cet = runif(3))
tib_eet <- tibble(date = ISOdate(2016,1,1,0:2, tz = 'EET'), val_cet = runif(3))
tib_utc <- tibble(date = ISOdate(2016,1,1,0:2, tz = 'UTC'), val_utc = runif(3))

lubridate::year(tib_cet$date)
#> [1] 2016 2016 2016
lubridate::year(tib_eet$date)
#> [1] 2016 2016 2016
lubridate::year(tib_utc$date)
#> [1] 2016 2016 2016

tib_join <- left_join(tib_cet, tib_utc, by = 'date')
lubridate::year(tib_join$date) # UTC is the convention but I would assume that the convention is on the left table
#> [1] 2015 2016 2016

tib_join <- left_join(tib_cet, tib_eet, by = 'date')
lubridate::year(tib_join$date) # This is even stranger since the UTC assumption is used in neither of the two tables
#> [1] 2015 2016 2016

Such issues go unnoticed. Certainly since I would assume that the timezone of the left hand table would be dominant.

@hadley hadley added data frame feature a feature request or enhancement labels Nov 2, 2017
@romainfrancois
Copy link
Member

Related to #2432

@hadley
Copy link
Member

hadley commented May 11, 2018

The timezone only affects printing so I think a warning would be too much. Regardless, I think we'll tackle systematically as part of #2432.

@hadley hadley closed this as completed May 11, 2018
@lock
Copy link

lock bot commented Nov 7, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Nov 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants