diff options
author | Caleb Spare <cespare@gmail.com> | 2017-02-08 13:05:25 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2017-02-09 02:41:15 +0000 |
commit | 7ad512e7ffe576c4894ea84b02e954846fbda643 (patch) | |
tree | dfd572e45222a22118f4668fe4b6a87a03d77e82 /src/time/format.go | |
parent | 9799622f09ba2ece6fa8eb7607d0d471d75d9915 (diff) | |
download | go-7ad512e7ffe576c4894ea84b02e954846fbda643.tar.gz go-7ad512e7ffe576c4894ea84b02e954846fbda643.zip |
time: format negative monotonic times correctly in Time.String
Fixes #18993
Change-Id: Ia1fa20b6d82384b07e9ba5512b909439e0bec2a5
Reviewed-on: https://go-review.googlesource.com/36611
Run-TryBot: Caleb Spare <cespare@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/time/format.go')
-rw-r--r-- | src/time/format.go | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/time/format.go b/src/time/format.go index 7fe5b51bca..37e759f890 100644 --- a/src/time/format.go +++ b/src/time/format.go @@ -433,17 +433,13 @@ func (t Time) String() string { // Format monotonic clock reading as m=±ddd.nnnnnnnnn. if t.wall&hasMonotonic != 0 { - m2 := t.ext - m1, m2 := m2/1e9, m2%1e9 - if m2 < 0 { - m2 += 1e9 - m1-- - } + m2 := uint64(t.ext) sign := byte('+') - if m1 < 0 { + if t.ext < 0 { sign = '-' - m1 = -m1 + m2 = -m2 } + m1, m2 := m2/1e9, m2%1e9 m0, m1 := m1/1e9, m1%1e9 var buf []byte buf = append(buf, " m="...) |