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

`ymd_hms` functions are not picking PM/AM indicator #327

vspinu opened this issue May 20, 2015 · 2 comments

`ymd_hms` functions are not picking PM/AM indicator #327

vspinu opened this issue May 20, 2015 · 2 comments


Copy link

@vspinu vspinu commented May 20, 2015

> mdy_hms(c('12/17/1996 04:00:00 PM'))
[1] "1996-12-17 04:00:00 UTC"
> ymd_hms(c('1996/04/01 04:00:00 PM'))
[1] "1996-04-01 04:00:00 UTC"
@vspinu vspinu added the bug label May 20, 2015
@vspinu vspinu changed the title `ymd_hms` funcntions are not picking PM/AM indicator `ymd_hms` functions are not picking PM/AM indicator May 20, 2015
Copy link
Member Author

@vspinu vspinu commented Oct 31, 2015

This happens on English locales that don't have PM/AM indicator like LC_TIME=en_DK.UTF-8 that I have.

Two ways to deal with it.

First option is introduce mandatory english locale parsing that would have lower priority than the current locale. This would essentially double the current overhead and it's also not system independent. You will have to know how standard english locales are names on all OSes. I am not even sure this is possible.

Second option is to deal with AM/PM and day/month english names explicitly at c-parser level. This is directly related to #287. I think this is the most robust, fast and simplest approach.

@vspinu vspinu added enhancement and removed bug labels Oct 31, 2015
Copy link

@dracodoc dracodoc commented Oct 31, 2015

It also happened on me with Chinese locales. I solved my problem with Sys.setlocale("LC_TIME", "C") after hours fight and search.

I think this problem should be solved by user with either setting locale temporally in one session or specify locale in parsing command.

However it will help a lot if the error messages and function documents include information and examples like this(especially the more obvious set locale to English often not working). I believe this problem is actually quite common: there are many people using system locale other than English but need to read time format in English.

data.table documents included many examples and even StackOverflow discussion links, I think that really helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants