- Allow default timezone to be set with the .ini setting "date.timezone".

This commit is contained in:
Derick Rethans 2005-06-18 20:23:19 +00:00
parent 635ea0d5fd
commit 3e7446f0e7
5 changed files with 42 additions and 3 deletions

View File

@ -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

View File

@ -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 */
/*
*/

View File

@ -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 */

View 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

View 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