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: add SetLocal #10701
Comments
I wish there wasn't. Timezones are basically an UI/display issue. If you know what is the "local" time zone, just convert your times to it instead of setting a global default. |
Well, there are certain services running on the machine that want to use the timezone to format their data. Thus, a central time zone setting for the host makes sense. |
I think you use UTC time at all times to communicatie between systems. This way you don't need to deal with these sort of issues. |
Well, I currently have this kind of an issue, and without a restart of the program, I am not able to solve it. There are good reasons to have a system-wide time zone on a server. This might not be useful for services and system-to-system communication, but for the local system it is. Even the default log.Println() uses the local timezone to format the date, but it does not react on time zone changes, nor is it possible to force a re-read of the local time zone. (and the default log.Println() does not print any timezone offset to "know" what time zone it is using currently) |
I've updated the title. What you're asking for is
I don't believe this is a good idea. In general but especially in Go, coordination via global mutable state is almost always a mistake and difficult to correct once you realize it. If there are higher-level APIs that force the use of time.Local, we should probably address those instead. For example, if package log is what you are concerned about, it would probably be okay to file a separate issue for adding log.SetLocation and log.(*Logger).SetLocation. |
I want to provide an API server which is capable of setting the system time zone.
After changing the system time zone, the running go process still uses the old timezone and it is not possible to refresh except restarting the process.
In java there is a java.util.TimeZone.setDefault() to switch the timezone of the VM. It would be nice to either provide something similar or to add a method to refresh the localLoc variable.
The text was updated successfully, but these errors were encountered: