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

ymd(column, truncated = 1) parses date incorrectly on Windows #843

Open
hidekoji opened this issue Dec 13, 2019 · 6 comments
Open

ymd(column, truncated = 1) parses date incorrectly on Windows #843

hidekoji opened this issue Dec 13, 2019 · 6 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@hidekoji
Copy link

In below example, I expect 17/11 to be parsed as "2017-11-01" but it's parsed as "2017-01-01"

df<-data.frame(date=c("18/08", "17/11", "18/08", "18/05", "18/05", "18/07")); dplyr::mutate(df, date2 = lubridate::ymd(date, truncated = 1))
#>    date      date2
#> 1 18/08 2018-08-01
#> 2 17/11 2017-01-01
#> 3 18/08 2018-08-01
#> 4 18/05 2018-05-01
#> 5 18/05 2018-05-01
#> 6 18/07 2018-07-01

Created on 2019-12-12 by the reprex package (v0.3.0)

> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=Japanese_Japan.932  LC_CTYPE=Japanese_Japan.932   
[3] LC_MONETARY=Japanese_Japan.932 LC_NUMERIC=C                  
[5] LC_TIME=Japanese_Japan.932    

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

other attached packages:
[1] reprex_0.3.0 dplyr_0.8.3 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.2       rstudioapi_0.10  knitr_1.25       whisker_0.4      magrittr_1.5    
 [6] tidyselect_0.2.5 R6_2.4.0         rlang_0.4.0      stringr_1.4.0    tools_3.6.0     
[11] xfun_0.10        clipr_0.7.0      htmltools_0.4.0  yaml_2.2.0       assertthat_0.2.1
[16] digest_0.6.21    tibble_2.1.3     crayon_1.3.4     processx_3.4.1   callr_3.3.2     
[21] purrr_0.3.2      ps_1.3.0         fs_1.3.1         glue_1.3.1       evaluate_0.14   
[26] rmarkdown_1.16   stringi_1.4.3    compiler_3.6.0   pillar_1.4.2     lubridate_1.7.4 
[31] pkgconfig_2.0.3 
> 
@hidekoji hidekoji changed the title ymd(column, truncated = 1) does not work on Windows ymd(column, truncated = 1) parses date incorrectly on Windows Dec 13, 2019
@cderv
Copy link
Contributor

cderv commented Dec 13, 2019

I am also on windows but it is working fine

date <- c("18/08", "17/11", "18/08", "18/05", "18/05", "18/07")
data.frame(
  date = date,
  date = lubridate::ymd(date, truncated = 1)
)
#>    date     date.1
#> 1 18/08 2018-08-01
#> 2 17/11 2017-11-01
#> 3 18/08 2018-08-01
#> 4 18/05 2018-05-01
#> 5 18/05 2018-05-01
#> 6 18/07 2018-07-01

Created on 2019-12-13 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.6.1 (2019-07-05)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  French_France.1252          
#>  ctype    French_France.1252          
#>  tz       Europe/Paris                
#>  date     2019-12-13                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version    date       lib source                        
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 3.6.0)                
#>  backports     1.1.5      2019-10-02 [1] CRAN (R 3.6.1)                
#>  callr         3.3.2      2019-09-22 [1] CRAN (R 3.6.1)                
#>  cli           2.0.0      2019-12-09 [1] CRAN (R 3.6.1)                
#>  crayon        1.3.4      2017-09-16 [1] CRAN (R 3.6.0)                
#>  debugme       1.1.0      2017-10-22 [1] standard (@1.1.0)             
#>  desc          1.2.0      2018-05-01 [1] CRAN (R 3.6.1)                
#>  devtools      2.2.1      2019-09-24 [1] CRAN (R 3.6.1)                
#>  digest        0.6.23     2019-11-23 [1] CRAN (R 3.6.1)                
#>  ellipsis      0.3.0      2019-09-20 [1] CRAN (R 3.6.1)                
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 3.6.1)                
#>  fansi         0.4.0      2018-10-05 [1] CRAN (R 3.6.0)                
#>  fs            1.3.1      2019-05-06 [1] CRAN (R 3.6.1)                
#>  glue          1.3.1      2019-03-12 [1] CRAN (R 3.6.0)                
#>  highr         0.8        2019-03-20 [1] CRAN (R 3.6.1)                
#>  htmltools     0.4.0      2019-10-04 [1] CRAN (R 3.6.1)                
#>  knitr         1.26       2019-11-12 [1] CRAN (R 3.6.1)                
#>  lubridate     1.7.4      2018-04-11 [1] CRAN (R 3.6.1)                
#>  magrittr      1.5        2014-11-22 [1] CRAN (R 3.6.0)                
#>  memoise       1.1.0      2017-04-21 [1] CRAN (R 3.6.1)                
#>  pkgbuild      1.0.6      2019-10-09 [1] CRAN (R 3.6.1)                
#>  pkgload       1.0.2      2018-10-29 [1] CRAN (R 3.6.1)                
#>  prettyunits   1.0.2      2015-07-13 [1] CRAN (R 3.6.0)                
#>  processx      3.4.1      2019-07-18 [1] CRAN (R 3.6.1)                
#>  ps            1.3.0      2018-12-21 [1] CRAN (R 3.6.0)                
#>  R6            2.4.1      2019-11-12 [1] CRAN (R 3.6.1)                
#>  Rcpp          1.0.3      2019-11-08 [1] CRAN (R 3.6.1)                
#>  remotes       2.1.0      2019-06-24 [1] CRAN (R 3.6.0)                
#>  rlang         0.4.2      2019-11-23 [1] CRAN (R 3.6.1)                
#>  rmarkdown     1.18       2019-11-27 [1] CRAN (R 3.6.1)                
#>  rprojroot     1.3-2      2018-01-03 [1] CRAN (R 3.6.0)                
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 3.6.1)                
#>  stringi       1.4.3      2019-03-12 [1] CRAN (R 3.6.0)                
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 3.6.0)                
#>  testthat      2.3.1      2019-12-01 [1] CRAN (R 3.6.1)                
#>  usethis       1.5.1.9000 2019-10-04 [1] Github (r-lib/usethis@3015465)
#>  withr         2.1.2      2018-03-15 [1] CRAN (R 3.6.0)                
#>  xfun          0.11       2019-11-12 [1] CRAN (R 3.6.1)                
#>  yaml          2.2.0      2018-07-25 [1] CRAN (R 3.6.0)                
#> 
#> [1] C:/Users/chris/Documents/R/win-library/3.6
#> [2] C:/Program Files/R/R-3.6.1/library

However, I think this is a local issue, if I change it I can reproduce

Sys.setlocale("LC_TIME", "Japanese_Japan.932")
#> [1] "Japanese_Japan.932"
date <- c("18/08", "17/11", "18/08", "18/05", "18/05", "18/07")
data.frame(
  date = date,
  date = lubridate::ymd(date, truncated = 1)
)
#>    date     date.1
#> 1 18/08 2018-08-01
#> 2 17/11 2017-01-01
#> 3 18/08 2018-08-01
#> 4 18/05 2018-05-01
#> 5 18/05 2018-05-01
#> 6 18/07 2018-07-01

Here is a minimal reprex:

lubridate::ymd("17/11", truncated = 1, locale = "Japanese_Japan.932")
#> [1] "2017-01-01"
lubridate::ymd("17/11", truncated = 1, locale = "French_France.1252")
#> [1] "2017-11-01"
lubridate::ymd("17/11", truncated = 1, locale = "English_United States.1252")
#> [1] "2017-11-01"

@vspinu
Copy link
Member

vspinu commented Dec 18, 2019

@cderv could you please post the value of lubridate:::.get_locale_regs("Japanese_Japan.932")?

I don't see this problem with japanese locale on Linux.

@vspinu vspinu added the bug an unexpected problem or unintended behavior label Dec 18, 2019
@vspinu vspinu added this to the 1.7.6 milestone Dec 18, 2019
@cderv
Copy link
Contributor

cderv commented Dec 18, 2019

Here is the result

> lubridate:::.get_locale_regs("Japanese_Japan.932")
$alpha_flex
                                                                                                                           b 
"((?<b_b>1|2|3|4|5|6|7|8|9|10|11|12)|(?<B_b>1\\?|2\\?|3\\?|4\\?|5\\?|6\\?|7\\?|8\\?|9\\?|10\\?|11\\?|12\\?))(?![[:alpha:]])" 
                                                                                                                           B 
                                     "(?<B_B>1\\?|2\\?|3\\?|4\\?|5\\?|6\\?|7\\?|8\\?|9\\?|10\\?|11\\?|12\\?)(?![[:alpha:]])" 
                                                                                                                           a 
                                                                            "((?<a_a>\\?)|(?<A_a>\\?\\?\\?))(?![[:alpha:]])" 
                                                                                                                           A 
                                                                                          "(?<A_A>\\?\\?\\?)(?![[:alpha:]])" 
                                                                                                                          Ou 
                                                                                                "(?<Ou_Ou>Z)(?![[:alpha:]])" 
                                                                                                                           p 
                                                                                               "(?<p>\\?\\?)(?![[:alpha:]])" 

