vspinu / timechange

Efficient Updating of Date-Times
GNU General Public License v3.0
30 stars 3 forks source link

C_force_tz gives NA #30

Open FlorianSchwendinger opened 8 months ago

FlorianSchwendinger commented 8 months ago

We found the following iteresting case.

library("timechange")

tz <- "US/Eastern"
roll_dst <- c("NA", "post")

dt1 <- as.POSIXct("2024-03-10 02:00:00", tz = "UTC")
dt2 <- as.POSIXct("2023-03-10 02:00:00", tz = "UTC")
timechange:::C_force_tz(dt1, tz, roll_dst)
#R> NA
timechange:::C_force_tz(dt2, tz, roll_dst)
#R "2023-03-10 02:00:00 EST"

with

> sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 12 (bookworm)

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.11.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.11.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] timechange_0.3.0

loaded via a namespace (and not attached):
[1] compiler_4.3.1
r2evans commented 8 months ago

@FlorianSchwendinger , can you confirm the underlying OS package version? I'm on ubuntu-23.10 and discovered that the /usr/share/zoneinfo/US/* symlinks were excluded in the most recent tzdata package (https://github.com/vspinu/timechange/issues/31#issuecomment-2003942790), can you confirm that this is the case for you as well?

FlorianSchwendinger commented 7 months ago

Sorry for the late reply. I am using Debian GNU/Linux 12 (bookworm) at /usr/share/zoneinfo/US I see

total 0
lrwxrwxrwx 1 root root 20 Feb  3 19:56 Alaska -> ../America/Anchorage
lrwxrwxrwx 1 root root 15 Feb  3 19:56 Aleutian -> ../America/Adak
lrwxrwxrwx 1 root root 18 Feb  3 19:56 Arizona -> ../America/Phoenix
lrwxrwxrwx 1 root root 18 Feb  3 19:56 Central -> ../America/Chicago
lrwxrwxrwx 1 root root 19 Feb  3 19:56 Eastern -> ../America/New_York
lrwxrwxrwx 1 root root 31 Feb  3 19:56 East-Indiana -> ../America/Indiana/Indianapolis
lrwxrwxrwx 1 root root 19 Feb  3 19:56 Hawaii -> ../Pacific/Honolulu
lrwxrwxrwx 1 root root 23 Feb  3 19:56 Indiana-Starke -> ../America/Indiana/Knox
lrwxrwxrwx 1 root root 18 Feb  3 19:56 Michigan -> ../America/Detroit
lrwxrwxrwx 1 root root 17 Feb  3 19:56 Mountain -> ../America/Denver
lrwxrwxrwx 1 root root 22 Feb  3 19:56 Pacific -> ../America/Los_Angeles
lrwxrwxrwx 1 root root 20 Feb  3 19:56 Samoa -> ../Pacific/Pago_Pago
FlorianSchwendinger commented 3 months ago

As far I see this issue is related to daylight saving time since

  1. Mär 2024 - Daylight Saving Time Started When local standard time was about to reach Sonntag, 10. März 2024, 02:00:00 clocks were turned forward 1 hour to Sonntag, 10. März 2024, 03:00:00 local daylight time instead. so the values between 02:00:00 to 02:59:59 should not exist in local time.