derick          Thu Sep  1 08:42:40 2005 EDT

  Modified files:              (Branch: PHP_5_1)
    /php-src    NEWS 
    /php-src/ext/date/lib       parse_tz.c 
    /php-src/ext/date/tests     bug33414-2.phpt 
  Log:
  - MFH: Fixed bug #33414 (Comprehensive list of incorrect days returned after
    strtotime() / date() tests).
  
  
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2027.2.41&r2=1.2027.2.42&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.41 php-src/NEWS:1.2027.2.42
--- php-src/NEWS:1.2027.2.41    Thu Sep  1 08:00:35 2005
+++ php-src/NEWS        Thu Sep  1 08:42:33 2005
@@ -76,6 +76,8 @@
 - Fixed bug #33578 (strtotime() problem with "Oct17" format). (Derick)
 - Fixed bug #33558 (warning with nested calls to functions returning by
   reference). (Dmitry)
+- Fixed bug #33414 (Comprehensive list of incorrect days returned after
+  strtotime() / date() tests). (Derick)
 - Fixed bug #33326 (Cannot build extensions with phpize on Macosx). (Jani)
 - Fixed bug #32981 (ReflectionMethod::getStaticVariables() causes apache2.0.54
   seg fault). (Dmitry)
http://cvs.php.net/diff.php/php-src/ext/date/lib/parse_tz.c?r1=1.20&r2=1.20.2.1&ty=u
Index: php-src/ext/date/lib/parse_tz.c
diff -u php-src/ext/date/lib/parse_tz.c:1.20 
php-src/ext/date/lib/parse_tz.c:1.20.2.1
--- php-src/ext/date/lib/parse_tz.c:1.20        Wed Aug  3 10:06:49 2005
+++ php-src/ext/date/lib/parse_tz.c     Thu Sep  1 08:42:39 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: parse_tz.c,v 1.20 2005/08/03 14:06:49 sniper Exp $ */
+/* $Id: parse_tz.c,v 1.20.2.1 2005/09/01 12:42:39 derick Exp $ */
 
 #include "timelib.h"
 
@@ -164,6 +164,15 @@
        printf("Local types count: %lu\n", (unsigned long) tz->typecnt);
        printf("Zone Abbr. count:  %lu\n", (unsigned long) tz->charcnt);
 
+       printf ("%8s (%12s) = %3d [%5ld %1d %3d '%s' (%d,%d)]\n",
+               "", "", 0,
+               (long int) tz->type[0].offset,
+               tz->type[0].isdst,
+               tz->type[0].abbr_idx,
+               &tz->timezone_abbr[tz->type[0].abbr_idx],
+               tz->type[0].isstdcnt,
+               tz->type[0].isgmtcnt
+               );
        for (i = 0; i < tz->timecnt; i++) {
                printf ("%08X (%12d) = %3d [%5ld %1d %3d '%s' (%d,%d)]\n",
                        tz->trans[i], tz->trans[i], tz->trans_idx[i],
@@ -244,6 +253,8 @@
 {
        uint32_t i;
 
+       /* If there is no transistion time, we pick the first one, if that 
doesn't
+        * exist we return NULL */
        if (!tz->timecnt || !tz->trans) {
                *transition_time = 0;
                if (tz->typecnt == 1) {
@@ -252,10 +263,26 @@
                return NULL;
        }
 
+       /* If the TS is lower than the first transistion time, then we scan over
+        * all the transistion times to find the first non-DST one, or the first
+        * one in case there are only DST entries. Not sure which smartass came 
up
+        * with this idea in the first though :) */
        if (ts < tz->trans[0]) {
+               uint32_t j;
+
                *transition_time = 0;
-               return &(tz->type[tz->trans_idx[tz->timecnt - 1]]);
+               j = 0;
+               while (j < tz->timecnt && tz->type[j].isdst) {
+                       ++j;
+               }
+               if (j == tz->timecnt) {
+                       j = 0;
+               }
+               return &(tz->type[j]);
        }
+
+       /* In all other cases we loop through the available transtion times to 
find
+        * the correct entry */
        for (i = 0; i < tz->timecnt; i++) {
                if (ts < tz->trans[i]) {
                        *transition_time = tz->trans[i - 1];
http://cvs.php.net/diff.php/php-src/ext/date/tests/bug33414-2.phpt?r1=1.2.2.1&r2=1.2.2.2&ty=u
Index: php-src/ext/date/tests/bug33414-2.phpt
diff -u php-src/ext/date/tests/bug33414-2.phpt:1.2.2.1 
php-src/ext/date/tests/bug33414-2.phpt:1.2.2.2
--- php-src/ext/date/tests/bug33414-2.phpt:1.2.2.1      Tue Aug  9 17:10:22 2005
+++ php-src/ext/date/tests/bug33414-2.phpt      Thu Sep  1 08:42:39 2005
@@ -106,8 +106,8 @@
 wanted=Tuesday            00:00:00
 
 TZ=Pacific/Pitcairn - wrong day.
-tStamp=Thursday 1970-01-01 17:17:17 PST 0
-result=Wednesday 1970-01-06 00:00:00 PST 0
+tStamp=Thursday 1970-01-01 17:17:17 PNT 0
+result=Wednesday 1970-01-07 00:00:00 PNT 0
 wanted=Wednesday            00:00:00
 
 TZ=Pacific/Fakaofo - wrong day.

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to