tidyverse / lubridate

Make working with dates in R just that little bit easier
https://lubridate.tidyverse.org
GNU General Public License v3.0
724 stars 207 forks source link

warning in parse_date_time() when a locale is set #1141

Open alusiani opened 10 months ago

alusiani commented 10 months ago

If a locale is set, parse_date_time() issues warnings for any string.

Minimal reproducible example:

suppressMessages(library(lubridate))

rc = Sys.setlocale(category = "LC_TIME", locale = "it_IT")
print(as.Date(parse_date_time("30/04/2022", "dmY")))

Undue warnings appear:

[1] "2022-04-30 UTC"
Warning messages:
1: In strsplit(L, "@", fixed = TRUE) : input string 1 is invalid UTF-8
2: In strsplit(L, "@", fixed = TRUE) : input string 2 is invalid UTF-8
3: In strsplit(L, "@", fixed = TRUE) : input string 3 is invalid UTF-8
4: In strsplit(L, "@", fixed = TRUE) : input string 5 is invalid UTF-8
5: In strsplit(L, "@", fixed = TRUE) : input string 6 is invalid UTF-8

sessionInfo()

> sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Fedora Linux 38 (KDE Plasma)

Matrix products: default
BLAS/LAPACK: FlexiBLAS OPENBLAS-OPENMP;  LAPACK version 3.11.0

locale:
 [1] LC_CTYPE=en_IE.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=it_IT              LC_COLLATE=en_IE.UTF-8    
 [5] LC_MONETARY=en_IE.UTF-8    LC_MESSAGES=en_IE.UTF-8   
 [7] LC_PAPER=en_IE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_IE.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Rome
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lubridate_1.9.2 devtools_2.4.5  usethis_2.2.2  

loaded via a namespace (and not attached):
 [1] miniUI_0.1.1.1    compiler_4.3.1    crayon_1.5.2      promises_1.2.0.1 
 [5] Rcpp_1.0.11       stringr_1.5.0     callr_3.7.3       later_1.3.1      
 [9] fastmap_1.1.1     mime_0.12         R6_2.5.1          generics_0.1.3   
[13] htmlwidgets_1.6.2 profvis_0.3.8     shiny_1.7.4.1     rlang_1.1.1      
[17] cachem_1.0.8      stringi_1.7.12    httpuv_1.6.11     fs_1.6.3         
[21] pkgload_1.3.2.1   timechange_0.2.0  memoise_2.0.1     cli_3.6.1        
[25] magrittr_2.0.3    ps_1.7.5          digest_0.6.33     processx_3.8.2   
[29] xtable_1.8-4      remotes_2.4.2.1   lifecycle_1.0.3   prettyunits_1.1.1
[33] vctrs_0.6.3       glue_1.6.2        urlchecker_1.0.1  sessioninfo_1.2.2
[37] pkgbuild_1.4.2    purrr_1.0.1       tools_4.3.1       ellipsis_0.3.2   
[41] htmltools_0.5.5