mirror of
https://github.com/php/php-src.git
synced 2026-04-26 09:28:21 +02:00
- MFH: Added date_timestamp_get() / DateTime::getTimestamp() to retrieve the
Unix timestamp belonging to a date object.
This commit is contained in:
@@ -18,6 +18,8 @@ PHP NEWS
|
||||
timezone_identifiers_list() / DateTimezone::listIdentifiers().
|
||||
* date_timestamp_set() / DateTime::setTimestamp() to set a Unix timestamp
|
||||
without invoking the date parser. (Scott)
|
||||
* date_timestamp_get() / DateTime::getTimestamp() to retrieve the Unix
|
||||
timestamp belonging to a date object.
|
||||
|
||||
- Added ability to store associative infor with objects in SplObjectStorage.
|
||||
(Marcus)
|
||||
|
||||
@@ -182,6 +182,7 @@ const zend_function_entry date_functions[] = {
|
||||
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)
|
||||
@@ -215,6 +216,7 @@ const zend_function_entry date_funcs_date[] = {
|
||||
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}
|
||||
};
|
||||
|
||||
@@ -2267,6 +2269,32 @@ PHP_FUNCTION(date_timestamp_set)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ 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;
|
||||
|
||||
@@ -63,6 +63,7 @@ PHP_FUNCTION(date_time_set);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user