com php-src: Bug #60774 (DateInterval::format("%a") is always zero when an interval is created using the createFromDateString method):
ext/date/lib/parse_date.c ext/date/lib/parse_date.re ext/date/tests/bug60774.phpt
| From: | Derick Rethans | Date: | Sun, 31 Mar 2013 09:59:21 +0000 |
| Subject: | com php-src: Bug #60774 (DateInterval::format("%a") is always zero when an interval is created using the createFromDateString method): ext/date/lib/parse_date.c ext/date/lib/parse_date.re ext/date/tests/bug60774.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-71815@lists.php.net to get a copy of this message | ||
Commit: b07ecb5501bcc07c830b552aee39098439fe2027
Author: EC2 Default User <ec2-user@ip-10-66-82-148.ec2.internal> Sun, 5 Aug 2012
17:14:51 +0000
Committer: Derick Rethans <github@derickrethans.nl> Sun, 31 Mar 2013 10:59:21 +0100
Parents: 84208d9dc550e7feab7c44d5e4ea3061a5952dab
Branches: PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b07ecb5501bcc07c830b552aee39098439fe2027
Log:
Bug #60774 (DateInterval::format("%a") is always zero when an interval is
created using the createFromDateString method)
Bugs:
https://bugs.php.net/60774
Changed paths:
M ext/date/lib/parse_date.c
M ext/date/lib/parse_date.re
A ext/date/tests/bug60774.phpt
Diff:
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c
index e8f393f..9f5593d 100644
--- a/ext/date/lib/parse_date.c
+++ b/ext/date/lib/parse_date.c
@@ -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);
diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re
index f3f5906..8aaa6c3 100644
--- a/ext/date/lib/parse_date.re
+++ b/ext/date/lib/parse_date.re
@@ -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
index 0000000..af8f447
--- /dev/null
+++ b/ext/date/tests/bug60774.phpt
@@ -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)