简体   繁体   English

如何设置半小时和 45 分钟时区而不用担心 Linux 中的 DST 变化?

[英]How to set half hour and 45-minute time zones without worrying about DST changes in Linux?

Currently I am setting time zone GMT+5 on my Linux CentOS 7 machine by linking /etc/localtime to /usr/share/zoneinfo/Etc/GMT-5.目前,我通过将/etc/localtime链接到/usr/share/zoneinfo/Etc/GMT-5.在我的 Linux CentOS 7 机器上设置时区 GMT+ /usr/share/zoneinfo/Etc/GMT-5.

I want to create a zone info file for example /usr/share/zoneinfo/Etc/GMT-5:30 that enables me to set the current timezone to GMT+5:30 without having to worry about DST changes .我想创建一个区域信息文件,例如/usr/share/zoneinfo/Etc/GMT-5:30使我能够将当前时区设置为 GMT+5:30而不必担心 DST 更改

I am aware that I could link /etc/localtime to /usr/share/zoneinfo/Asia/Kolkata for example but then I will have to worry about DST changes even if it may not be implemented in the mean time.我知道我可以将/etc/localtime链接到/usr/share/zoneinfo/Asia/Kolkata例如,但是我将不得不担心 DST 更改,即使它可能不会同时实施。

Also I am aware of TZ=GMT+5:30; export $TZ我也知道TZ=GMT+5:30; export $TZ TZ=GMT+5:30; export $TZ but I am worried that this approach backfire for some reason in the future. TZ=GMT+5:30; export $TZ但我担心这种方法将来会因某种原因适得其反。

If you don't want to use $TZ variable, you may want to create your own timezone file.如果您不想使用 $TZ 变量,您可能需要创建自己的时区文件。

You need create a text file (say MyZone.zic) with您需要创建一个文本文件(比如 MyZone.zic)

Zone MyZone 5:30 - GMT-5:30

then run然后运行

zic -d <desired_folder> MyZone.zic

then link compiled file to /etc/localtime然后将编译后的文件链接到 /etc/localtime

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM