-
Notifications
You must be signed in to change notification settings - Fork 992
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
as.ITime
should round sub-second values instead of floor
/truncate
#2870
Comments
Regarding the last point, yes, it's to do with negative numbers -- truncation means always bringing the number closer to 0, which in this case means rounding "up" for negative numbers:
|
The fix is as simple as fixing this line... I'm not immediately sold that we should change the behavior, though...
Anyway, I'll file a PR to start the discussion with a solution in hand |
Actually, I think internal behavior is inconsistent at the moment, IIUC:
I don't know what a |
Confirmed:
|
(referencing closed issue #2156 as requested by Matt)
as.ITime
converts time strings to integers, so it makes sense that any inputs with sub-second precision would be rounded to the nearest second. Unfortunately, it always rounds down (probably just truncating the input to discard decimal values), which doesn't seem like the best option to me.The issue
For example:
This isn't just being printed that way, the integer behind the scenes agrees with the printed value:
Comparison with
chron::times
The
chron
package uses numeric instead of integer values, so this isn't an issue there:Comparison with
as.POSIXct
as.POSIXct
prints the "truncated" value, but retains the sub-second precision in the numeric value behind the scenes:Something odd I noticed with
as.POSIXct
Oddly,
POSIXct
seems to truncate sometimes, possibly depending on timezone, and possibly something to do with negative numbers. Not sure why this is, and it's not related todata.table
at all, just something I noticed when looking at the above, so you might notice it too:The text was updated successfully, but these errors were encountered: