Skip to content

time: notice system timezone changes #28020

@tv42

Description

@tv42

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

go version go1.11.1 linux/amd64

Does this issue reproduce with the latest release?

Yes.

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

linux/amd64

What did you do?

package main

import (
	"fmt"
	"time"
)

func main() {
	for {
		time.Sleep(1 * time.Second)
		fmt.Println(time.Now())
	}
}

in one terminal:

$ go run time.go

in another (note, this changes your computer's timezone):

$ timedatectl set-timezone America/Denver
$ date
Thu Oct  4 12:48:50 MDT 2018
$ timedatectl set-timezone America/Los_Angeles
$ date
Thu Oct  4 11:48:56 PDT 2018
$ 

What did you expect to see?

Go process seeing that the current time changes between MDT and PDT, time displayed changing by an hour.

As far as I can tell, there's not even a way to tell package time to re-initialize its idea of local time, even if my app somehow (in a platform-specific way) realized that it was necessary.

This hurts long-running end-user apps when users travel. Think of e.g. a desktop clock.

What did you see instead?

2018-10-04 12:48:48.12727581 -0600 MDT m=+1.000767878
2018-10-04 12:48:49.127890815 -0600 MDT m=+2.001383092
2018-10-04 12:48:50.128187914 -0600 MDT m=+3.001680261
2018-10-04 12:48:51.128403029 -0600 MDT m=+4.001895306
2018-10-04 12:48:52.128632471 -0600 MDT m=+5.002124678
2018-10-04 12:48:53.128842855 -0600 MDT m=+6.002335551
2018-10-04 12:48:54.129075736 -0600 MDT m=+7.002568154
2018-10-04 12:48:55.129282227 -0600 MDT m=+8.002787356
2018-10-04 12:48:56.129528956 -0600 MDT m=+9.003021303
2018-10-04 12:48:57.129734907 -0600 MDT m=+10.003227044
2018-10-04 12:48:58.129960422 -0600 MDT m=+11.003452839
2018-10-04 12:48:59.130145298 -0600 MDT m=+12.003637576

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions