Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse_date_time with format %B does not match abbreviated month names #529

Closed
billdenney opened this issue Mar 23, 2017 · 1 comment
Closed

Comments

@billdenney
Copy link
Contributor

billdenney commented Mar 23, 2017

parse_date_time with format %B does not match abbreviated month names while %b works as expected.

> parse_date_time("04JAN2016:07:40:00", "%d%B%Y:%H%:M:%S")
[1] NA
Warning message:
All formats failed to parse. No formats found. 
> parse_date_time("04JAN2016:07:40:00", "%d%b%Y:%H%:M:%S")
[1] "2016-01-04 07:40:00 UTC"

If important, this is on a Windows 10 system:

> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

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

other attached packages:
[1] lubridate_1.5.6 ggplot2_2.2.1   dplyr_0.5.0     rio_0.4.16     

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.8         cellranger_1.0.0    plyr_1.8.4          tools_3.3.2         digest_0.6.12       evaluate_0.10       jsonlite_1.2       
 [8] tibble_1.2          gtable_0.2.0        openxlsx_3.0.0      csvy_0.1.3          DBI_0.5             curl_2.1            yaml_2.1.13        
[15] haven_1.0.0         stringr_1.1.0       xml2_1.0.0          knitr_1.15          readODS_1.6.2       triebeard_0.3.0     rprojroot_1.1      
[22] grid_3.3.2          data.table_1.9.6    R6_2.1.3            readxl_0.1.1        foreign_0.8-67      rmarkdown_1.3       readr_1.0.0        
[29] magrittr_1.5        backports_1.0.4     urltools_1.5.1      scales_0.4.1        htmltools_0.3.5     assertthat_0.1      colorspace_1.2-6   
[36] stringi_1.1.1       lazyeval_0.2.0.9000 munsell_0.4.3       chron_2.3-47    

As an addendum, you do better than strptime which doesn't parse either version:

> strptime("04JAN2016:07:40:00", "%d%B%Y:%H%:M:%S")
[1] NA
> strptime("04JAN2016:07:40:00", "%d%b%Y:%H%:M:%S")
[1] NA
@vspinu
Copy link
Member

vspinu commented Mar 23, 2017

Yeh. Something is not quite right with the C parser:

> dt <- c("04jan2016:07:40:00", "04JAN2016:07:40:00", "04Jan2016:07:40:00")
> parse_date_time2(dt, "dBYHMS")
[1] NA                        "2016-07-04 07:40:00 UTC" "2016-01-04 07:40:00 UTC"
> parse_date_time2(dt, "dbYHMS")
[1] NA                        "2016-07-04 07:40:00 UTC" "2016-01-04 07:40:00 UTC"
> parse_date_time(dt, "dBYHMS")
[1] NA                        NA                        "2016-01-04 07:40:00 UTC"
Warning message:
 2 failed to parse. 
> parse_date_time(dt, "dbYHMS")
[1] "2016-01-04 07:40:00 UTC" "2016-01-04 07:40:00 UTC" "2016-01-04 07:40:00 UTC"

Will have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants