- Fixed bug #50383 (Exceptions thrown in __call / __callStatic do not include
file and line in trace). (Felipe)
- Fixed bug #50358 (Compile failure compiling ext/phar/util.lo). (Felipe)
+- Fixed bug #49778 (DateInterval::format("%a") is always zero when an interval
+ is created from an ISO string). (Derick)
?? ??? 20??, PHP 5.3.2
-/* Generated by re2c 0.13.5 on Tue May 5 09:42:15 2009 */
+/* Generated by re2c 0.13.5 on Sun Mar 7 14:12:01 2010 */
#line 1 "ext/date/lib/parse_iso_intervals.re"
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2010 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
in.period->weekday = 0;
in.period->weekday_behavior = 0;
in.period->first_last_day_of = 0;
+ in.period->days = TIMELIB_UNSET;
in.recurrences = 1;
PHP_DATE_INTERVAL_ADD_PROPERTY("i", i);
PHP_DATE_INTERVAL_ADD_PROPERTY("s", s);
PHP_DATE_INTERVAL_ADD_PROPERTY("invert", invert);
- PHP_DATE_INTERVAL_ADD_PROPERTY("days", days);
+ if (intervalobj->diff->days != -99999) {
+ PHP_DATE_INTERVAL_ADD_PROPERTY("days", days);
+ } else {
+ MAKE_STD_ZVAL(zv);
+ ZVAL_FALSE(zv);
+ zend_hash_update(props, "days", 5, &zv, sizeof(zval), NULL);
+ }
return props;
}
case 'S': length = slprintf(buffer, 32, "%02d", (int) t->s); break;
case 's': length = slprintf(buffer, 32, "%d", (int) t->s); break;
- case 'a': length = slprintf(buffer, 32, "%d", (int) t->days); break;
+ case 'a': {
+ if ((int) t->days != -99999) {
+ length = slprintf(buffer, 32, "%d", (int) t->days);
+ } else {
+ length = slprintf(buffer, 32, "(unknown)");
+ }
+ } break;
case 'r': length = slprintf(buffer, 32, "%s", t->invert ? "-" : ""); break;
case 'R': length = slprintf(buffer, 32, "%c", t->invert ? '-' : '+'); break;
--- /dev/null
+--TEST--
+Bug #49778 (DateInterval::format("%a") is always zero when an interval is created from an ISO string)
+--FILE--
+<?php
+$i=new DateInterval('P7D');
+var_dump($i);
+echo $i->format("%d"), "\n";
+echo $i->format("%a"), "\n";
+?>
+--EXPECT--
+object(DateInterval)#1 (8) {
+ ["y"]=>
+ int(0)
+ ["m"]=>
+ int(0)
+ ["d"]=>
+ int(7)
+ ["h"]=>
+ int(0)
+ ["i"]=>
+ int(0)
+ ["s"]=>
+ int(0)
+ ["invert"]=>
+ int(0)
+ ["days"]=>
+ bool(false)
+}
+7
+(unknown)