derick          Mon Jan 28 20:29:40 2008 UTC

  Modified files:              
    /php-src/ext/date   php_date.c php_date.h 
  Log:
  - Added DateTime::getTimestamp() / date_timestamp_get().
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.159&r2=1.160&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.159 php-src/ext/date/php_date.c:1.160
--- php-src/ext/date/php_date.c:1.159   Sun Jan 27 17:44:16 2008
+++ php-src/ext/date/php_date.c Mon Jan 28 20:29:40 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_date.c,v 1.159 2008/01/27 17:44:16 derick Exp $ */
+/* $Id: php_date.c,v 1.160 2008/01/28 20:29:40 derick Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -184,6 +184,7 @@
        PHP_FE(date_date_set, NULL)
        PHP_FE(date_isodate_set, NULL)
        PHP_FE(date_timestamp_set, NULL)
+       PHP_FE(date_timestamp_get, NULL)
 
        PHP_FE(timezone_open, NULL)
        PHP_FE(timezone_name_get, NULL)
@@ -218,6 +219,7 @@
        PHP_ME_MAPPING(setDate,     date_date_set,     NULL, 0)
        PHP_ME_MAPPING(setISODate,  date_isodate_set,  NULL, 0)
        PHP_ME_MAPPING(setTimestamp,date_timestamp_set, NULL, 0)
+       PHP_ME_MAPPING(getTimestamp,date_timestamp_get, NULL, 0)
        {NULL, NULL, NULL}
 };
 
@@ -2425,6 +2427,32 @@
 }
 /* }}} */
 
+/* {{{ proto long date_timestamp_get(DateTime object)
+   Gets the Unix timestamp.
+*/
+PHP_FUNCTION(date_timestamp_get)
+{
+       zval         *object;
+       php_date_obj *dateobj;
+       long          timestamp;
+       int           error;
+
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), 
"O", &object, date_ce_date) == FAILURE) {
+               RETURN_FALSE;
+       }
+       dateobj = (php_date_obj *) zend_object_store_get_object(object 
TSRMLS_CC);
+       DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
+       timelib_update_ts(dateobj->time, NULL);
+
+       timestamp = timelib_date_to_int(dateobj->time, &error);
+       if (error) {
+               RETURN_FALSE;
+       } else {
+               RETVAL_LONG(timestamp);
+       }
+}
+/* }}} */
+
 static int timezone_initialize(timelib_tzinfo **tzi, /*const*/ char *tz 
TSRMLS_DC)
 {
        char *tzid;
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.h?r1=1.35&r2=1.36&diff_format=u
Index: php-src/ext/date/php_date.h
diff -u php-src/ext/date/php_date.h:1.35 php-src/ext/date/php_date.h:1.36
--- php-src/ext/date/php_date.h:1.35    Sun Jan 13 15:16:47 2008
+++ php-src/ext/date/php_date.h Mon Jan 28 20:29:40 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_date.h,v 1.35 2008/01/13 15:16:47 derick Exp $ */
+/* $Id: php_date.h,v 1.36 2008/01/28 20:29:40 derick Exp $ */
 
 #ifndef PHP_DATE_H
 #define PHP_DATE_H
@@ -64,6 +64,7 @@
 PHP_FUNCTION(date_date_set);
 PHP_FUNCTION(date_isodate_set);
 PHP_FUNCTION(date_timestamp_set);
+PHP_FUNCTION(date_timestamp_get);
 
 PHP_METHOD(DateTimeZone, __construct);
 PHP_FUNCTION(timezone_open);

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

Reply via email to