-
Notifications
You must be signed in to change notification settings - Fork 285
collector_guess now guesses time formats as well #424
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
Conversation
bool isTime(const std::string& x, LocaleInfo* pLocale) { | ||
DateTimeParser parser(pLocale); | ||
parser.setDate(x.c_str()); | ||
return parser.parse(pLocale->timeFormat_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm, maybe this should default to parseTime()
, since that's a more flexible default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think parseTime()
is too flexible actually. Using it the following tests fail
collector_guess("0001")
#> [1] "time"
collector_guess("00010203")
#> [1] "time"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I'd rather make parseTime()
less flexible but still correct ;)
05326fc
to
6321fce
Compare
I updated |
return false; | ||
consumeThisChar(':'); | ||
consumeSeconds(&sec_, NULL); | ||
bool valid = consumeInteger(2, &hour_) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind sticking with the previous structure? i.e. return false
when a condition isn't met - I find that easier to understand.
I think you're right that making time stricter is a good idea (but it'll need it's own bullet point in NEWS) |
The flexible parser was modified to require colons between fields to support this use case. Fixes tidyverse#384
6321fce
to
6bacca8
Compare
Current coverage is 70.50%@@ master #424 diff @@
==========================================
Files 56 56
Lines 2811 2824 +13
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 1975 1991 +16
+ Misses 836 833 -3
Partials 0 0
|
Ok used |
LGTM |
One thing to note with this is the default time format is
%H:%M
, so the examples in the issue are still going to be guessed as dates unless they change thetime_format
in the locale (as is done in the tests).I don't know if we should change the default time format to
%H:%M:%S
or not.Fixes #384