diff options
Diffstat (limited to 'ext/date/php_date.c')
| -rw-r--r-- | ext/date/php_date.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index a68077dc7a..7fde443a71 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -3461,8 +3461,20 @@ static int date_interval_initialize(timelib_rel_time **rt, /*const*/ char *forma php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown or bad format (%s)", format); retval = FAILURE; } else { - *rt = p; - retval = SUCCESS; + if(p) { + *rt = p; + retval = SUCCESS; + } else { + if(b && e) { + timelib_update_ts(b, NULL); + timelib_update_ts(e, NULL); + *rt = timelib_diff(b, e); + retval = SUCCESS; + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to parse interval (%s)", format); + retval = FAILURE; + } + } } timelib_error_container_dtor(errors); return retval; |
