mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
- Allow default timezone to be set with the .ini setting "date.timezone".
This commit is contained in:
parent
635ea0d5fd
commit
3e7446f0e7
@ -1,5 +1,3 @@
|
||||
- Implement INI setting default timezone, for now the env var "TZ" can be
|
||||
used.
|
||||
- Port over my 200 test cases to .phpt format.
|
||||
- Write an error handler for unexpected characters while parsing dates.
|
||||
- Remove old parsedate.* code from ext/standard
|
||||
|
@ -33,8 +33,10 @@ function_entry date_functions[] = {
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(date)
|
||||
|
||||
PHP_INI_BEGIN()
|
||||
/* STD_PHP_INI_ENTRY("date.timezone", TIMEZONE_DB_LOCATION, PHP_INI_ALL, OnUpdateString, timezonedb_location, zend_date_globals, date_globals) */
|
||||
STD_PHP_INI_ENTRY("date.timezone", "GMT", PHP_INI_ALL, OnUpdateString, default_timezone, zend_date_globals, date_globals)
|
||||
PHP_INI_END()
|
||||
|
||||
|
||||
@ -51,10 +53,17 @@ zend_module_entry date_module_entry = {
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
|
||||
/* {{{ php_date_init_globals */
|
||||
static void php_date_init_globals(zend_date_globals *date_globals)
|
||||
{
|
||||
date_globals->default_timezone = NULL;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
PHP_MINIT_FUNCTION(date)
|
||||
{
|
||||
ZEND_INIT_MODULE_GLOBALS(date, php_date_init_globals, NULL);
|
||||
REGISTER_INI_ENTRIES();
|
||||
|
||||
return SUCCESS;
|
||||
@ -84,6 +93,9 @@ static char* guess_timezone(void)
|
||||
if (env) {
|
||||
return env;
|
||||
}
|
||||
if (DATEG(default_timezone)) {
|
||||
return DATEG(default_timezone);
|
||||
}
|
||||
/* Check config setting */
|
||||
/*
|
||||
*/
|
||||
|
@ -30,5 +30,14 @@ PHP_MINIT_FUNCTION(date);
|
||||
PHP_MSHUTDOWN_FUNCTION(date);
|
||||
PHP_MINFO_FUNCTION(date);
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(date)
|
||||
char *default_timezone;
|
||||
ZEND_END_MODULE_GLOBALS(date)
|
||||
|
||||
#ifdef ZTS
|
||||
#define DATEG(v) TSRMG(date_globals_id, zend_date_globals *, v)
|
||||
#else
|
||||
#define DATEG(v) (date_globals.v)
|
||||
#endif
|
||||
|
||||
#endif /* PHP_DATE_H */
|
||||
|
10
ext/date/tests/default-timezone-1.phpt
Normal file
10
ext/date/tests/default-timezone-1.phpt
Normal file
@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
date.timezone setting [1]
|
||||
--INI--
|
||||
date.timezone=GMT
|
||||
--FILE--
|
||||
<?php
|
||||
echo strtotime("2005-06-18 22:15:44");
|
||||
?>
|
||||
--EXPECT--
|
||||
1119132944
|
10
ext/date/tests/default-timezone-2.phpt
Normal file
10
ext/date/tests/default-timezone-2.phpt
Normal file
@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
date.timezone setting [2]
|
||||
--INI--
|
||||
date.timezone=Europe/Oslo
|
||||
--FILE--
|
||||
<?php
|
||||
echo strtotime("2005-06-18 22:15:44");
|
||||
?>
|
||||
--EXPECT--
|
||||
1119125744
|
Loading…
Reference in New Issue
Block a user