我想在我的系统的 zoneinfo 数据库中列出所有时区的列表(注意:系统是 debian strecth linux)
我目前的解决方案是:列出 下的所有路径/usr/share/zoneinfo/posix
,它们是纯文件或符号链接
cd /usr/share/zoneinfo/posix && find * -type f -or -type l | sort
Run Code Online (Sandbox Code Playgroud)
但是,我不确定每个已知时区是否都映射到此目录下的路径。
题
是否有一个命令可以提供系统当前 zoneinfo 数据库中完整的时区列表?
Sim*_*ted 14
在 Debian 9 上,您的命令为我提供了此处列出的所有时区:https : //en.wikipedia.org/wiki/List_of_tz_database_time_zones
此外,systemd
提供timedatectl list-timezones
,它输出与您的命令相同的列表。
据我所知,数据tzdata
是直接从 IANA 提供的:
This package contains data required for the implementation of
standard local time for many representative locations around the
globe. It is updated periodically to reflect changes made by
political bodies to time zone boundaries, UTC offsets, and
daylight-saving rules.
Run Code Online (Sandbox Code Playgroud)
所以只需保持tzdata
包更新。
小智 6
如果您想检索未使用的系统上的列表,systemd
这里是awk
我从实现中派生的脚本timedatectl list-timezones
:
awk '/^Z/ { print $2 }; /^L/ { print $3 }' /usr/share/zoneinfo/tzdata.zi
Run Code Online (Sandbox Code Playgroud)
将其输出通过管道传输到 中sort
,您将得到与 几乎相同的结果timedatectl list-timezones
。