Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAllow to parse dates from long numbers #302
Conversation
|
Should really have run |
|
Example of what used to fail:
It seems like a bug in |
|
Thanks. Could you please add a small test for this? Could you also squash your commits into one? We try to stick to one-commit-per-change rule to make it easier to navigate the history. |
|
Regarding performance,
|
|
Tests are added and everything is squashed into one commit |
| @@ -156,6 +156,20 @@ test_that("ymd functions correctly parse dates with no separators and no quotes" | |||
| equals(as.POSIXct("2010-01-02 23:59:59", tz = "UTC"))) | |||
| }) | |||
|
|
|||
| test_that("numbers are correctly converted into character for parsing", { | |||
| # numbers with 000000 at the end are wrongly converted by as.character | |||
vspinu
Jan 30, 2015
Member
They are not wrongly converted. That's the feature which is customized by scipen option.
They are not wrongly converted. That's the feature which is customized by scipen option.
| equals(as.POSIXct("2010-01-02 00:00:00", tz = "UTC"))) | ||
| expect_that(.num_to_date(20100102000000), | ||
| equals("20100102000000")) | ||
| # check for a fix in as.character |
vspinu
Jan 30, 2015
Member
I don't think we need these tests. as.character is not broken and will never be fixed.
I don't think we need these tests. as.character is not broken and will never be fixed.
|
This PR made me think, are there other places |
|
Potential problems:
The other uses in the source code do not seem problematic to me. |
|
I've addressed the comments above. Let me know what you think. I guess I'll need to squash the commits again but I'll rather do that when all is accepted. |
Probably not an issue as
Good catch. That makes me think that
Yes. Looks good. Please squash. Instead of adding new commits you can always amend previous commit and then force push. Thanks. |
With as.character(), long numbers with many zeros at the end get converted to scientific notation which the parse of course fails to recognise. Using format(..., scientific = FALSE) prevents that. trim = TRUE is necessary for variable length input. Add tests for these problematic numbers. Tests also check wether the behaviour of as.character() changes but format() outperforms as.character() and may be preferred anyway.
|
Squashed commits |
Allow to parse dates from long numbers
|
|
|
You are welcome. Happy to help. |
With as.character(), long numbers get converted to scientific
notation which the parse of course fails to recognise. Using
format(..., scientific = FALSE) prevents that.