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 upMilliseconds are not parsed for certain formats #29
Comments
|
Thanks. There must be a Easier to see this way: R> anytime(c("20160101 101112.345678", "01Sep2016 101112.345678"))
[1] "2016-01-01 10:11:12.345678 CST" "2016-09-01 10:11:12.000000 CDT"
R> (and |
|
I'm on it. I'll send a pull ASAP. |
|
Wicked. Was thinking about rolling a new release, so this will make it even better! |
|
"That format" is probably also missing in So my bad... |
|
I have this branch now: https://github.com/bobjansen/anytime/tree/runit which allows some quicker experimentation and found that this issue is more annoying than I first thought: the format check is greedy so that we have: > anytime:::testFormat("%d%b%Y %H:%M:%S", "01Sep2016 101112")
[1] "2016-09-01 10:11:00 AEST"which is wrong but also > dput(anytime:::testFormat("%d%b%Y %H%M%S", "01Sep2016 101112.345678"))
structure(1472688672, class = c("POSIXct", "POSIXt"), tzone = "") # Too greedy
> dput(anytime:::testFormat("%d%b%Y %H%M%S%f", "01Sep2016 101112.345678"))
structure(1472688672.34568, class = c("POSIXct", "POSIXt"), tzone = "")which makes format ordering a bit complicated. |
|
The format was already there: https://github.com/eddelbuettel/anytime/blob/master/tests/allFormats.R#L21 and on. |
|
I may know what that is. It is an actual error. Which I caught for dates, but not for dates with subsequent See this: https://github.com/eddelbuettel/anytime/blob/master/src/anytime.cpp#L213-L214 We may need to (very carefully) generalise that to an |
|
Ie this is also just plain wrong: R> anytime("20161030 121647")
[1] "2016-03-14 16:00:00 CDT"
R> |
|
It is a terrible format but still ... |
|
I actually like the parsimony of "20161030 121647". Luckily for us it's hardly used (IME) and I guess we could do without support for "20161030 101112.345678" if nothing else works. |
|
If I sit down with Boost regexp I can probably cover it. |
|
Grr. Cannot. Boost regexp requires linking which we don't have. Regexp is part of C++11 so I may just adopt that as a minimal standard. I am a bit tied up til the end of next week so this is on hold. |
|
Better news. Try the brand new branch. It should now cover 20161103
20161103 1011
20161103 101112
20161103 101112.131415 |
|
That took one more refinement but I currently do see any failures in the tests we have. Which does of course mean that we may need more tests :) |
|
The examples above work for me but anytime(c("01Sep2016 101112", "01Sep2016 101112.345678"))
anytime(c("01Sep2016 10:11:12", "01Sep2016 10:11:12.345678"))
anytime(c("01-Sep-2016 101112", "01-Sep-2016 101112.345678"))still give me trouble, milliseconds are ignored. Do these work on your machine? |
|
In the meantime I fixed one more mistake, but good catch on your part. I now that section dropping out: edd@max:~/git/anytime(feature/all_digits)$ Rscript tests/allFormats.R
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12 CDT" "2016-09-01 10:11:12 CDT"
[1] "2016-09-01 10:11:12 CDT" "2016-09-01 10:11:12 CDT"
[1] "2016-09-01 10:11:00 CDT" "2016-09-01 10:11:12 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 CDT" "2016-09-01 CDT" "2016-09-01 CDT" "2016-09-01 CDT"
[1] "2016-09-01 CDT" "2016-09-01 CDT" "2016-09-01 CDT" "2016-09-01 CDT"
[1] "2016-09-01 CDT" "2016-09-01 CDT"
[1] "2016-09-01 CDT" "2016-09-01 CDT" "2016-09-01 CDT" "2016-09-01 CDT"
[1] NA NA NA "2016-09-01 10:11:12 CDT"
[1] "2016-09-11 00:00:00.000000 CDT" "2016-09-11 10:11:00.000000 CDT" "2016-09-11 10:11:12.000000 CDT" "2016-09-11 10:11:12.345678 CDT"
edd@max:~/git/anytime(feature/all_digits)$ and I guess you quite correctly put the finger on the three lines where we drop fractional seconds. Will investigate on the train home. |
|
Hehe, that was unrelated -- the format strings were lacking the required |
with thanks to Bob Jansen in #29 (comment)
|
@bobjansen I just pushed two more commits (with the first explicitly thanking you for the note above). Please give that a whirl. I may release it tomorrow or Monday or Tuesday -- it will bring a lot of nice new stuff. |
|
Thanks. And the new features look very useful. I gave it a whirl but now it does this: > anytime(c("01-Sep-2016 101112", "01-Sep-2016 101112.345678"))
[1] "2016-09-01 10:11:00.000000 CEST" "2016-09-01 10:11:12.345678 CEST"I think I have fix for our current set of tests though, see this tiny change. I will try to do some further testing in the coming days. |
|
I would argue that It simply is not in the list of formats. Now, you rightly realized that, and added the missing format. But as discussed in the passed, added formats is not "entirely free" as it may affect other parses. So I would try to convince you to let go of this one. What do you think? Is it really a must-have? |
|
We have |
|
Oops. Good catch. If they are in And I just noticed that lines 3 and 4 of the tests no longer do subseconds. Dang. Looks the splitting of the times needs to be more careful about excluding parts that are not just digits. |
|
Really appreciate the careful checking. I just made one more commit; it looks good at my end now: edd@max:~/git/anytime(master)$ Rscript tests/allFormats.R
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:00.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 10:11:12.000000 CDT" "2016-09-01 10:11:12.345678 CDT"
[1] "2016-09-01 CDT" "2016-09-01 CDT" "2016-09-01 CDT" "2016-09-01 CDT"
[1] "2016-09-01 CDT" "2016-09-01 CDT" "2016-09-01 CDT" "2016-09-01 CDT"
[1] "2016-09-01 CDT" "2016-09-01 CDT"
[1] "2016-09-01 CDT" "2016-09-01 CDT" "2016-09-01 CDT" "2016-09-01 CDT"
[1] NA NA NA "2016-09-01 10:11:12 CDT"
[1] "2016-09-11 00:00:00.000000 CDT" "2016-09-11 10:11:00.000000 CDT" "2016-09-11 10:11:12.000000 CDT" "2016-09-11 10:11:12.345678 CDT"
edd@max:~/git/anytime(master)$ |
|
Looks good to me too! Edit: I do need to have 2fdfcc merged for "01-Sep-2016 101112" to work though. |
|
Yes -- I just cherry-picked that one in. We should be good now. |
|
It is really unbelievable. I just caught another special case (of the dreaded |
with thanks to Bob Jansen in eddelbuettel#29 (comment)
When I run (from a fresh install from CRAN and when running on my version of master)
the milliseconds seem not to be parsed. Something that doesn't seem to happen in
tests/allFormats.Rout.save.