$num_flex
                                                                                                                                                                                                                                                   d 
                                                                                                                                                                                                              "(?<d>[012]?[1-9]|3[01]|[12]0)(?!\\d)" 
                                                                                                                                                                                                                                                   q 
                                                                                                                                                                                                                            "(?<q>[0]?[1-4])(?!\\d)" 
                                                                                                                                                                                                                                                   H 
                                                                                                                                                                                                                      "(?<H>2[0-4]|[01]?\\d)(?!\\d)" 
                                                                                                                                                                                                                                                   h 
                                                                                                                                                                                                                      "(?<H>2[0-4]|[01]?\\d)(?!\\d)" 
                                                                                                                                                                                                                                                   I 
                                                                                                                                                                                                                       "(?<I>1[0-2]|0?[1-9])(?!\\d)" 
                                                                                                                                                                                                                                                   j 
                                                                                                                                                                                                                        "(?<j>[0-3]?\\d?\\d)(?!\\d)" 
                                                                                                                                                                                                                                                   M 
                                                                                                                                                                                                                            "(?<M>[0-5]?\\d)(?!\\d)" 
                                                                                                                                                                                                                                                   S 
                                                                                                                                                                                                "((?<OS_S>[0-5]?\\d\\.\\d+)|(?<S>[0-6]?\\d))(?!\\d)" 
                                                                                                                                                                                                                                                   s 
                                                                                                                                                                                                "((?<OS_S>[0-5]?\\d\\.\\d+)|(?<S>[0-6]?\\d))(?!\\d)" 
                                                                                                                                                                                                                                                   U 
                                                                                                                                                                                                                            "(?<U>[0-5]?\\d)(?!\\d)" 
                                                                                                                                                                                                                                                   w 
                                                                                                                                                                                                                                "(?<w>[0-6])(?!\\d)" 
                                                                                                                                                                                                                                                   u 
                                                                                                                                                                                                                                "(?<u>[1-7])(?!\\d)" 
                                                                                                                                                                                                                                                   W 
                                                                                                                                                                                                                            "(?<W>[0-5]?\\d)(?!\\d)" 
                                                                                                                                                                                                                                                   Y 
                                                                                                                                                                                                                               "(?<Y>\\d{4})(?!\\d)" 
                                                                                                                                                                                                                                                   y 
                                                                                                                                                                                                              "((?<Y_y>\\d{4})|(?<y>\\d{2}))(?!\\d)" 
                                                                                                                                                                                                                                                  Oz 
                                                                                                                                                                                                                       "(?<Oz_Oz>[-+]\\d{4})(?!\\d)" 
                                                                                                                                                                                                                                                  OO 
                                                                                                                                                                                                                   "(?<OO>[-+]\\d{2}:\\d{2})(?!\\d)" 
                                                                                                                                                                                                                                                  Oo 
                                                                                                                                                                                                                          "(?<Oo>[-+]\\d{2})(?!\\d)" 
                                                                                                                                                                                                                                                   T 
"(((?<I_s>1[0-2]|0?[1-9])\\D+(?<M_s_T>[0-5]?\\d)\\D+((?<OS_s_T_S>[0-5]?\\d\\.\\d+)|(?<S_s_T>[0-6]?\\d))\\D*(?<p_s>\\?\\?)(?![[:alpha:]]))|((?<H_s>2[0-4]|[01]?\\d)\\D+(?<M_s>[0-5]?\\d)\\D+((?<OS_s_S>[0-5]?\\d\\.\\d+)|(?<S_s>[0-6]?\\d))))(?!\\d)" 
                                                                                                                                                                                                                                                   R 
                                                                                                          "(((?<I_s>1[0-2]|0?[1-9])\\D+(?<M_s_T>[0-5]?\\d)\\D*(?<p_s>\\?\\?)(?![[:alpha:]]))|((?<H_s>2[0-4]|[01]?\\d)\\D+(?<M_s>[0-5]?\\d)))(?!\\d)" 
                                                                                                                                                                                                                                                   r 
                                                                                                                                                        "(((?<I_s>1[0-2]|0?[1-9])\\D*(?<p_s>\\?\\?)(?![[:alpha:]]))|(?<H_s>2[0-4]|[01]?\\d))(?!\\d)" 
                                                                                                                                                                                                                                                   m 
                                                                                        "((?<m>1[0-2]|0?[1-9](?!\\d))|(((?<b_m>1|2|3|4|5|6|7|8|9|10|11|12)|(?<B_m>1\\?|2\\?|3\\?|4\\?|5\\?|6\\?|7\\?|8\\?|9\\?|10\\?|11\\?|12\\?))(?![[:alpha:]])))" 
                                                                                                                                                                                                                                                  OS 
                                                                                                                                                                                                                          "(?<OS_f>[0-5]\\d\\.\\d+)" 
                                                                                                                                                                                                                                                   z 
                                                                                                                                 "((?<Ou_Ou>Z)(?![[:alpha:]])|(?<Oz_Oz>[-+]\\d{4})(?!\\d)|(?<OO>[-+]\\d{2}:\\d{2})(?!\\d)|(?<Oo>[-+]\\d{2})(?!\\d))" 

