Edit report at https://bugs.php.net/bug.php?id=63941&edit=1
ID: 63941 Updated by: der...@php.net Reported by: njaguar at gmail dot com Summary: Date timezone code-cleanup Status: Open Type: Bug Package: Performance problem Operating System: * PHP Version: 5.4Git-2013-01-08 (snap) Block user comment: N Private report: N New Comment: What does this patch actually do? There is a lot of weirdness in it, and I thought the performance patch was already committed? Previous Comments: ------------------------------------------------------------------------ [2013-01-08 16:01:53] njaguar at gmail dot com Description: ------------ Per discussion with suggestions from Nuno Lopes, did some code cleanup over bug/patch https://bugs.php.net/bug.php?id=63699 Removed int for checked timezone, and also opting for a singular variable (timzeone) that is checked and set as appropriate. Simplifies code guess_timezone(). Minor speed increases (due to less if/checks from original code): date : 1.143 sec strftime : 0.961 sec strtotime : 2.166 sec (also re: Christopher Jones) Test script: --------------- <?php // test script to verify all is working as intended, and throws errors accordingly. Change php.ini date.timezone value to invalid setting to test that ed(); ini_set('date.timezone', 'FAKE_TIMEZONE'); ed(); ini_set('date.timezone', 'America/Chicago'); ed(); date_default_timezone_set('FAKE_TIMEZONE'); ed(); date_default_timezone_set('America/Los_Angeles'); ed(); function ed() { echo date('F j, Y, g:i a : e') . ' : ' . date_default_timezone_get() .' : ' . ini_get('date.timezone') ."<br>\n"; } ?> Expected result: ---------------- > php ~paul/test_date.php January 8, 2013, 9:58 am : America/Chicago : America/Chicago : America/Chicago<br> PHP Warning: ini_set(): Invalid date.timezone value 'FAKE_TIMEZONE'. in /home/paul/test_date.php on line 5 Warning: ini_set(): Invalid date.timezone value 'FAKE_TIMEZONE'. in /home/paul/test_date.php on line 5 January 8, 2013, 9:58 am : America/Chicago : America/Chicago : FAKE_TIMEZONE<br> January 8, 2013, 9:58 am : America/Chicago : America/Chicago : America/Chicago<br> PHP Notice: date_default_timezone_set(): Timezone ID 'FAKE_TIMEZONE' is invalid in /home/paul/test_date.php on line 11 Notice: date_default_timezone_set(): Timezone ID 'FAKE_TIMEZONE' is invalid in /home/paul/test_date.php on line 11 January 8, 2013, 9:58 am : America/Chicago : America/Chicago : America/Chicago<br> January 8, 2013, 7:58 am : America/Los_Angeles : America/Los_Angeles : America/Chicago<br> Actual result: -------------- n/a ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63941&edit=1