【发布时间】:2012-02-11 09:15:14
【问题描述】:
在 PHP(自 5.2.0 起)中,我可以编写以下代码:
//$t is timestamp of day I want to look at
$tz=new DateTimeZone('America/New_York');
$transition = $tz->getTransitions($t,$t);
if(!$transition || count($transition)==0)throw new Exception("Bad timezone")
$offset=$transition[0]['offset']; //This is seconds ahead of GMT.
//I.e. -14400 in summer, -18000 in winter.
当我发现这个类/成语时,我几乎高兴得哭了;但是有没有办法在 R 中做同样的事情?还是我必须求助于我以前在 PHP 中所做的事情,即为我需要考虑的每个时区硬编码一组夏季开始/结束日期?
(顺便说一句,有关 PHP 代码的更多信息,请参阅:How to tell if a timezone observes daylight saving at any time of the year?)
【问题讨论】:
-
感谢您的快速回复(他们是一样的;我只是因为我已经在使用 POSIXlt 就给 Oscar 打勾了)。我意识到我也可以一直在 PHP 中这样做!