$alpha_exact
                                                                                                                               b 
"((?<b_b_e>1|2|3|4|5|6|7|8|9|10|11|12)|(?<B_b_e>1\\?|2\\?|3\\?|4\\?|5\\?|6\\?|7\\?|8\\?|9\\?|10\\?|11\\?|12\\?))(?![[:alpha:]])" 
                                                                                                                               B 
                                       "(?<B_B_e>1\\?|2\\?|3\\?|4\\?|5\\?|6\\?|7\\?|8\\?|9\\?|10\\?|11\\?|12\\?)(?![[:alpha:]])" 
                                                                                                                               a 
                                                                            "((?<a_a_e>\\?)|(?<A_a_e>\\?\\?\\?))(?![[:alpha:]])" 
                                                                                                                               A 
                                                                                            "(?<A_A_e>\\?\\?\\?)(?![[:alpha:]])" 
                                                                                                                              Ou 
                                                                                                  "(?<Ou_Ou_e>Z)(?![[:alpha:]])" 
                                                                                                                               p 
                                                                                                 "(?<p_e>\\?\\?)(?![[:alpha:]])" 

$num_exact
                                                                                                                                                                                                                                                    d 
                                                                                                                                                                                                                     "(?<d_e>[012][1-9]|3[01]|[12]0)" 
                                                                                                                                                                                                                                                    q 
                                                                                                                                                                                                                                   "(?<q_e>[0][1-4])" 
                                                                                                                                                                                                                                                    H 
                                                                                                                                                                                                                             "(?<H_e>2[0-4]|[01]\\d)" 
                                                                                                                                                                                                                                                    h 
                                                                                                                                                                                                                             "(?<H_e>2[0-4]|[01]\\d)" 
                                                                                                                                                                                                                                                    I 
                                                                                                                                                                                                                              "(?<I_e>1[0-2]|0[1-9])" 
                                                                                                                                                                                                                                                    j 
                                                                                                                                                                                                                                "(?<j_e>[0-3]\\d\\d)" 
                                                                                                                                                                                                                                                    M 
                                                                                                                                                                                                                                   "(?<M_e>[0-5]\\d)" 
                                                                                                                                                                                                                                                    S 
                                                                                                                                                                                                      "((?<OS_S_e>[0-5]\\d\\.\\d*)|(?<S_e>[0-6]\\d))" 
                                                                                                                                                                                                                                                    s 
                                                                                                                                                                                                      "((?<OS_S_e>[0-5]\\d\\.\\d*)|(?<S_e>[0-6]\\d))" 
                                                                                                                                                                                                                                                    U 
                                                                                                                                                                                                                                   "(?<U_e>[0-5]\\d)" 
                                                                                                                                                                                                                                                    w 
                                                                                                                                                                                                                                      "(?<w_e>[0-6])" 
                                                                                                                                                                                                                                                    u 
                                                                                                                                                                                                                                      "(?<u_e>[1-7])" 
                                                                                                                                                                                                                                                    W 
                                                                                                                                                                                                                                   "(?<W_e>[0-5]\\d)" 
                                                                                                                                                                                                                                                    Y 
                                                                                                                                                                                                                                     "(?<Y_e>\\d{4})" 
                                                                                                                                                                                                                                                    y 
                                                                                                                                                                                                                  "((?<Y_y_e>\\d{4})|(?<y_e>\\d{2}))" 
                                                                                                                                                                                                                                                   Oz 
                                                                                                                                                                                                                             "(?<Oz_Oz_e>[-*]\\d{4})" 
                                                                                                                                                                                                                                                   OO 
                                                                                                                                                                                                                         "(?<OO_e>[-*]\\d{2}:\\d{2})" 
                                                                                                                                                                                                                                                   Oo 
                                                                                                                                                                                                                                "(?<Oo_e>[-*]\\d{2})" 
                                                                                                                                                                                                                                                    T 
