Skip to content
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

scala.concurrent.duration.Duration strips a nano-second when parsing negative durations #9949

Closed
scabug opened this issue Oct 5, 2016 · 1 comment

Comments

@scabug
Copy link

scabug commented Oct 5, 2016

Discovered this playing with scala.concurrent.Duration string parsing in 2.11.8.

scala> import scala.concurrent.duration.Duration
import scala.concurrent.duration.Duration

scala> Duration("1 day")
res1: scala.concurrent.duration.Duration = 1 day

scala> Duration("-1 day")
res2: scala.concurrent.duration.Duration = -86399999999999 nanoseconds

The negative value is exactly 1 nanosecond short of a day. Also, because it's expressed in nanoseconds, it's not nearly as readable.

@scabug
Copy link
Author

scabug commented Oct 5, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9949?orig=1
Reporter: Leonid Meyerguz (lmeyerguz-at-gmail.com)
Affected Versions: 2.11.8

Jasper-M added a commit to Jasper-M/scala that referenced this issue May 31, 2017
Use round instead of manually trying to convert to a Long.

Fixes scala/bug#9949 and scala/bug#10320
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant