Convert UNIX timestamp to Julian Day */
PHP_FUNCTION(unixtojd)
{
- time_t ts = 0;
+ time_t ts;
+ zend_bool ts_is_null = 1;
struct tm *ta, tmbuf;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &ts) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &ts, &ts_is_null) == FAILURE) {
RETURN_THROWS();
}
- if (!ts) {
+ if (ts_is_null) {
ts = time(NULL);
} else if (ts < 0) {
zend_argument_value_error(1, "must be greater than or equal to 0");
return;
}
-
- if (cal != -1 && (cal < 0 || cal >= CAL_NUM_CALS)) {
+ if (cal < 0 || cal >= CAL_NUM_CALS) {
zend_argument_value_error(1, "must be a valid calendar ID");
RETURN_THROWS();
}
_php_cal_info(cal, return_value);
-
}
/* }}} */
function cal_from_jd(int $jd, int $calendar): array {}
-function cal_info(?int $calendar = UNKNOWN): array {}
+function cal_info(int $calendar = -1): array {}
function cal_to_jd(int $calendar, int $month, int $day, int $year): int {}
-function easter_date(int $year = UNKNOWN, int $method = CAL_EASTER_DEFAULT): int {}
+function easter_date(?int $year = null, int $method = CAL_EASTER_DEFAULT): int {}
-function easter_days(int $year = UNKNOWN, int $method = CAL_EASTER_DEFAULT): int {}
+function easter_days(?int $year = null, int $method = CAL_EASTER_DEFAULT): int {}
function frenchtojd(int $month, int $day, int $year): int {}
function juliantojd(int $month, int $day, int $year): int {}
-function unixtojd(int $timestamp = UNKNOWN): int|false {}
+function unixtojd(?int $timestamp = null): int|false {}
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_cal_info, 0, 0, IS_ARRAY, 0)
- ZEND_ARG_TYPE_INFO(0, calendar, IS_LONG, 1)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, calendar, IS_LONG, 0, "-1")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_cal_to_jd, 0, 4, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_easter_date, 0, 0, IS_LONG, 0)
- ZEND_ARG_TYPE_INFO(0, year, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, year, IS_LONG, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, method, IS_LONG, 0, "CAL_EASTER_DEFAULT")
ZEND_END_ARG_INFO()
#define arginfo_juliantojd arginfo_frenchtojd
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_unixtojd, 0, 0, MAY_BE_LONG|MAY_BE_FALSE)
- ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timestamp, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, zend_long gm)
{
-
/* based on code by Simon Kershaw, <webmaster@ely.anglican.org> */
struct tm te;
zend_long year, golden, solar, lunar, pfm, dom, tmp, easter, result;
zend_long method = CAL_EASTER_DEFAULT;
+ zend_bool year_is_null = 1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(),
+ "|l!l", &year, &year_is_null, &method) == FAILURE) {
+ RETURN_THROWS();
+ }
/* Default to the current year if year parameter is not given */
- {
+ if (year_is_null) {
time_t a;
struct tm b, *res;
time(&a);
}
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(),
- "|ll", &year, &method) == FAILURE) {
- RETURN_THROWS();
- }
-
if (gm && (year<1970 || year>2037)) { /* out of range for timestamps */
zend_argument_value_error(1, "must be between 1970 and 2037 (inclusive)");
RETURN_THROWS();