Open raymondben opened 7 years ago
Hm. That's indeed odd. Thanks for catching this.
You are right, it's sort of an expected behavior :( You are also right that the parser is too liberal. I regretted making it as such many, many times so far. But well, now it's a bit too late. Fixing this one would almost surely break some more rare patterns.
The new stand-alone parser (which is slowly in the making) won't have this problem.
Minimal reprex:
library(lubridate, warn.conflicts = FALSE)
ymd_hms("2007-03-08 13:13")
#> [1] "2020-07-03 08:13:13 UTC"
ymd_hms("2007-03-08 1:13")
#> Warning: All formats failed to parse. No formats found.
#> [1] NA
Created on 2019-11-19 by the reprex package (v0.3.0)
ymd_hms("2007-03-08 13:13",truncated=1)
gives"2007-03-08 13:13:00 UTC"
, as expected.ymd_hms("2007-03-08 1:13")
givesNA
and warning, as expected. Butymd_hms("2007-03-08 13:13")
gives"2020-07-03 08:13:13 UTC"
without warning. It is using a "YYMM-DD-HH MM:SS" date format. Maybe this is expected behaviour, but allowing that liberal a date format (specifically "-" as a separator both within the date and between the DD and HH) seems likely to lead to parsing results that the user did not expect.(with lubridate_1.6.0 and lubridate_1.6.0.9009)