]> granicus.if.org Git - php/commitdiff
Avoid portability problems
authorHannes Magnusson <bjori@php.net>
Sat, 7 Oct 2006 15:14:57 +0000 (15:14 +0000)
committerHannes Magnusson <bjori@php.net>
Sat, 7 Oct 2006 15:14:57 +0000 (15:14 +0000)
ext/calendar/cal_unix.c

index 9a619c7bda81b2641bb1276a92b023cb4ccd92d5..a1cdd0d4122bc931950aee2cd82bda6aa57acd83 100644 (file)
    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", &timestamp) == 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;
   }