Skip to content

parse_date_time: orders mdy/Y don't play well with dby/Y #572

Closed

Description

@Henrik-P

When using orders mdy or mdY together with dby or dbY in parse_date_time, the mdy and mdY formats are incorrectly parsed as dmy or dmY. For some reason mdy and dbY works though.

In all examples below, the mdy or mdY dates should be parsed as "2017-09-01" (Ymd).

Does not work:

# mdy & dby
parse_date_time(c("09-01-17", "02-Sep-17"), orders = c("mdy", "dby"), locale = "eng")
# [1] "2017-01-09 UTC" "2017-09-02 UTC"

# mdY & dby/Y
parse_date_time(c("09-01-2017", "02-Sep-17"), orders = c("mdY", "dby"), locale = "eng")
parse_date_time(c("09-01-2017", "02-Sep-2017"), orders = c("mdY", "dbY"), locale = "eng")
# [1] "2017-01-09 UTC" "2017-09-02 UTC"

# mdy/Y & dby/Y, with no mdy/Y in x 
parse_date_time("09-01-17", orders = c("mdy", "dby", "dbY"), locale = "eng")
parse_date_time("09-01-2017", orders = c("mdY", "dby", "dbY"), locale = "eng")
# [1] "2017-01-09 UTC"

Works:

# mdy vs dbY
parse_date_time(c("09-01-17", "02-Sep-2017"), orders = c("mdy", "dbY"), locale = "eng")

# ymd/Ymd vs dbY
parse_date_time(c("17-09-01", "02-Sep-2017"), orders = c("ymd", "dbY"), locale = "eng")
parse_date_time(c("2017-09-01", "02-Sep-2017"), orders = c("Ymd", "dbY"), locale = "eng")

# dmy/dmY vs dbY 
parse_date_time(c("01-09-17", "02-Sep-2017"), orders = c("dmy", "dbY"), locale = "eng")
parse_date_time(c("01-09-2017", "02-Sep-2017"), orders = c("dmY", "dbY"), locale = "eng")

Activity

  1. changed the title [-]parse_date_time: orders mdy/Y doesn't play well with dby/Y[/-] [+]parse_date_time: orders mdy/Y don't play well with dby/Y[/+] on Sep 1, 2017
  2. vspinu commented on Oct 1, 2017

    @vspinu
    Member

    This happens because "b" format matches numeric months. This is not intended.

  3. added
    bugan unexpected problem or unintended behavior
    on Oct 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions