Today I noticed that my script to convert and display Olson timezone IDs into Cities and GMT offsets was producing some very weird results: Argentina zones caught my attention because they were displaying a standard (non-DST) time offset of ±0000 in reference to GMT/UTC.
I examined my code and I found a small bug in my logic, however it wasn't related to the discrepancy, so I updated timezonedb
via pecl
to version 2012.8
but it's still returning the wrong offset...
Here is some code that returns the last 3 changes to the America/Argentina/San_Luis
timezone:
$timezone = new DateTimeZone('America/Argentina/San_Luis');
$transitions = $timezone->getTransitions();
echo '<pre>';
print_r(array_slice($transitions, -3, null, true));
echo '</pre>';
And this is the output:
Array
(
[59] => Array
(
[ts] => 1223784000
[time] => 2008-10-12T04:00:00+0000
[offset] => -10800
[isdst] => 1
[abbr] => WARST
)
[60] => Array
(
[ts] => 1236481200
[time] => 2009-03-08T03:00:00+0000
[offset] => -14400
[isdst] =>
[abbr] => WART
)
[61] => Array
(
[ts] => 1255233600
[time] => 2009-10-11T04:00:00+0000
[offset] => -10800
[isdst] => 1
[abbr] => WARST
)
)
As you can see, the indexes 59
and 61
are DST offsets while the index 60
is a standard time offset.
However, if you check Time&Date the standard offset should be -10800
(3 hours) and not -14400
:
Standard time zone: UTC/GMT -3 hours
No daylight saving time in 2012
Time zone abbreviation: ART - Argentina Time
In fact, even the abbr
is wrong (should be ART
since on 2009-10-10 DST was discontinued).
What's going wrong here? I'm pretty sure this is irrelevant but I'm running PHP 5.4.6 if it matters.
PS: I remember reading about some legal issues with the Olson database, might this be related?
UPDATE: I wrote a little script to compare the PHP non-DST offsets with this Wikipedia page:
function getStandardOffset($timezone)
{
$timezone = new DateTimeZone($timezone);
//$hemisphere = (ph()->Value($timezone->getLocation(), 'latitude') >= 0) ? 'north' : 'south';
$transitions = array_reverse(array_slice($timezone->getTransitions(), -3, null, true), true);
foreach ($transitions as $transition)
{
if ($transition['isdst'] == 1)
{
continue;
}
return sprintf('%+03d:%02u', $transition['offset'] / 3600, abs($transition['offset']) % 3600 / 60);
}
return false;
}
$diff = array();
$html = ph()->HTML->DOM(file_get_contents('http://en.wikipedia.org/wiki/List_of_tz_database_time_zones'));
$timezones = DateTimeZone::listIdentifiers();
foreach ($timezones as $timezone)
{
$offset = str_replace('−', '-', ph()->HTML->DOM($html, sprintf('//td/a[contains(text(), "%s")]/../..', $timezone), '0.td.4.a'));
if (strcmp($offset, getStandardOffset($timezone)) !== 0)
{
$diff[$timezone] = array
(
'php' => getStandardOffset($timezone),
'wiki' => $offset,
);
}
}
echo '<pre>';
print_r($diff);
echo '</pre>';
The following time zones differ:
Array
(
[America/Argentina/San_Luis] => Array
(
[php] => -04:00
[wiki] => -03:00
)
[Antarctica/Casey] => Array
(
[php] => +08:00
[wiki] => +11:00
)
[Antarctica/Davis] => Array
(
[php] => +07:00
[wiki] => +05:00
)
)
It's not a huge deal but I'm curious why this happens since I have the latest version of the Olson tzdb.
I'll take your first example here:
[60] => Array
(
[ts] => 1236481200
[time] => 2009-03-08T03:00:00+0000
[offset] => -14400
[isdst] =>
[abbr] => WART
)
However, if you check Time&Date the standard offset should be -10800 (3 hours) and not -14400
From what I've read, this is not true; according to this article, around that time (March 3rd 2009) the timezone was changed to UTC-4 when there's no daylight saving and UTC-3 if there is. Though, the mentioned date in the article is March 14/15 and not March 8 ... I'm not sure what has caused that difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With