iliaa           Wed Feb 13 23:50:35 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/calendar       cal_unix.c 
  Log:
  
  New calendar parsing API
  
http://cvs.php.net/viewvc.cgi/php-src/ext/calendar/cal_unix.c?r1=1.17.2.2.2.2.2.1&r2=1.17.2.2.2.2.2.2&diff_format=u
Index: php-src/ext/calendar/cal_unix.c
diff -u php-src/ext/calendar/cal_unix.c:1.17.2.2.2.2.2.1 
php-src/ext/calendar/cal_unix.c:1.17.2.2.2.2.2.2
--- php-src/ext/calendar/cal_unix.c:1.17.2.2.2.2.2.1    Mon Dec 31 07:17:06 2007
+++ php-src/ext/calendar/cal_unix.c     Wed Feb 13 23:50:35 2008
@@ -28,35 +28,24 @@
    Convert UNIX timestamp to Julian Day */
 PHP_FUNCTION(unixtojd)
 {
-  zval *timestamp;
-  long jdate; 
-  time_t t;
-  struct tm *ta, tmbuf;
-  int myargc=ZEND_NUM_ARGS();
-       
-  if ((myargc > 1) || (zend_get_parameters(ht, myargc, &timestamp) != 
SUCCESS)) {
-    WRONG_PARAM_COUNT;
-  }
-
-  if(myargc==1) {
-    convert_to_long(timestamp);
-    t = Z_LVAL_P(timestamp);
-  } else {
-    t = time(NULL);
-  }
-
-  if(t < 0) {
-       RETURN_FALSE;
-  }
-
-  ta = php_localtime_r(&t, &tmbuf);
-  if (!ta) {
-         RETURN_FALSE;
-  }
-
-  jdate = GregorianToSdn(ta->tm_year+1900, ta->tm_mon+1, ta->tm_mday);
-  
-  RETURN_LONG(jdate);
+       time_t ts = 0;
+       struct tm *ta, tmbuf;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &ts) == 
FAILURE) {
+               return;
+       }       
+
+       if (!ts) {
+               ts = time(NULL);
+       } else if (ts < 0) {
+               RETURN_FALSE;
+       }
+
+       if (!(ta = php_localtime_r(&ts, &tmbuf))) {
+               RETURN_FALSE;
+       }
+
+       RETURN_LONG(GregorianToSdn(ta->tm_year+1900, ta->tm_mon+1, 
ta->tm_mday));
 }
 /* }}} */
 
@@ -64,21 +53,18 @@
    Convert Julian Day to UNIX timestamp */
 PHP_FUNCTION(jdtounix)
 {
-  zval *jday;
-  long uday;
+       long uday;
 
-  if ((ZEND_NUM_ARGS()!= 1) || (zend_get_parameters(ht, 1, &jday) != SUCCESS)) 
{
-    WRONG_PARAM_COUNT;
-  }
-  
-  convert_to_long(jday);
-
-  uday = Z_LVAL_P(jday) - 2440588 /* J.D. of 1.1.1970 */;
-  
-  if(uday<0)     RETURN_FALSE; /* before beginning of unix epoch */ 
-  if(uday>24755) RETURN_FALSE; /* behind end of unix epoch */
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &uday) == 
FAILURE) {
+               return;
+       }       
+       uday -= 2440588 /* J.D. of 1.1.1970 */;
+
+       if (uday < 0 || uday > 24755) { /* before beginning of unix epoch or 
behind end of unix epoch */ 
+               RETURN_FALSE;
+       }
 
-  RETURN_LONG(uday*24*3600);
+       RETURN_LONG(uday * 24 * 3600);
 }
 /* }}} */
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to