将 Olson 时区文件转换为 TZ 环境变量

发布于 2024-09-17 05:09:16 字数 391 浏览 1 评论 0原文

我们使用“America/New_York”约定让用户选择时区,但在我们的资源有限的系统中,我们必须手动提供实际的 TZ 变量。例如,对于纽约,我们有:

timezones["America/New_York"] = "EST5EDT,M3.2.0,M11.1.0";

但是,我们发现提供这些环境设置的资源只有美国所有区域的一个子集,我正在尝试构建其余的资源。例如,我需要构建 America/Kentucky/LouisvilleAmerica/Boise

是否有此构建的资源或现有脚本可以将 Olson 约定转换为 TZ 环境变量?我用谷歌搜索了一段时间,找不到任何东西(并且对自己实现逻辑感到紧张)。

TIA 麦克风

We are using the "America/New_York" convention for the user to select the timezone, but in our resource constrained system, we must manually provide the actual TZ variable. For example, for New York, we have:

timezones["America/New_York"] = "EST5EDT,M3.2.0,M11.1.0";

However, the resource we found to provide these environment settings only had a subset of all the US regions, and I'm trying to construct the remaining ones. For example, I need to build America/Kentucky/Louisville and America/Boise.

Is there resource with this built, or an existing script which can convert the Olson conventions to TZ environment variables? I've googled for a while, and can't find anything (and am nervous about implementing the logic myself).

TIA
Mike

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

末が日狂欢 2024-09-24 05:09:16

每个时区的描述通常存储在 /usr/share/zoneinfo 下的文件中(例如 /usr/share/zoneinfo/America/Kentucky/Louisville)。 tzfile(5) 人页描述了这些文件的结构。

请注意,这些文件包含根据日期使用的不同规则,以考虑每个时区时间规则的过去和未来的政治变化(因此您不能只是说“给我美国/的字符串” Kentucky/Louisville”,您必须说“给我 America/Kentucky/Louisville 的字符串,有效期截至 2010 年 9 月 2 日”)。

The descriptions of each timezone are usually stored in files under /usr/share/zoneinfo (eg. /usr/share/zoneinfo/America/Kentucky/Louisville). The tzfile(5) man page describes the structure of these files.

Note that the files contain different rules to be used depending on the date, to account for past and future political changes to the time rules for each time zone (so you can't just say "give me the string for America/Kentucky/Louisville", you have to say "give me the string for America/Kentucky/Louisville, valid as at 2-September-2010").

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文