ID:               48097
 Updated by:       [email protected]
 Reported By:      energie at eox dot hu
-Status:           Open
+Status:           Assigned
 Bug Type:         Date/time related
 Operating System: linux/windows
 PHP Version:      5.2.9
-Assigned To:      
+Assigned To:      derick


Previous Comments:
------------------------------------------------------------------------

[2009-04-28 09:02:24] energie at eox dot hu

Description:
------------
Result of "date_create" with timezon given:
"Mon, 23 May 1955 00:00:00 +0200"
After calling "date_timezone_set" for this date the expected result
would be the same but instead the result is:
"Mon, 23 May 1955 01:00:00 +0200"

In case of "Europe/Budapest" timezone 3 dates are affected between
1900.01.01 and 1999.12.31:
[0] => Sun, 23 May 1954 00:00:00 +0200
[0] => Mon, 23 May 1955 00:00:00 +0200
[0] => Sun, 03 Jun 1956 00:00:00 +0200

There are timezones where everything works fine, and many ohters that
have date inputs that cause this mis-calculation. Thers is no relation
between the dates in different timezones but the wrong dates are always
the same in a given timezone, so there are no "random" errors.

Reproduce code:
---------------
$errors = array();
$timezones = array('Europe/Budapest');
// Uncomment the following line to run on all timezones
// $timezones = timezone_identifiers_list();

function generate_dates($timezone) {
  $dates = array();
  for($y = 1900; $y <= 1999; $y++) {
    for($m = 1; $m <= 12; $m++) {
      for($d = 1; $d <= 31; $d++) {
        $date = date_create(sprintf('%s-%s-%s 00:00:00', $y, $m, $d),
timezone_open($timezone));
        if ($date) {
          $dates[] = $date;
        }
      }
    }
  }
  return $dates;
}

foreach($timezones as $timezone) {
  $dates = generate_dates($timezone);
  foreach($dates as $date) {
    $test = date_format($date, 'r');
    date_timezone_set($date, timezone_open($timezone));
    if ($test != date_format($date, 'r')) {
      $errors[$timezone][] = array($test, date_format($date, 'r'));
    }
  }
  print('Timezone: '. $timezone . ', errors: '.
count($errors[$timezone]) . "\n");
  // Uncomment the following line to display all dates that calculated
"wrong"
  // print_r($errors[$timezone]);
  // print "\n";
}

Expected result:
----------------
Timezone: Europe/Budapest, errors: 0

Actual result:
--------------
Timezone: Europe/Budapest, errors: 3


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48097&edit=1

Reply via email to