-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: notice system timezone changes #28020
Comments
What does the C library do? |
I haven't (yet) written C to test it, but my current understanding is: localtime(3) and friends cache values on first use. tzset(3) reloads the cache. So libc enables one to easily handle this in the app; Go doesn't. (And, IMHO, Go should aim higher than libc.) glibc argument for not stat(2)ing /etc/localtime on every localtime(3) call was performance. inotify and friends might change that equation. Random discussion found: |
Go pins time.Local at the start of the binary (golang/go#28020), but because the bar can run for days on end even as the machine moves around the world, we need to track the machine timezone for local clock modules. This changes clock.Module to handle a nil timezone as "true" machine-local time zone, updating the output any time the timezone changes locally.
I found an example in C from https://stackoverflow.com/questions/2251635/how-to-detect-change-of-system-time-in-linux. I have not tested it personally. |
@perillo The timezone can change without |
I cooked up a little library to watch |
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?
in one terminal:
in another (note, this changes your computer's timezone):
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?
The text was updated successfully, but these errors were encountered: