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

Closed
cespare opened this issue Feb 8, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@cespare
Copy link
Contributor

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)?

linux/amd64

What did you do?

package main

import (
	"fmt"
	"time"
)

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

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

@rsc

This comment has been minimized.

Copy link
Contributor

commented Feb 8, 2017

Yes, please. Thanks.

@gopherbot

This comment has been minimized.

Copy link

commented Feb 8, 2017

CL https://golang.org/cl/36611 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.
You can’t perform that action at this time.