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

Fix a bug in DateTimeParser where compound formats would get parsed as #178

Merged
merged 2 commits into from
Jul 9, 2015
Merged

Conversation

kmillar
Copy link
Contributor

@kmillar kmillar commented May 22, 2015

partial ISO8601 date time format.

@hadley
Copy link
Member

hadley commented May 22, 2015

Would you mind explaining how the patch fixes the problem?

@kmillar
Copy link
Contributor Author

kmillar commented May 22, 2015

Previously there were two overloads of parse in the code: parse(bool) and parse(const std::string&)

In e.g.
parse("%m/%d/%y");
you have a 'const char*'

const char* can be converted to bool, and can also be converted to std::string, so either version is possible.

The rules of C++ say that the bool conversion takes precedence, which isn't what you want here. Adding an overload for 'const char*' removes the ambiguity.

Generally it's a good idea to only overload functions when the semantics of the function is the same no matter which overload is chosen, otherwise things like this happen.

@hadley
Copy link
Member

hadley commented May 25, 2015

Thanks - that's very useful. I really should rename parse(bool) to parseISO8601().

Would you mind adding a bullet to NEWS describing the bug and including (#178, @kmillar)

…ol).

This improves code clarity and fixed bug #178.
@kmillar
Copy link
Contributor Author

kmillar commented May 26, 2015

Your rename suggestion is a much better approach.

@hadley hadley merged commit 11b5d48 into tidyverse:master Jul 9, 2015
@hadley
Copy link
Member

hadley commented Jul 9, 2015

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants