PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Date and Time » Date » Bug #685

some speed improvement

Details

Request #685some speed improvement
Submitted2004-02-05 09:12 UTC
Fromshuther at gmx dot net
StatusSuspended
PackageDate
PHP Version4.3.4
OSWindows 2000
Roadmaps(Not assigned)

Comments

[2004-02-05 09:12 UTC] shuther at gmx dot net

Description:
------------
Here is some code to improve the speed of the compare function.
A note migth be added also: 'For server production, please specify in the environment:'
set TZ = 'UTC'

A constant can be setup if we know that we are working only with one timezone; very usefull if we do a lot of compare (in my case, I show a calendar, and a Date function is called 2000 times because of this.)

Reproduce code:
---------------
52a53,57
>
> if (!defined('DATE_TWEAK_SAME_TZ')) {
> define('DATE_TWEAK_SAME_TZ', false);
> }
>
704,705c750,759
< $d1->convertTZ(new Date_TimeZone('UTC'));
< $d2->convertTZ(new Date_TimeZone('UTC'));
---
> /* We define a constant that speed the search, case if we are always working with the same TZ */
> if (DATE_TWEAK_SAME_TZ) {
> static $dateTimezone;
>
> if (!isset($dateTimezone))
> $dateTimezone = new Date_TimeZone('UTC');
>
> $d1->convertTZ($dateTimezone);
> $d2->convertTZ($dateTimezone);
> }

diff -w -b -r1.3 TimeZone.php
252c252,255
< $env_tz = "";
---
> static $env_tz;
>
> /* Some change for speed purposes */
> if (!isset($env_tz)) {
254a258,259
> } else {
> $env_tz = '';
255a261,265
> }
>
> if ($this->id == $env_tz) {
> $ltime = localtime($date->getTime(), true);
> } else {
258a269
> }