]> granicus.if.org Git - php/commitdiff
Bug #60774 (DateInterval::format("%a") is always zero when an interval is
authorEC2 Default User <ec2-user@ip-10-66-82-148.ec2.internal>
Sun, 5 Aug 2012 17:14:51 +0000 (17:14 +0000)
committerDerick Rethans <github@derickrethans.nl>
Sun, 31 Mar 2013 09:59:21 +0000 (10:59 +0100)
created using the createFromDateString method)

ext/date/lib/parse_date.c
ext/date/lib/parse_date.re
ext/date/tests/bug60774.phpt [new file with mode: 0644]

index e8f393f322e25f7e41cbb21ea41bc6ec9bdb27a9..9f5593dacb567b70d70c4bea714aa5e242398659 100644 (file)
@@ -24789,6 +24789,7 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
        in.tzdb = tzdb;
        in.time->is_localtime = 0;
        in.time->zone_type = 0;
+       in.time->relative.days = TIMELIB_UNSET;
 
        do {
                t = scan(&in, tz_get_wrapper);
index f3f5906b0a819dc3593cb29bbaa298f272020ba2..8aaa6c336ed07147c3196bc131d7092dfc92d629 100644 (file)
@@ -1796,6 +1796,7 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
        in.tzdb = tzdb;
        in.time->is_localtime = 0;
        in.time->zone_type = 0;
+       in.time->relative.days = TIMELIB_UNSET;
 
        do {
                t = scan(&in, tz_get_wrapper);
diff --git a/ext/date/tests/bug60774.phpt b/ext/date/tests/bug60774.phpt
new file mode 100644 (file)
index 0000000..af8f447
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+Bug #60774 (DateInterval::format("%a") is always zero when an interval is created using the createFromDateString method)
+--FILE--
+<?php
+$i= DateInterval::createFromDateString('2 days');
+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(2)
+  ["h"]=>
+  int(0)
+  ["i"]=>
+  int(0)
+  ["s"]=>
+  int(0)
+  ["invert"]=>
+  int(0)
+  ["days"]=>
+  bool(false)
+}
+2
+(unknown)