Closed martinschlund closed 1 year ago
mdy_hm()
and dmy_hm()
fail the same way. For example,
> dmy_hm('02012023 12:08') # doesn't work anymore
[1] NA
Warning message:
All formats failed to parse. No formats found.
> dmy_hm('02-01-2023 12:08') # doesn't work anymore
[1] NA
Warning message:
All formats failed to parse. No formats found.
> dmy_hm('020120231208') # still works
[1] "2023-01-02 12:08:00 UTC"
> dmy_hm('02012023 1208') # also still works
[1] "2023-01-02 12:08:00 UTC"
> parse_date_time('02-01-2023 12:08', orders='dmy HM') # still works
[1] "2023-01-02 12:08:00 UTC"
> sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=nl_NL.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lubridate_1.9.0 timechange_0.1.1 arrow_10.0.1 data.table_1.14.6
loaded via a namespace (and not attached):
[1] ps_1.7.2 assertthat_0.2.1 R6_2.5.1 magrittr_2.0.3 rlang_1.0.6 cli_3.4.1 vctrs_0.5.1 generics_0.1.3 bit64_4.0.5
[10] glue_1.6.2 purrr_0.3.5 bit_4.0.5 compiler_4.2.0 tidyselect_1.2.0
I have been noticing this bug since the beginning of December and it is very serious in my case because I had to modify existing code of my project.
What I have discovered is that the only dates that ymd_hm()
parses well are those in which the hour and minutes are not separated:
> lubridate::ymd_hm("2023-01-19 2338")
[1] "2023-01-19 23:38:00 UTC"
> lubridate::ymd_hm("2023/01/19 2338")
[1] "2023-01-19 23:38:00 UTC"
> lubridate::ymd_hm("2023/01/192338")
[1] "2023-01-19 23:38:00 UTC"
> sessionInfo()
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale:
[1] LC_COLLATE=Spanish_Spain.utf8 LC_CTYPE=Spanish_Spain.utf8 LC_MONETARY=Spanish_Spain.utf8 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.2.2 generics_0.1.3 tools_4.2.2 lubridate_1.9.0 data.table_1.14.6 timechange_0.1.1
The bug is locale specific. Same as https://github.com/tidyverse/lubridate/issues/1097 and was fixed in devel at the end of November. A I am starting the release process.
In R version 4.2.2
ymd_hm()
is not working.Gives NA and a warning.
works fine though.
Sessioninfo: