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

time: Time.String formats negative monotonic times incorrectly #18993

cespare opened this issue Feb 8, 2017 · 2 comments

time: Time.String formats negative monotonic times incorrectly #18993

cespare opened this issue Feb 8, 2017 · 2 comments


Copy link

@cespare cespare commented Feb 8, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

tip (go version devel +0c9325e Wed Feb 8 17:54:06 2017 +0000 linux/amd64)

What operating system and processor architecture are you using (go env)?


What did you do?

package main

import (

func main() {
	time.Sleep(200 * time.Millisecond)
	t := time.Now()
	t = t.Add(-time.Second)

This printed

2017-02-08 10:34:35.543437741 -0800 PST m=+0.200282679
2017-02-08 10:34:34.543437741 -0800 PST m=-1.200282679

Given the first timestamp, the second line should instead have been

2017-02-08 10:34:34.543437741 -0800 PST m=-0.799717321

Looks like that method could also use a test. If it's OK, I'll send a CL.

/cc @rsc

@cespare cespare self-assigned this Feb 8, 2017
@bradfitz bradfitz added this to the Go1.9 milestone Feb 8, 2017
Copy link

@rsc rsc commented Feb 8, 2017

Yes, please. Thanks.

Copy link

@gopherbot gopherbot commented Feb 8, 2017

CL mentions this issue.

@gopherbot gopherbot closed this in 7ad512e Feb 9, 2017
@golang golang locked and limited conversation to collaborators Feb 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.