S.Perera
S.Perera

Reputation: 904

`parse_date_time2` function in lubridate package

The help page for parse_date_time2() states it is a fast C parser of numeric orders. What is meant by "numeric orders" here?

Can someone give an example where this will not work because of not having a numeric order?

Upvotes: 0

Views: 328

Answers (1)

MrFlick
MrFlick

Reputation: 206606

The parse_date_time2 function as a parameter named orders= which the help page describes as "a character vector of date-time formats". It's the ordering of the numbers representing year, day, month, etc in the string you are trying to parse. To be fast, parse_date_time2 only recognizes a subset of orders as indicated by the (!) in the descriptions on the help page. The fast version does not recognize julian dates for example.

lubridate::parse_date_time("151-2001", "jY")
# [1] "2001-05-31 UTC"
lubridate::parse_date_time2("151-2001", "jY")
# Error in parse_dt(x, order, exact, FALSE, cutoff_2000) : 
#   Unrecognized format j supplied

It doesn't really matter if the ordering is numeric or not, it just matters if it's one of the formats that is in the faster parser used by parse_date_time2

Upvotes: 1

Related Questions