tidyverse / lubridate

Make working with dates in R just that little bit easier
https://lubridate.tidyverse.org
GNU General Public License v3.0
724 stars 207 forks source link

dst returns NA when time is between 02:00:01 and 02:59:59 #1126

Closed drdull closed 1 year ago

drdull commented 1 year ago

Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on https://stackoverflow.com/ or https://community.rstudio.com/.

Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.

Brief description of the problem It seems that the dst function returns an NA when the input time is between 02:00:01 and 02:59:59

``` r
library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union
date <- as.POSIXlt("2002-04-07 02:01:00", format="%Y-%m-%d %H:%M:%S", tz="America/Detroit")
date
#> [1] "2002-04-07 02:01:00"
dst(date)
#> [1] NA
date <- as.POSIXlt("2002-04-07 03:01:00", format="%Y-%m-%d %H:%M:%S", tz="America/Detroit")
date
#> [1] "2002-04-07 03:01:00 EDT"
dst(date)
#> [1] TRUE

Created on 2023-07-22 with reprex v2.0.2

Nova-Scotia commented 1 year ago

I've run into this many times.

If you consult google (here's an example website) you'll see that because of daylight savings time, 2:01 AM on April 4 2002 did not exist because the clocks went forward to 3 AM on that date. So, lubridate returns NA because there was no 2:01 AM that day. Fun times!

drdull commented 1 year ago

Ah! Fun times, indeed! Reminds me of an English film I saw many, many years ago in which the hero (Dirk Bogarde??) was a passenger on an ocean liner traveling across times zones. Normally he was a shy person, but when the ship’s clocks changed effectively making an hour disappear (it did not exist) he was transformed into a gregarious bon vivant.

Thank you for the explanation.

From: Nova-Scotia @.> Reply-To: tidyverse/lubridate @.> Date: Wednesday, July 26, 2023 at 11:05 To: tidyverse/lubridate @.> Cc: "Lesht, Barry M" @.>, Author @.***> Subject: Re: [tidyverse/lubridate] dst returns NA when time is between 02:00:01 and 02:59:59 (Issue #1126)

[External: Use caution with links & attachments]

I've run into this many times.

If you consult google (here's an example websitehttps://urldefense.us/v3/__https:/www.timeanddate.com/time/change/usa?year=2002__;!!JRQnnSFuzw7wjAKq6ti6!2dSbL5iPCSdMYqhgBgFeTvUWLHTyf7DySxxq9GuEum8sSaUOTcu44HimMmOabk2YaTjWVdEgpa9C_2SVdK1Gutz1$) you'll see that because of daylight savings time, 2:01 AM on April 4 2002 did not exist because the clocks went forward to 3 AM on that date. So, lubridate returns NA because there was no 2:01 AM that day. Fun times!

— Reply to this email directly, view it on GitHubhttps://urldefense.us/v3/__https:/github.com/tidyverse/lubridate/issues/1126*issuecomment-1652110087__;Iw!!JRQnnSFuzw7wjAKq6ti6!2dSbL5iPCSdMYqhgBgFeTvUWLHTyf7DySxxq9GuEum8sSaUOTcu44HimMmOabk2YaTjWVdEgpa9C_2SVdLBTQu9Q$, or unsubscribehttps://urldefense.us/v3/__https:/github.com/notifications/unsubscribe-auth/BBOCVJWGXD3ZNRHBUDIBF6TXSE53BANCNFSM6AAAAAA2T3UBMY__;!!JRQnnSFuzw7wjAKq6ti6!2dSbL5iPCSdMYqhgBgFeTvUWLHTyf7DySxxq9GuEum8sSaUOTcu44HimMmOabk2YaTjWVdEgpa9C_2SVdCabuy9x$. You are receiving this because you authored the thread.Message ID: @.***>

Nova-Scotia commented 1 year ago

Maybe the best response I've gotten to a comment on gitHub. ha! Want to close the issue? ;)