"(((?<I_s_e>1[0-2]|0[1-9])\\D*(?<M_s_T_e>[0-5]\\d)\\D*((?<OS_s_T_S_e>[0-5]\\d\\.\\d*)|(?<S_s_T_e>[0-6]\\d))\\D*(?<p_s_e>\\\\)(?![[:alpha:]]))|((?<H_s_e>2[0-4]|[01]\\d)\\D*(?<M_s_e>[0-5]\\d)\\D*((?<OS_s_S_e>[0-5]\\d\\.\\d*)|(?<S_s_e>[0-6]\\d))))" 
                                                                                                                                                                                                                                                    R 
                                                                                                              "(((?<I_s_e>1[0-2]|0[1-9])\\D*(?<M_s_T_e>[0-5]\\d)\\D*(?<p_s_e>\\\\)(?![[:alpha:]]))|((?<H_s_e>2[0-4]|[01]\\d)\\D*(?<M_s_e>[0-5]\\d)))" 
                                                                                                                                                                                                                                                    r 
                                                                                                                                                              "(((?<I_s_e>1[0-2]|0[1-9])\\D*(?<p_s_e>\\\\)(?![[:alpha:]]))|(?<H_s_e>2[0-4]|[01]\\d))" 
                                                                                                                                                                                                                                                    m 
                                                                                           "((?<m_e>1[0-2]|0[1-9])|(((?<b_m_e>1|2|3|4|5|6|7|8|9|10|11|12)|(?<B_m_e>1\\?|2\\?|3\\?|4\\?|5\\?|6\\?|7\\?|8\\?|9\\?|10\\?|11\\?|12\\?))(?![[:alpha:]])))" 
                                                                                                                                                                                                                                                   OS 
                                                                                                                                                                                                                           "(?<OS_e>[0-5]\\d\\.\\d+)" 
                                                                                                                                                                                                                                                    z 
                                                                                                                                               "((?<Ou_Ou_e>Z)(?![[:alpha:]])|(?<Oz_Oz_e>[-*]\\d{4})|(?<OO_e>[-*]\\d{2}:\\d{2})|(?<Oo_e>[-*]\\d{2}))" 

$wday_names
$wday_names$abr
[1] "\\?"

$wday_names$full
[1] "\\?\\?\\?"


$month_names
$month_names$abr
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12"

$month_names$full
 [1] "1\\?"  "2\\?"  "3\\?"  "4\\?"  "5\\?"  "6\\?"  "7\\?"  "8\\?"  "9\\?"  "10\\?"
[11] "11\\?" "12\\?"

@hidekoji
Copy link
Author

hidekoji commented Dec 27, 2019

Apologies for the belated update. Here is my result for lubridate:::.get_locale_regs("Japanese_Japan.932") on Windows.

lubridate:::.get_locale_regs("Japanese_Japan.932")
#> $alpha_flex
#>                                                                                                                b 
#> "((?<b_b>1|2|3|4|5|6|7|8|9|10|11|12)|(?<B_b>1月|2月|3月|4月|5月|6月|7月|8月|9月|10月|11月|12月))(?![[:alpha:]])" 
#>                                                                                                                B 
#>                                      "(?<B_B>1月|2月|3月|4月|5月|6月|7月|8月|9月|10月|11月|12月)(?![[:alpha:]])" 
#>                                                                                                                a 
#>         "((?<a_a>木|月|火|日|金|水|土)|(?<A_a>木曜日|月曜日|火曜日|日曜日|金曜日|水曜日|土曜日))(?![[:alpha:]])" 
#>                                                                                                                A 
#>                                        "(?<A_A>木曜日|月曜日|火曜日|日曜日|金曜日|水曜日|土曜日)(?![[:alpha:]])" 
#>                                                                                                               Ou 
#>                                                                                     "(?<Ou_Ou>Z)(?![[:alpha:]])" 
#>                                                                                                                p 
#>                                                                                 "(?<p>午前|午後)(?![[:alpha:]])" 
#> 
#> $num_flex
#>                                                                                                                                                                                                                                                       d 
#>                                                                                                                                                                                                                  "(?<d>[012]?[1-9]|3[01]|[12]0)(?!\\d)" 
#>                                                                                                                                                                                                                                                       q 
#>                                                                                                                                                                                                                                "(?<q>[0]?[1-4])(?!\\d)" 
#>                                                                                                                                                                                                                                                       H 
#>                                                                                                                                                                                                                          "(?<H>2[0-4]|[01]?\\d)(?!\\d)" 
#>                                                                                                                                                                                                                                                       h 
#>                                                                                                                                                                                                                          "(?<H>2[0-4]|[01]?\\d)(?!\\d)" 
#>                                                                                                                                                                                                                                                       I 
#>                                                                                                                                                                                                                           "(?<I>1[0-2]|0?[1-9])(?!\\d)" 
#>                                                                                                                                                                                                                                                       j 
#>                                                                                                                                                                                                                            "(?<j>[0-3]?\\d?\\d)(?!\\d)" 
#>                                                                                                                                                                                                                                                       M 
#>                                                                                                                                                                                                                                "(?<M>[0-5]?\\d)(?!\\d)" 
#>                                                                                                                                                                                                                                                       S 
#>                                                                                                                                                                                                    "((?<OS_S>[0-5]?\\d\\.\\d+)|(?<S>[0-6]?\\d))(?!\\d)" 
#>                                                                                                                                                                                                                                                       s 
#>                                                                                                                                                                                                    "((?<OS_S>[0-5]?\\d\\.\\d+)|(?<S>[0-6]?\\d))(?!\\d)" 
#>                                                                                                                                                                                                                                                       U 
#>                                                                                                                                                                                                                                "(?<U>[0-5]?\\d)(?!\\d)" 
#>                                                                                                                                                                                                                                                       w 
#>                                                                                                                                                                                                                                    "(?<w>[0-6])(?!\\d)" 
#>                                                                                                                                                                                                                                                       u 
#>                                                                                                                                                                                                                                    "(?<u>[1-7])(?!\\d)" 
#>                                                                                                                                                                                                                                                       W 
#>                                                                                                                                                                                                                                "(?<W>[0-5]?\\d)(?!\\d)" 
#>                                                                                                                                                                                                                                                       Y 
#>                                                                                                                                                                                                                                   "(?<Y>\\d{4})(?!\\d)" 
#>                                                                                                                                                                                                                                                       y 
#>                                                                                                                                                                                                                  "((?<Y_y>\\d{4})|(?<y>\\d{2}))(?!\\d)" 
#>                                                                                                                                                                                                                                                      Oz 
#>                                                                                                                                                                                                                           "(?<Oz_Oz>[-+]\\d{4})(?!\\d)" 
#>                                                                                                                                                                                                                                                      OO 
#>                                                                                                                                                                                                                       "(?<OO>[-+]\\d{2}:\\d{2})(?!\\d)" 
#>                                                                                                                                                                                                                                                      Oo 
#>                                                                                                                                                                                                                              "(?<Oo>[-+]\\d{2})(?!\\d)" 
#>                                                                                                                                                                                                                                                       T 
#> "(((?<I_s>1[0-2]|0?[1-9])\\D+(?<M_s_T>[0-5]?\\d)\\D+((?<OS_s_T_S>[0-5]?\\d\\.\\d+)|(?<S_s_T>[0-6]?\\d))\\D*(?<p_s>午前|午後)(?![[:alpha:]]))|((?<H_s>2[0-4]|[01]?\\d)\\D+(?<M_s>[0-5]?\\d)\\D+((?<OS_s_S>[0-5]?\\d\\.\\d+)|(?<S_s>[0-6]?\\d))))(?!\\d)" 
#>                                                                                                                                                                                                                                                       R 
#>                                                                                                           "(((?<I_s>1[0-2]|0?[1-9])\\D+(?<M_s_T>[0-5]?\\d)\\D*(?<p_s>午前|午後)(?![[:alpha:]]))|((?<H_s>2[0-4]|[01]?\\d)\\D+(?<M_s>[0-5]?\\d)))(?!\\d)" 
#>                                                                                                                                                                                                                                                       r 
#>                                                                                                                                                         "(((?<I_s>1[0-2]|0?[1-9])\\D*(?<p_s>午前|午後)(?![[:alpha:]]))|(?<H_s>2[0-4]|[01]?\\d))(?!\\d)" 
#>                                                                                                                                                                                                                                                       m 
#>                                                                                                        "((?<m>1[0-2]|0?[1-9](?!\\d))|(((?<b_m>1|2|3|4|5|6|7|8|9|10|11|12)|(?<B_m>1月|2月|3月|4月|5月|6月|7月|8月|9月|10月|11月|12月))(?![[:alpha:]])))" 
#>                                                                                                                                                                                                                                                      OS 
#>                                                                                                                                                                                                                              "(?<OS_f>[0-5]\\d\\.\\d+)" 
#>                                                                                                                                                                                                                                                       z 
#>                                                                                                                                     "((?<Ou_Ou>Z)(?![[:alpha:]])|(?<Oz_Oz>[-+]\\d{4})(?!\\d)|(?<OO>[-+]\\d{2}:\\d{2})(?!\\d)|(?<Oo>[-+]\\d{2})(?!\\d))" 
#> 
#> $alpha_exact
#>                                                                                                                    b 
#> "((?<b_b_e>1|2|3|4|5|6|7|8|9|10|11|12)|(?<B_b_e>1月|2月|3月|4月|5月|6月|7月|8月|9月|10月|11月|12月))(?![[:alpha:]])" 
#>                                                                                                                    B 
#>                                        "(?<B_B_e>1月|2月|3月|4月|5月|6月|7月|8月|9月|10月|11月|12月)(?![[:alpha:]])" 
#>                                                                                                                    a 
#>         "((?<a_a_e>木|月|火|日|金|水|土)|(?<A_a_e>木曜日|月曜日|火曜日|日曜日|金曜日|水曜日|土曜日))(?![[:alpha:]])" 
#>                                                                                                                    A 
#>                                          "(?<A_A_e>木曜日|月曜日|火曜日|日曜日|金曜日|水曜日|土曜日)(?![[:alpha:]])" 
#>                                                                                                                   Ou 
#>                                                                                       "(?<Ou_Ou_e>Z)(?![[:alpha:]])" 
#>                                                                                                                    p 
#>                                                                                   "(?<p_e>午前|午後)(?![[:alpha:]])" 
#> 
#> $num_exact
#>                                                                                                                                                                                                                                                          d 
#>                                                                                                                                                                                                                           "(?<d_e>[012][1-9]|3[01]|[12]0)" 
#>                                                                                                                                                                                                                                                          q 
#>                                                                                                                                                                                                                                         "(?<q_e>[0][1-4])" 
#>                                                                                                                                                                                                                                                          H 
#>                                                                                                                                                                                                                                   "(?<H_e>2[0-4]|[01]\\d)" 
#>                                                                                                                                                                                                                                                          h 
#>                                                                                                                                                                                                                                   "(?<H_e>2[0-4]|[01]\\d)" 
#>                                                                                                                                                                                                                                                          I 
#>                                                                                                                                                                                                                                    "(?<I_e>1[0-2]|0[1-9])" 
#>                                                                                                                                                                                                                                                          j 
#>                                                                                                                                                                                                                                      "(?<j_e>[0-3]\\d\\d)" 
#>                                                                                                                                                                                                                                                          M 
#>                                                                                                                                                                                                                                         "(?<M_e>[0-5]\\d)" 
#>                                                                                                                                                                                                                                                          S 
#>                                                                                                                                                                                                            "((?<OS_S_e>[0-5]\\d\\.\\d*)|(?<S_e>[0-6]\\d))" 
#>                                                                                                                                                                                                                                                          s 
#>                                                                                                                                                                                                            "((?<OS_S_e>[0-5]\\d\\.\\d*)|(?<S_e>[0-6]\\d))" 
#>                                                                                                                                                                                                                                                          U 
#>                                                                                                                                                                                                                                         "(?<U_e>[0-5]\\d)" 
#>                                                                                                                                                                                                                                                          w 
#>                                                                                                                                                                                                                                            "(?<w_e>[0-6])" 
#>                                                                                                                                                                                                                                                          u 
#>                                                                                                                                                                                                                                            "(?<u_e>[1-7])" 
#>                                                                                                                                                                                                                                                          W 
#>                                                                                                                                                                                                                                         "(?<W_e>[0-5]\\d)" 
#>                                                                                                                                                                                                                                                          Y 
#>                                                                                                                                                                                                                                           "(?<Y_e>\\d{4})" 
#>                                                                                                                                                                                                                                                          y 
#>                                                                                                                                                                                                                        "((?<Y_y_e>\\d{4})|(?<y_e>\\d{2}))" 
#>                                                                                                                                                                                                                                                         Oz 
#>                                                                                                                                                                                                                                   "(?<Oz_Oz_e>[-*]\\d{4})" 
#>                                                                                                                                                                                                                                                         OO 
#>                                                                                                                                                                                                                               "(?<OO_e>[-*]\\d{2}:\\d{2})" 
#>                                                                                                                                                                                                                                                         Oo 
#>                                                                                                                                                                                                                                      "(?<Oo_e>[-*]\\d{2})" 
#>                                                                                                                                                                                                                                                          T 
#> "(((?<I_s_e>1[0-2]|0[1-9])\\D*(?<M_s_T_e>[0-5]\\d)\\D*((?<OS_s_T_S_e>[0-5]\\d\\.\\d*)|(?<S_s_T_e>[0-6]\\d))\\D*(?<p_s_e>午前|午後)(?![[:alpha:]]))|((?<H_s_e>2[0-4]|[01]\\d)\\D*(?<M_s_e>[0-5]\\d)\\D*((?<OS_s_S_e>[0-5]\\d\\.\\d*)|(?<S_s_e>[0-6]\\d))))" 
#>                                                                                                                                                                                                                                                          R 
#>                                                                                                               "(((?<I_s_e>1[0-2]|0[1-9])\\D*(?<M_s_T_e>[0-5]\\d)\\D*(?<p_s_e>午前|午後)(?![[:alpha:]]))|((?<H_s_e>2[0-4]|[01]\\d)\\D*(?<M_s_e>[0-5]\\d)))" 
#>                                                                                                                                                                                                                                                          r 
#>                                                                                                                                                               "(((?<I_s_e>1[0-2]|0[1-9])\\D*(?<p_s_e>午前|午後)(?![[:alpha:]]))|(?<H_s_e>2[0-4]|[01]\\d))" 
#>                                                                                                                                                                                                                                                          m 
#>                                                                                                             "((?<m_e>1[0-2]|0[1-9])|(((?<b_m_e>1|2|3|4|5|6|7|8|9|10|11|12)|(?<B_m_e>1月|2月|3月|4月|5月|6月|7月|8月|9月|10月|11月|12月))(?![[:alpha:]])))" 
#>                                                                                                                                                                                                                                                         OS 
#>                                                                                                                                                                                                                                 "(?<OS_e>[0-5]\\d\\.\\d+)" 
#>                                                                                                                                                                                                                                                          z 
#>                                                                                                                                                     "((?<Ou_Ou_e>Z)(?![[:alpha:]])|(?<Oz_Oz_e>[-*]\\d{4})|(?<OO_e>[-*]\\d{2}:\\d{2})|(?<Oo_e>[-*]\\d{2}))" 
#> 
#> $wday_names
#> $wday_names$abr
#> [1] "日" "月" "火" "水" "木" "金" "土"
#> 
#> $wday_names$full
#> [1] "日曜日" "月曜日" "火曜日" "水曜日" "木曜日" "金曜日" "土曜日"
#> 
#> 
#> $month_names
#> $month_names$abr
#>  [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12"
#> 
#> $month_names$full
#>  [1] "1月"  "2月"  "3月"  "4月"  "5月"  "6月"  "7月"  "8月"  "9月"  "10月"
#> [11] "11月" "12月"

Created on 2019-12-27 by the reprex package (v0.3.0)

@vspinu
Copy link
Member

vspinu commented Mar 8, 2020

It's a bug in strptime. On windows with the above japanese locale it gives:

> x <- c("18/08", "17/11", "18/08", "18/05", "18/05", "18/07")
> strptime(x, "%y/%b%d")
[1] NA "2017-01-01 PST" NA NA NA NA

I am afraid I cannot do much about this ATM. The only solution is to drop dependency on strptime in our parser, thing which is planned but is unlikely to happen before summer I am afraid.

@vspinu vspinu removed this from the 1.7.6 milestone Mar 8, 2020
@vspinu
Copy link
Member

vspinu commented Mar 9, 2020

A workaround is to avoid training during the parsing:

> parse_date_time(x, c("ym","ymd"), train=F)
[1] "2018-08-01 UTC" "2017-11-01 UTC" "2018-08-01 UTC" "2018-05-01 UTC" "2018-05-01 UTC" "2018-07-01 UTC"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants