Closed TylerGrantSmith closed 3 years ago
First of all, thanks for your efforts to find the root of the problem.
Would you be so kind to explicitly assign the timezone to the POSIXt variables in your examples. I cannot reproduce the first error and I think it is because the default timezone on my system is different from yours, with a different moment of going into dst. Thanks!
Sorry about that!
cross_dst <- data.frame(day = as.POSIXct(c('2020-03-08', '2020-03-09'),
'America/Chicago'))
# errors with "day"
padr::pad(cross_dst, interval = "day")
#> Error: The specified interval is invalid for the datetime variable.
#> Not all original observation are in the padding.
#> If you want to pad at this interval, aggregate the data first with thicken.
# different error when not specified
padr::pad(cross_dst)
#> Error in seq.int(0, to0 - from, by): invalid '(to - from)/by'
Created on 2020-09-18 by the reprex package (v0.3.0)
Now I can indeed reproduce, thanks. Will look into it when time allows.
Did some more digging, problem occurs at weeks also
cross_week = data.frame(day = as.POSIXct(c('2020-03-08', '2020-03-22'),
'America/Chicago'))
padr::pad(cross_week, interval = "week")
Fixed it, thanks again for your help!
It seems there are a few different problems that lead to
POSIXt
vectors not being handled well bypad
when the dates cross a daylight savings bounary.Created on 2020-09-17 by the reprex package (v0.3.0)
In the first case, the issue is traced to
The second issue is traced to
padr:::convert_int_to_hours
which doesn't acceptDSTday
and highlights a disagreement in the documentation forpadr::pad
which says about theinterval
parameter:which is not the case (as contradicted in the Details).
The function
padr:::get_return_rows
is actually problematic in both cases, because thediffs
produced in this case is "23 hours".