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

Parsing month names fails when day not present. #253

Closed
coolbutuseless opened this issue Aug 22, 2014 · 4 comments
Closed

Parsing month names fails when day not present. #253

coolbutuseless opened this issue Aug 22, 2014 · 4 comments

Comments

@coolbutuseless
Copy link

parse_date_time("2 july 2008", orders="dmy"); parse_date_time("7 2008", orders="my"); parse_date_time("july 2008", orders="my")
[1] "2008-07-02 UTC"
[1] "2008-07-01 UTC"
[1] NA
Warning message:
All formats failed to parse. No formats found.

@coolbutuseless
Copy link
Author

also I would have thought these would return the same date:

dmy("1 7 97"); dmy("1 july 97")
[1] "2097-07-01 UTC"
[1] "1997-07-01 UTC"

@coolbutuseless
Copy link
Author

And now I've just discovered that strptime() also won't properly parse month names when day not present:

strptime("JUL 97", "%b %y")
[1] NA
strptime("1 JUL 97", "%d %b %y")
[1] "1997-07-01 EST"

@vspinu
Copy link
Member

vspinu commented Aug 24, 2014

For non-numeric formats (months in this case) lubridate relies on strptime. For numeric formats an internal C parser is used. So you get NA on "july 2008" and the correct answer for "7 2008".

Same reason for dmy("1 7 97") and dmy("1 july 97") discrepancy. It looks like strptime parses all years greater than 68 as XXth century. I will look into fixing this asap.

I thought about extending the internal C parser to handle alphabetic months in English locale. It might be a worthwhile effort given this common user pattern.

@vspinu
Copy link
Member

vspinu commented Dec 14, 2014

Fixed the 68 issue and openning a new ticket for C parser of %b format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants