title: Parse dates in format dmy together with dmY using parse_date_time
body: <p>I have a vector of character representation of dates, where formats mostly are <code>dmY</code> (e.g. 27-09-2013), <code>dmy</code> (e.g. 27-09-13), and occasionally some <code>b</code> or <code>B</code> months. Thus, <code>parse_date_time</code> in package <code>lubridate</code> that "allows the user to specify several format-orders to handle heterogeneous date-time character representations" could be a very useful function for me.</p>
  
  <p>However, it seems that <code>parse_date_time</code> has problem parsing <code>dmy</code> dates when they occur together with <code>dmY</code> dates. When parsing <code>dmy</code> alone, or <code>dmy</code> together with some other formats relevant to me, it works fine. This pattern was also noted in a comment to @Peyton's answer <a href="https://stackoverflow.com/questions/19028102/subset-dates-in-the-wrong-format-in-r/19028263#19028263">here</a>. A quick fix was suggested, but I wish to ask if it is possible to handle it in <code>lubridate</code>.</p>
  
  <p>Here I show some examples where I try to parse dates on <code>dmy</code> format together with some other formats, and specifying <code>orders</code> accordingly.</p>
  
  <pre><code>library(lubridate)
  # version: lubridate_1.3.0
  
  # regarding how date format is specified in 'orders':
  # examples in ?parse_date_time
  # parse_date_time(x, "ymd")
  # parse_date_time(x, "%y%m%d")
  # parse_date_time(x, "%y %m %d")
  # these order strings are equivalent and parses the same way
  # "Formatting orders might include arbitrary separators. These are discarded"
  
  # dmy date only
  parse_date_time(x = "27-09-13", orders = "d m y")
  # [1] "2013-09-27 UTC"
  # OK
  
  # dmy &amp; dBY
  parse_date_time(c("27-09-13", "27 September 2013"), orders = c("d m y", "d B Y"))
  # [1] "2013-09-27 UTC" "2013-09-27 UTC"
  # OK
  
  # dmy &amp; dbY
  parse_date_time(c("27-09-13", "27 Sep 2013"), orders = c("d m y", "d b Y"))
  # [1] "2013-09-27 UTC" "2013-09-27 UTC"
  # OK
  
  # dmy &amp; dmY
  parse_date_time(c("27-09-13", "27-09-2013"), orders = c("d m y", "d m Y"))
  # [1] "0013-09-27 UTC" "2013-09-27 UTC"
  # not OK
  
  # does order of the date components matter?
  parse_date_time(c("2013-09-27", "13-09-13"), orders = c("Y m d", "y m d"))
  # [1] "2013-09-27 UTC" "0013-09-27 UTC"
  # no
  </code></pre>
  
  <p>What about the <code>select_formats</code> argument? I am sorry to say this, but I have a hard time understand this section of the help file. And a <a href="https://stackoverflow.com/search?q=[r]+select_formats">search for <code>select_formats</code> on SO</a>: 0 results. Still, this section seemed relevant: "By default the formats with most formating tockens (%) are selected and %Y counts as 2.5 tockens (so that it can have priority over %y%m).". So I (desperately) tried with some additional <code>dmy</code> dates:</p>
  
  <pre><code>parse_date_time(c("27-09-2013", rep("27-09-13", 10)), orders = c("d m y", "d m Y"))
  # not OK. Tried also 100 dmy dates.
  
  # does order in the vector matter?
  parse_date_time(c(rep("27-09-13", 10), "27-09-2013"), orders = c("d m y", "d m Y"))
  # no
  </code></pre>
  
  <p>I then checked how the <code>guess_formats</code> function (also in <code>lubridate</code>) handled <code>dmy</code> together with <code>dmY</code>:</p>
  
  <pre><code>guess_formats(c("27-09-13", "27-09-2013"), c("dmy", "dmY"), print_matches = TRUE)
  #                   dmy        dmY       
  # [1,] "27-09-13"   "%d-%m-%y" ""        
  # [2,] "27-09-2013" "%d-%m-%Y" "%d-%m-%Y"
  # OK   
  </code></pre>
  
  <p>From <code>?guess_formats</code>: <code>y also matches Y</code>. From <code>?parse_date_time</code>: <code>y* Year without century (00–99 or 0–99). Also matches year with century (Y format)</code>. So I tried:</p>
  
  <pre><code>guess_formats(c("27-09-13", "27-09-2013"), c("dmy"), print_matches = TRUE)
  #                   dmy       
  # [1,] "27-09-13"   "%d-%m-%y"
  # [2,] "27-09-2013" "%d-%m-%Y"
  # OK
  </code></pre>
  
  <p>Thus, <code>guess_format</code> seems to be able to deal with <code>dmy</code> together with <code>dmY</code>. But how can I tell <code>parse_date_time</code> to do the same? Thanks in advance for any comments or help.</p>
  
  <p><strong>Update</strong>
  I posted the question on the <a href="https://github.com/hadley/lubridate/issues/206" rel="nofollow noreferrer"><code>lubridate</code> bug report</a>, and got a rapid reply from @vitoshka: "This is a bug".</p>