-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Inconsistent recognition of incorrect input, given locale, in ymd and mdy #255
Comments
This is why you have the
In the future the parser might recognize English months independently of the locale, till then this is the only solution. |
I appreciate that. What I was trying to point out was that ymd, returning NA makes a good job of it, while mdy (returning 2075...) doesn't. |
Well, lubridate tries to be smart about huge number of formats. In this case it does a good job for your locale because it interprets "121975" as "1975-10-12 UTC". Which is not what you need but it's the only logical answer for
A good way out is to recognize the English months and parse the date correctly irrespective of the current locale. I hope to be able to implement this in the relatively close future. |
No criticism intended. Actually I suppose it was the 2075 that caught my intention. Interestingly, your comment above is wrong: "121975" [isn't interpreted] as "1975-10-12 UTC" but, as you show, "2075-12-19 UTC". I wonder whether guessing "2075" when a "1975" is present really is the best choice at this time in the current century (irrespective of locale)? |
The code and the comments are correct. This is how it is intended to work. You ask for There is a small issue in that code though. The 75 is interpreted as 2075 and it should probably be 1975 in order to be consistent with how |
R version 3.1.0 lubridate 1.3.3.
Sys.getlocale(category = "LC_ALL")
[1] "LC_COLLATE=Welsh_United Kingdom.1252;LC_CTYPE=Welsh_United Kingdom.1252;LC_MONETARY=Welsh_United Kingdom.1252;LC_NUMERIC=C;LC_TIME=Welsh_United Kingdom.1252"
ymd("1989, Hydref 17")
[1] "1989-10-17 UTC"
but
ymd("1989, October 17")
[1] NA (which is good, given the locale)
while
mdy("Hydref 12, 1975")
[1] "1975-10-12 UTC"
and
mdy("October 12, 1975")
[1] "2075-12-19 UTC" (which is wrong).
The text was updated successfully, but these errors were encountered: