升级 PHP 本地实现的 Olson tz 数据库

发布于 2024-12-25 11:06:47 字数 882 浏览 5 评论 0原文

我正在开发一个大量使用时区的网站,该网站需要处于可用的绝对最新 tz 信息的最前沿(我已经通过 tz 邮件列表)。我不知道的是如何让 PHP 安装在我的开发计算机和 Web 主机上运行,​​以使用更多最新的 tz 数据而不是已有的旧数据。 这并不像升级 PHP 那么简单,因为即使是最新版本的 PHP 也不一定在任何给定时间都具有绝对最新的 tz 数据。

有人指出 pecl 中的 timezonedb 包 会让我该软件包的最新官方版本,但是如果我需要进一步了解可能尚未正式发布的更新的“前沿”怎么办?我非常确定新的 tz 数据必须使用 zic 进行编译(以 tzcode 形式分发),并将生成的二进制文件提供给 pecl。我真的不知道这需要什么,因此各个步骤的见解/链接将不胜感激。

如何在 (1) XAMPP 开发计算机和/或 (2) 上升级由 PHP 实例本机使用的 Olson 数据库> 典型的共享托管服务...同时跳过尽可能少的障碍和管理障碍?是否有任何共享托管环境可能会使人们变得更加困难而应该注意的细节?存在数据的多个副本是否可行,以便在有人以某种方式搞砸时可以轻松撤消更改?

由于更改有时没有及时正式发布才能生效,因此我正在专门寻找一种能够自行任意进行​​这些更改的方法。我也有兴趣探索从“快速/简单”到“严格/最佳”的一系列可能解决方案的潜在权衡。

I'm working on a site that makes heavy use of time zones which needs to be on the bleeding edge of the absolute latest tz information available (which I already get through the tz mailing list). What I don't know is how to get the PHP installations running on my development machine and my web host to use more up-to-date tz data instead of the older data already on them. This isn't as simple as just upgrading PHP, since even the newest versions of PHP won't necessarily have the absolute latest tz data at any given time.

It's been pointed out that the timezonedb package in pecl will get me to the latest official release of the package, but what if I need to go a little further to get to that "bleeding edge" of updates that may not have been officially released yet? I'm pretty sure that the newer tz data would have to be compiled with zic (distributed in tzcode), and the resulting binaries given to pecl. I really don't know all that this entails, so insight/links for individual steps would be appreciated.

How can one upgrade this Olson database that is used natively by one's instances of PHP on (1) a XAMPP development machine and/or (2) a typical shared hosting service... while jumping through as few hoops and administrative hurdles as possible? Are there any particulars which a shared hosting environment might make more difficult that one should be aware of? Is it feasible to have multiple copies of the data present so that changes could easily be undone if one somehow screws them up?

Since changes sometimes aren't officially released in time for them to take effect, I'm looking specifically for a way to be able to make these changes arbitrarily on my own. I'm also interested in exploring potential tradeoffs over a range of possible solutions from "quick/easy" to "rigorous/best".

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

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

发布评论

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

评论(1

給妳壹絲溫柔 2025-01-01 11:06:47

最终答案

上面的评论给出了比这更好的答案 - 查看 PECL 包 timezonedb

我已将其转换为社区 Wiki。


调查

来自 php-5.3.8.tar.bz2 等包的分布式源代码包含 ext/date/lib 目录和文件中 Olson 数据库的翻译timezonedb.htimezonemap.hfallbackmap.h。这意味着 PHP 开发系统中的某处有代码可以从 Olson 数据库的版本中生成此信息,但默认情况下不会分发。此外,它并不是作为 SVN 的一部分进行分发的;我提取了截至修订版 321876 的 PHP 5.3 源代码,ext/date 目录不包含任何帮助内容(仅包含生成的文件)。

因此,向 PHP 维护人员询问如何做到这一点可能是合适的;这当然应该是可能的,而且应该是自动化的(如果他们不让它自动化那就太愚蠢了)。但我不清楚 PHP 维护人员之外的人是否能告诉我该怎么做。

NEWS 文件中的注释表明 Derick Rethans 可能是一个值得联系的人 - 他将数据库更新为 Olson 2010c (2010.3)。您可以在源目录顶层的 run-tests.php 文件中找到他的 PHP 电子邮件地址;您可以在 ext/date/lib 目录中的源代码中找到备用电子邮件地址。

Derick Rethans 提供了用于从 Olson 数据库生成文件 timezonedb.h 的转换工具包:

http://svn.xdebug.org/cgi-bin/viewvc.cgi/timelib/trunk/zones/?root=php

截至 2016 年 12 月 9 日,上面的链接是 404,互联网档案馆的 WayBack Machine 无法提供帮助,因为不允许通过 robots.txt 文件进行搜索。

但是,Google 搜索“php timelib”会发现:

这几乎肯定是替代品。

Definitive Answer

The comments above give a much better answer than this - look at the PECL package timezonedb.

I've converted this to Community Wiki.


An Investigation

The distributed source from a package such as php-5.3.8.tar.bz2 contains a translation of the Olson database in the ext/date/lib directory and files timezonedb.h, timezonemap.h, fallbackmap.h. This means that there is code somewhere in the PHP development system that generates this information from a release of the Olson database, but it is not distributed by default. Further, it is not self-evidently distributed as part of SVN; I extracted PHP 5.3 source as of revision 321876 and the ext/date directory contained nothing to assist (just the generated files).

So, it might be appropriate to ask the PHP maintainers how to do it; it certainly should be possible, and it should be automated (it would be silly if they do not have it automated). But it is not clear to me that those outside the PHP maintainers can tell how to do it.

The comments in the NEWS file indicate that Derick Rethans might be a good person to contact - he updated the database to Olson 2010c (2010.3). You can find his email address at PHP in the run-tests.php file in the top-level of the source directory; you can find an alternative email address in the source in ext/date/lib directory.

Derick Rethans made available the conversion tool kit used to generate the file timezonedb.h from the Olson database here:

http://svn.xdebug.org/cgi-bin/viewvc.cgi/timelib/trunk/zones/?root=php

As of 2016-12-09, the link above is 404, and the WayBack Machine at the Internet Archive can't help because it was not allowed to search by a robots.txt file.

However, a Google search for 'php timelib' finds:

which is almost certainly the replacement.

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