Right now, the parsers use .mklt() which just sets the isdst field to -1L
> lubridate:::.mklt
function (dtlist, tz)
{
na_fill <- rep_len(NA_integer_, length(dtlist$sec))
dtlist[["wday"]] <- na_fill
dtlist[["yday"]] <- na_fill
dtlist[["isdst"]] <- -1L
.POSIXlt(dtlist, tz = tz)
}
This means that this field isn't recycled to the right length but all the others are:
library(lubridate, warn.conflicts = FALSE)
x <- c("68-05-17", "69-05-17", "55-05-17")
# `isdt` should be vectorized
unclass(fast_strptime(
x,
format = "%y-%m-%d",
tz = "UTC"
))
#> $sec
#> [1] 0 0 0
#>
#> $min
#> [1] 0 0 0
#>
#> $hour
#> [1] 0 0 0
#>
#> $mday
#> [1] 17 17 17
#>
#> $mon
#> [1] 4 4 4
#>
#> $year
#> [1] 168 69 155
#>
#> $wday
#> [1] NA NA NA
#>
#> $yday
#> [1] NA NA NA
#>
#> $isdst
#> [1] -1
#>
#> attr(,"tzone")
#> [1] "UTC"
# It is vectorized in strptime()
unclass(strptime(
x,
format = "%y-%m-%d",
tz = "UTC"
))
#> $sec
#> [1] 0 0 0
#>
#> $min
#> [1] 0 0 0
#>
#> $hour
#> [1] 0 0 0
#>
#> $mday
#> [1] 17 17 17
#>
#> $mon
#> [1] 4 4 4
#>
#> $year
#> [1] 168 69 155
#>
#> $wday
#> [1] 4 6 1
#>
#> $yday
#> [1] 137 136 136
#>
#> $isdst
#> [1] 0 0 0
#>
#> attr(,"tzone")
#> [1] "UTC"
This causes issues in vctrs with vec_slice():
library(lubridate, warn.conflicts = FALSE)
x <- c("68-05-17", "69-05-17", "55-05-17")
lt <- fast_strptime(
x,
format = "%y-%m-%d",
tz = "UTC"
)
# The lack of vectorization breaks vctrs subsetting
vctrs::vec_slice(lt, 1)
#> Error in `vctrs::vec_slice()`:
#> ! Column `isdst` (size 1) must match the data frame (size 3).
#> ℹ In file 'slice.c' at line 191.
#> ℹ This is an internal error in the rlang package, please report it to the
#> package authors.
I think it is reasonable to assume that this field should have been recycled to the length of the vector.
I'll do a PR
Right now, the parsers use
.mklt()which just sets theisdstfield to-1LThis means that this field isn't recycled to the right length but all the others are:
This causes issues in vctrs with
vec_slice():I think it is reasonable to assume that this field should have been recycled to the length of the vector.
I'll do a PR