scottmac                Fri Dec 14 14:27:18 2007 UTC

  Modified files:              
    /php-src/ext/date   php_date.c php_date.h 
  Log:
  - Add Datetime::createFromTimestamp to allow setting of a unix timestamp 
without invoking the date parser.
  
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.148&r2=1.149&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.148 php-src/ext/date/php_date.c:1.149
--- php-src/ext/date/php_date.c:1.148   Fri Nov 23 00:15:37 2007
+++ php-src/ext/date/php_date.c Fri Dec 14 14:27:18 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_date.c,v 1.148 2007/11/23 00:15:37 iliaa Exp $ */
+/* $Id: php_date.c,v 1.149 2007/12/14 14:27:18 scottmac Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -180,6 +180,7 @@
        PHP_FE(date_time_set, NULL)
        PHP_FE(date_date_set, NULL)
        PHP_FE(date_isodate_set, NULL)
+       PHP_FE(date_timestamp_set, NULL)
 
        PHP_FE(timezone_open, NULL)
        PHP_FE(timezone_name_get, NULL)
@@ -211,6 +212,7 @@
        PHP_ME_MAPPING(setTime,     date_time_set,     NULL, 0)
        PHP_ME_MAPPING(setDate,     date_date_set,     NULL, 0)
        PHP_ME_MAPPING(setISODate,  date_isodate_set,  NULL, 0)
+       PHP_ME_MAPPING(createFromTimestamp,     date_timestamp_set, NULL, 0)
        {NULL, NULL, NULL}
 };
 
@@ -2171,6 +2173,25 @@
 }
 /* }}} */
 
+/* {{{ proto void date_timestamp_set(DateTime object, long unixTimestamp)
+   Sets the date and time based on an Unix timestamp.
+*/
+PHP_FUNCTION(date_timestamp_set)
+{
+       zval         *object;
+       php_date_obj *dateobj;
+       long          timestamp;
+
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), 
"Ol", &object, date_ce_date, &timestamp) == FAILURE) {
+               RETURN_FALSE;
+       }
+       dateobj = (php_date_obj *) zend_object_store_get_object(object 
TSRMLS_CC);
+       DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
+       timelib_unixtime2gmt(dateobj->time, (timelib_sll)timestamp);
+       timelib_update_ts(dateobj->time, NULL);
+}
+/* }}} */
+
 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.32&r2=1.33&diff_format=u
Index: php-src/ext/date/php_date.h
diff -u php-src/ext/date/php_date.h:1.32 php-src/ext/date/php_date.h:1.33
--- php-src/ext/date/php_date.h:1.32    Mon Jan  1 09:29:22 2007
+++ php-src/ext/date/php_date.h Fri Dec 14 14:27:18 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_date.h,v 1.32 2007/01/01 09:29:22 sebastian Exp $ */
+/* $Id: php_date.h,v 1.33 2007/12/14 14:27:18 scottmac Exp $ */
 
 #ifndef PHP_DATE_H
 #define PHP_DATE_H
@@ -60,6 +60,7 @@
 PHP_FUNCTION(date_time_set);
 PHP_FUNCTION(date_date_set);
 PHP_FUNCTION(date_isodate_set);
+PHP_FUNCTION(date_timestamp_set);
 
 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