derick          Mon Jan 28 21:12:42 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src    NEWS 
    /php-src/ext/date   php_date.c 
  Log:
  - MFH: Added two optional parameters to timezone_transitions_get() /
    DateTimeZone::getTranstions() to limit the range of transitions being
    returned.
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.92&r2=1.2027.2.547.2.965.2.93&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.92 
php-src/NEWS:1.2027.2.547.2.965.2.93
--- php-src/NEWS:1.2027.2.547.2.965.2.92        Mon Jan 28 20:30:50 2008
+++ php-src/NEWS        Mon Jan 28 21:12:41 2008
@@ -20,6 +20,9 @@
     without invoking the date parser. (Scott)
   * date_timestamp_get() / DateTime::getTimestamp() to retrieve the Unix
     timestamp belonging to a date object.
+  * two optional parameters to timezone_transitions_get() /
+    DateTimeZone::getTranstions() to limit the range of transitions being
+    returned.
 
 - Added ability to store associative infor with objects in SplObjectStorage.
   (Marcus)
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.43.2.45.2.51.2.15&r2=1.43.2.45.2.51.2.16&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.43.2.45.2.51.2.15 
php-src/ext/date/php_date.c:1.43.2.45.2.51.2.16
--- php-src/ext/date/php_date.c:1.43.2.45.2.51.2.15     Mon Jan 28 20:35:17 2008
+++ php-src/ext/date/php_date.c Mon Jan 28 21:12:41 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_date.c,v 1.43.2.45.2.51.2.15 2008/01/28 20:35:17 derick Exp $ */
+/* $Id: php_date.c,v 1.43.2.45.2.51.2.16 2008/01/28 21:12:41 derick Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -2448,16 +2448,17 @@
 }
 /* }}} */
 
-/* {{{ proto array timezone_transitions_get(DateTimeZone object)
-   Returns numeracilly indexed array containing associative array for all 
transitions for the timezone.
+/* {{{ proto array timezone_transitions_get(DateTimeZone object [, long 
timestamp_begin [, long timestamp_end ]])
+   Returns numerically indexed array containing associative array for all 
transitions in the specified range for the timezone.
 */
 PHP_FUNCTION(timezone_transitions_get)
 {
        zval                *object, *element;
        php_timezone_obj    *tzobj;
-       int                  i;
+       int                  i, first = 1;
+       long                 timestamp_begin = LONG_MIN, timestamp_end = 
LONG_MAX;
 
-       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), 
"O", &object, date_ce_timezone) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), 
"O|ll", &object, date_ce_timezone, &timestamp_begin, &timestamp_end) == 
FAILURE) {
                RETURN_FALSE;
        }
        tzobj = (php_timezone_obj *) zend_object_store_get_object(object 
TSRMLS_CC);
@@ -2468,15 +2469,30 @@
 
        array_init(return_value);
        for (i = 0; i < tzobj->tzi.tz->timecnt; ++i) {
-               MAKE_STD_ZVAL(element);
-               array_init(element);
-               add_assoc_long(element, "ts",     tzobj->tzi.tz->trans[i]);
-               add_assoc_string(element, "time", 
php_format_date(DATE_FORMAT_ISO8601, 13, tzobj->tzi.tz->trans[i], 0 TSRMLS_CC), 
0);
-               add_assoc_long(element, "offset", 
tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].offset);
-               add_assoc_bool(element, "isdst",  
tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].isdst);
-               add_assoc_string(element, "abbr", 
&tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].abbr_idx],
 1);
+               if (tzobj->tzi.tz->trans[i] >= timestamp_begin && 
tzobj->tzi.tz->trans[i] < timestamp_end) {
+                       if (first && timestamp_begin != LONG_MIN && i > 0 && 
timestamp_begin != tzobj->tzi.tz->trans[i])
+                       {
+                               MAKE_STD_ZVAL(element);
+                               array_init(element);
+                               add_assoc_long(element, "ts",     
timestamp_begin);
+                               add_assoc_string(element, "time", 
php_format_date(DATE_FORMAT_ISO8601, 13, timestamp_begin, 0 TSRMLS_CC), 0);
+                               add_assoc_long(element, "offset", 
tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i-1]].offset);
+                               add_assoc_bool(element, "isdst",  
tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i-1]].isdst);
+                               add_assoc_string(element, "abbr", 
&tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i-1]].abbr_idx],
 1);
 
-               add_next_index_zval(return_value, element);
+                               add_next_index_zval(return_value, element);
+                       }
+                       MAKE_STD_ZVAL(element);
+                       array_init(element);
+                       add_assoc_long(element, "ts",     
tzobj->tzi.tz->trans[i]);
+                       add_assoc_string(element, "time", 
php_format_date(DATE_FORMAT_ISO8601, 13, tzobj->tzi.tz->trans[i], 0 TSRMLS_CC), 
0);
+                       add_assoc_long(element, "offset", 
tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].offset);
+                       add_assoc_bool(element, "isdst",  
tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].isdst);
+                       add_assoc_string(element, "abbr", 
&tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].abbr_idx],
 1);
+
+                       add_next_index_zval(return_value, element);
+                       first = 0;
+               }
        }
 }
 /* }}} */

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

Reply via email to