From f76d8e55bccdcfe4c53230a54515df250499c164 Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Sat, 7 Oct 2006 15:14:57 +0000 Subject: [PATCH] Avoid portability problems --- ext/calendar/cal_unix.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ext/calendar/cal_unix.c b/ext/calendar/cal_unix.c index 9a619c7bda..a1cdd0d412 100644 --- a/ext/calendar/cal_unix.c +++ b/ext/calendar/cal_unix.c @@ -28,15 +28,21 @@ Convert UNIX timestamp to Julian Day */ PHP_FUNCTION(unixtojd) { - time_t timestamp = time(NULL); - long jdate; + time_t timestamp; + long jdate, t; struct tm *ta, tmbuf; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", ×tamp) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &t) == FAILURE) { return; } - if(timestamp < 0) { + if (ZEND_NUM_ARGS()) { + timestamp = (time_t) t; + } else { + timestamp = time(NULL); + } + + if (timestamp < 0) { RETURN_FALSE; } -- 2.50.1