Skip to content

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

Description

@billdenney

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions