]> Cypherpunks repositories - gostls13.git/commit
time: allow long fractions in ParseDuration
authorRob Pike <r@golang.org>
Sun, 18 Sep 2016 04:35:42 +0000 (14:35 +1000)
committerRob Pike <r@golang.org>
Mon, 19 Sep 2016 19:46:09 +0000 (19:46 +0000)
commit3cca069220af044c1a36da3f588ffe3abbeab9c5
tree65b4fe54144842476a11fa1a26b64701244e6b70
parente94c52933b9c414d3f8fa94ead0d9cc5b7d7d717
time: allow long fractions in ParseDuration

The code scanned for an integer after a decimal point, which
meant things could overflow if the number was very precise
(0.1234123412341234123412342134s). This fix changes the
parser to stop adding precision once we run out of bits, rather
than trigger an erroneous overflow.

We could parse durations using floating-point arithmetic,
but since the type is int64 and float64 has only has 53 bits
of precision, that would be imprecise.

Fixes #15011.

Change-Id: If85e22b8f6cef12475e221169bb8f493bb9eb590
Reviewed-on: https://go-review.googlesource.com/29338
Reviewed-by: Costin Chirvasuta <costinc@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/time/format.go
src/time/time_test.go