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 upHandling negative timestamps #63
Comments
jpmarindiaz
commented
May 7, 2017
|
How is that not user error? In which context do you see these? Let's remember where |
|
Would it be suitable to directly throw an error in the face of clearly invalid input? |
|
That though crossed my mind too. What's holding me back is that each additional test adds an extra layer... At some point you just got to treat your users as adults. A negative time point (not talking durations here) is simply absurd. |
|
So the background is this: I was working with data in unix timestamp format (I think). Anyway, I managed to get the expected result with this (from your stackoverflow answer)
I am not sure if this background helps or was rather a silly question/issue. |
|
True, true, time before the epoch is expressed as negative offset. But where is your data coming from? "Raw numbers" like this mostly come from current/live measurement. "Old" datatimes before 1970 I have only ever seen expressed as textual. |
|
Actually, crap. I exposes a logic bug. For 'small numbers' I switch to dates. Can't do that. Because R> utctime(0)
[1] "1970-01-01"
R>it should also work for, say, |
|
As for the bug report, I need to at least document better what works or doesn't work. |
|
It works for explicit date requests, at least here: R> utcdate( 0 )
[1] "1970-01-01"
R> utcdate( -1 )
[1] "1969-12-31"
R> utcdate( -365 )
[1] "1969-01-01"
R> utcdate( -365 * 5 )
[1] "1965-01-02"
R> utcdate( -365 * 50 )
[1] "1920-01-14"
R> |
|
I got the data from dbpedia sparql, birthDates of people. |
|
I found a possible solution on the commute in, but it needs testing. We have a problem because we clearly want to recognise '20170508' as well. But maybe differentiating between As a general rule, for numeric data you can just load as a numeric vector and then do the convert you found, which essentially just sets the class attribute. |
|
I wasn't thinking this through earlier, and you are quite frankly correct. This should always have worked. I was a little too accomodating in the becoming allowing I will add some more documentation to clarify. Thanks for filing this bug report. I think anytime will be a better package when I have this fully implemented (ie docs, tests, ...) and released. |
|
Addressed in #65 which I just merged. |