Closed thibautjombart closed 5 years ago
- inconsistent handling of future date depending on whether they are
character
orDate
Good catch! Sending a Date vector to the function is a bit weird behavior and the function should just return a Date in the case of Date or POSIXt.
- future dates should be allowed if people want them; can we have an argument
allow_future
defaulting toFALSE
, which will set dates in the future toNA
, and otherwise process them the same way as other dates?
Agreed that future dates should be set to NA instead of being processed. I don't think allow_future
is necessary considering that the last_date
argument can be set to one year from now: last_date = Sys.Date() + 365
.
Addendum: future dates are indeed set to NA when the number of errors are within the tolerance level.
# returns character
suppressWarnings(linelist::guess_dates("2019-09-10"))
#> [1] "2019-09-10"
# returns NA Date
suppressWarnings(linelist::guess_dates("2019-09-10", error_tol = 1))
#> [1] NA
# returns Date
linelist::guess_dates("2019-09-10", error_tol = 1, last_date = "2020-01-01")
#> [1] "2019-09-10"
Created on 2019-04-05 by the reprex package (v0.2.1)
There are two issues here:
character
orDate
(see below; theDate
case in particular gives a cryptic messageallow_future
defaulting toFALSE
, which will set dates in the future toNA
, and otherwise process them the same way as other dates?