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

discrepancy between strptime and ymd #289

Closed
markvanderloo opened this issue Dec 16, 2014 · 1 comment
Closed

discrepancy between strptime and ymd #289

markvanderloo opened this issue Dec 16, 2014 · 1 comment
Labels
bug an unexpected problem or unintended behavior

Comments

@markvanderloo
Copy link

ymd's doc states that it is based on 'strptime'. However, for the edge case of a non-existing date I get different results.

> ymd("2011-02-29")
[1] "2011-03-01 UTC"
> strptime("2011-02-29","%Y-%m-%d")
[1] NA
vspinu added a commit that referenced this issue Dec 18, 2014
@vspinu
Copy link
Member

vspinu commented Dec 18, 2014

ymd's doc states that it is based on 'strptime'.

This used to be true but it's not anymore. ymd relies only strptime when non-numeric formats are used. Otherwise a fast internal parser is used. This is documented in parse_date_time:

 ‘parse_date_time’, and hence all the derived functions, such as
 ‘ymd_hms’, ‘ymd’ etc, will drop into ‘fast_strptime’ instead of
 ‘strptime’ whenever the trained from input data formats are all
 numeric.

I have just fixed this in the docs. Thanks.

ymd("2011-02-29") ## [1] "2011-03-01 UTC"

This is a semi-bug. I will fix this in the parser if it doesn't impose too much of the penalty. You are expected not to pass invalid dates to the parser.

@vspinu vspinu added the bug an unexpected problem or unintended behavior label Dec 18, 2014
@vspinu vspinu closed this as completed in 8521eb5 Apr 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants