summaryrefslogtreecommitdiff
path: root/ext/date/php_date.c
diff options
context:
space:
mode:
authorIgnace Nyamagana Butera <nyamsprod@gmail.com>2019-02-26 21:21:46 +0100
committerDerick Rethans <github@derickrethans.nl>2019-03-17 14:37:35 -0400
commit6eb83a63e1833f0991af4ccccc5533269c8af96c (patch)
treed7a53230c36432e6ed244f9144b408794a526078 /ext/date/php_date.c
parentf167b06d4c86c96291c21c027ba3cae22f5b5be8 (diff)
downloadphp-git-6eb83a63e1833f0991af4ccccc5533269c8af96c.tar.gz
Fixed bug #75113: Added DatePeriod::getRecurrences() method.
Diffstat (limited to 'ext/date/php_date.c')
-rw-r--r--ext/date/php_date.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 5cc3f794cd..f6f0c6468a 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -543,6 +543,7 @@ const zend_function_entry date_funcs_period[] = {
PHP_ME(DatePeriod, getStartDate, NULL, ZEND_ACC_PUBLIC)
PHP_ME(DatePeriod, getEndDate, NULL, ZEND_ACC_PUBLIC)
PHP_ME(DatePeriod, getDateInterval, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(DatePeriod, getRecurrences, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
@@ -4736,6 +4737,28 @@ PHP_METHOD(DatePeriod, getDateInterval)
}
/* }}} */
+/* {{{ proto int DatePeriod::getRecurrences()
+ Get recurrences.
+*/
+PHP_METHOD(DatePeriod, getRecurrences)
+{
+ php_period_obj *dpobj;
+ php_date_obj *dateobj;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ dpobj = Z_PHPPERIOD_P(ZEND_THIS);
+
+ if (0 == dpobj->recurrences - dpobj->include_start_date) {
+ return;
+ }
+
+ RETURN_LONG(dpobj->recurrences - dpobj->include_start_date);
+}
+/* }}} */
+
static int check_id_allowed(char *id, zend_long what) /* {{{ */
{
if (what & PHP_DATE_TIMEZONE_GROUP_AFRICA && strncasecmp(id, "Africa/", 7) == 0) return 1;