cvs: php-src /ext/date php_date.c php_date.h /ext/date/tests bug26198.phpt bug28599.phpt bug29585.phpt bug29595.phpt bug33056.phpt bug33452.phpt
bug33536.phpt bug33562.phpt bug33563.phpt format-negative-timestamp.phpt timezone-configuration.phpt

From: Date: Mon, 04 Jul 2005 21:27:26 +0000
Subject: cvs: php-src /ext/date php_date.c php_date.h /ext/date/tests bug26198.phpt bug28599.phpt bug29585.phpt bug29595.phpt bug33056.phpt bug33452.phpt
bug33536.phpt bug33562.phpt bug33563.phpt format-negative-timestamp.phpt timezone-configuration.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-32684@lists.php.net to get a copy of this message
derick Mon Jul 4 17:27:26 2005 EDT Modified files: /php-src/ext/date php_date.c php_date.h /php-src/ext/date/tests bug26198.phpt bug28599.phpt bug29585.phpt bug29595.phpt bug33056.phpt bug33452.phpt bug33536.phpt bug33562.phpt bug33563.phpt format-negative-timestamp.phpt timezone-configuration.phpt Log: - Renamed date_timezone_set/get() to date_default_timezone_set/get(). - Added missing proto's and folding marks.

http://cvs.php.net/diff.php/php-src/ext/date/php_date.c?r1=1.33&r2=1.34&ty=u Index: php-src/ext/date/php_date.c diff -u php-src/ext/date/php_date.c:1.33 php-src/ext/date/php_date.c:1.34 --- php-src/ext/date/php_date.c:1.33 Mon Jul 4 14:13:15 2005 +++ php-src/ext/date/php_date.c Mon Jul 4 17:27:25 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_date.c,v 1.33 2005/07/04 18:13:15 iliaa Exp $ */ +/* $Id: php_date.c,v 1.34 2005/07/04 21:27:25 derick Exp $ */ #include "php.h" #include "php_streams.h" @@ -28,6 +28,7 @@ #include "lib/timelib.h" #include <time.h> +/* {{{ Function table */ function_entry date_functions[] = { PHP_FE(strtotime, NULL) PHP_FE(date, NULL) @@ -45,18 +46,21 @@ PHP_FE(localtime, NULL) PHP_FE(getdate, NULL) - PHP_FE(date_timezone_set, NULL) - PHP_FE(date_timezone_get, NULL) + PHP_FE(date_default_timezone_set, NULL) + PHP_FE(date_default_timezone_get, NULL) {NULL, NULL, NULL} }; +/* }}} */ ZEND_DECLARE_MODULE_GLOBALS(date) +/* {{{ INI Settings */ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("date.timezone", "", PHP_INI_ALL, OnUpdateString, default_timezone, zend_date_globals, date_globals) PHP_INI_END() +/* }}} */ - +/* {{{ Module struct */ zend_module_entry date_module_entry = { STANDARD_MODULE_HEADER, "date", /* extension name */ @@ -69,6 +73,8 @@ PHP_VERSION, /* extension version */ STANDARD_MODULE_PROPERTIES }; +/* }}} */ + /* {{{ php_date_init_globals */ static void php_date_init_globals(zend_date_globals *date_globals) @@ -78,6 +84,7 @@ } /* }}} */ +/* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(date) { if (DATEG(timezone)) { @@ -87,7 +94,9 @@ return SUCCESS; } +/* }}} */ +/* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(date) { if (DATEG(timezone)) { @@ -97,7 +106,9 @@ return SUCCESS; } +/* }}} */ +/* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(date) { ZEND_INIT_MODULE_GLOBALS(date, php_date_init_globals, NULL); @@ -105,25 +116,28 @@ return SUCCESS; } +/* }}} */ - +/* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(date) { UNREGISTER_INI_ENTRIES(); return SUCCESS; } +/* }}} */ - +/* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(date) { php_info_print_table_start(); php_info_print_table_row(2, "date/time support", "enabled"); php_info_print_table_end(); } +/* }}} */ -/* =[ Helper functions ] ================================================== */ +/* {{{ Helper functions */ static char* guess_timezone(TSRMLS_D) { char *env; @@ -180,8 +194,10 @@ } return tzi; } +/* }}} */ + -/* =[ date() and gmdate() ]================================================ */ +/* {{{ date() and gmdate() data */ #include "ext/standard/php_smart_str.h" static char *mon_full_names[] = { @@ -215,7 +231,9 @@ } return "th"; } +/* }}} */ +/* {{{ php_format_date - (gm)date helper */ static char *php_format_date(char *format, int format_len, timelib_time *t, int localtime) { smart_str string = {0}; @@ -345,18 +363,26 @@ RETVAL_STRING(string, 0); timelib_time_dtor(t); } +/* }}} */ +/* {{{ proto string date(string format [, long timestamp]) + Format a local date/time */ PHP_FUNCTION(date) { php_date(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); } +/* }}} */ +/* {{{ proto string gmdate(string format [, long timestamp]) + Format a GMT date/time */ PHP_FUNCTION(gmdate) { php_date(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); } +/* }}} */ -/* Backwards compability function */ + +/* {{{ php_parse_date: Backwards compability function */ signed long php_parse_date(char *string, signed long *now) { timelib_time *parsed_time; @@ -372,6 +398,7 @@ } return retval; } +/* }}} */ /* {{{ proto int strtotime(string time, int now) @@ -432,6 +459,8 @@ } /* }}} */ + +/* {{{ php_mktime - (gm)mktime helper */ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt) { long hou, min, sec, mon, day, yea, dst = -1; @@ -515,6 +544,7 @@ RETURN_LONG(ts); } } +/* }}} */ /* {{{ proto int mktime(int hour, int min, int sec, int mon, int day, int year) Get UNIX timestamp for a date */ @@ -532,6 +562,7 @@ } /* }}} */ + /* {{{ proto bool checkdate(int month, int day, int year) Returns true(1) if it is a valid date in gregorian calendar */ PHP_FUNCTION(checkdate) @@ -550,8 +581,7 @@ /* }}} */ #ifdef HAVE_STRFTIME -/* {{{ php_strftime - */ +/* {{{ php_strftime - (gm)strftime helper */ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt) { char *format, *buf; @@ -637,7 +667,7 @@ Format a local time/date according to locale settings */ PHP_FUNCTION(strftime) { - _php_strftime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); + php_strftime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); } /* }}} */ @@ -645,7 +675,7 @@ Format a GMT/UCT time/date according to locale settings */ PHP_FUNCTION(gmstrftime) { - _php_strftime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); + php_strftime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); } /* }}} */ #endif @@ -737,7 +767,10 @@ } /* }}} */ -PHP_FUNCTION(date_timezone_set) + +/* {{{ proto void date_default_timezone_set(string timezone_identifier) + Sets the default timezone used by all date/time functions in a script */ +PHP_FUNCTION(date_default_timezone_set) { char *zone; int zone_len; @@ -752,11 +785,15 @@ DATEG(timezone) = estrndup(zone, zone_len); RETURN_TRUE; } +/* }}} */ -PHP_FUNCTION(date_timezone_get) +/* {{{ proto void date_default_timezone_get(string timezone_identifier) + Gets the default timezone used by all date/time functions in a script */ +PHP_FUNCTION(date_default_timezone_get) { RETURN_STRING(DATEG(timezone), 0); } +/* }}} */ /* * Local variables: http://cvs.php.net/diff.php/php-src/ext/date/php_date.h?r1=1.12&r2=1.13&ty=u Index: php-src/ext/date/php_date.h diff -u php-src/ext/date/php_date.h:1.12 php-src/ext/date/php_date.h:1.13 --- php-src/ext/date/php_date.h:1.12 Mon Jul 4 09:21:36 2005 +++ php-src/ext/date/php_date.h Mon Jul 4 17:27:25 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_date.h,v 1.12 2005/07/04 13:21:36 derick Exp $ */ +/* $Id: php_date.h,v 1.13 2005/07/04 21:27:25 derick Exp $ */ #ifndef PHP_DATE_H #define PHP_DATE_H @@ -42,8 +42,8 @@ PHP_FUNCTION(localtime); PHP_FUNCTION(getdate); -PHP_FUNCTION(date_timezone_set); -PHP_FUNCTION(date_timezone_get); +PHP_FUNCTION(date_default_timezone_set); +PHP_FUNCTION(date_default_timezone_get); PHP_RINIT_FUNCTION(date); PHP_RSHUTDOWN_FUNCTION(date); http://cvs.php.net/diff.php/php-src/ext/date/tests/bug26198.phpt?r1=1.4&r2=1.5&ty=u Index: php-src/ext/date/tests/bug26198.phpt diff -u php-src/ext/date/tests/bug26198.phpt:1.4 php-src/ext/date/tests/bug26198.phpt:1.5 --- php-src/ext/date/tests/bug26198.phpt:1.4 Sun Jul 3 11:01:29 2005 +++ php-src/ext/date/tests/bug26198.phpt Mon Jul 4 17:27:26 2005 @@ -2,7 +2,7 @@ Bug #26198 (strtotime handling of "M Y" and "Y M" format) --FILE-- <?php - date_timezone_set("GMT"); + date_default_timezone_set("GMT"); echo gmdate("F Y (Y-m-d H:i:s T)\n", strtotime("Oct 2001")); echo gmdate("M Y (Y-m-d H:i:s T)\n", strtotime("2001 Oct")); ?> http://cvs.php.net/diff.php/php-src/ext/date/tests/bug28599.phpt?r1=1.2&r2=1.3&ty=u Index: php-src/ext/date/tests/bug28599.phpt diff -u php-src/ext/date/tests/bug28599.phpt:1.2 php-src/ext/date/tests/bug28599.phpt:1.3 --- php-src/ext/date/tests/bug28599.phpt:1.2 Sun Jul 3 11:01:29 2005 +++ php-src/ext/date/tests/bug28599.phpt Mon Jul 4 17:27:26 2005 @@ -2,7 +2,7 @@ Bug #28599 (strtotime fails with zero base time) --FILE-- <?php -date_timezone_set("Europe/Amsterdam"); +date_default_timezone_set("Europe/Amsterdam"); print gmdate("d-m-Y H:i:s", strtotime("+30 minutes", 1100535573)); ?> --EXPECT-- http://cvs.php.net/diff.php/php-src/ext/date/tests/bug29585.phpt?r1=1.3&r2=1.4&ty=u Index: php-src/ext/date/tests/bug29585.phpt diff -u php-src/ext/date/tests/bug29585.phpt:1.3 php-src/ext/date/tests/bug29585.phpt:1.4 --- php-src/ext/date/tests/bug29585.phpt:1.3 Sun Jul 3 11:01:29 2005 +++ php-src/ext/date/tests/bug29585.phpt Mon Jul 4 17:27:26 2005 @@ -2,7 +2,7 @@ Bug #29585 (Support week numbers in strtotime()) --FILE-- <?php -date_timezone_set("GMT"); +date_default_timezone_set("GMT"); echo gmdate("Y-m-d H:i:s", strtotime("2004W30")); ?> --EXPECT-- http://cvs.php.net/diff.php/php-src/ext/date/tests/bug29595.phpt?r1=1.2&r2=1.3&ty=u Index: php-src/ext/date/tests/bug29595.phpt diff -u php-src/ext/date/tests/bug29595.phpt:1.2 php-src/ext/date/tests/bug29595.phpt:1.3 --- php-src/ext/date/tests/bug29595.phpt:1.2 Sun Jul 3 11:01:29 2005 +++ php-src/ext/date/tests/bug29595.phpt Mon Jul 4 17:27:26 2005 @@ -2,7 +2,7 @@ Bug #29595 (Roman number format for months) --FILE-- <?php -date_timezone_set("GMT"); +date_default_timezone_set("GMT"); $from_postgres = '2004-08-09 14:48:27.304809+10'; echo strtotime($from_postgres); http://cvs.php.net/diff.php/php-src/ext/date/tests/bug33056.phpt?r1=1.2&r2=1.3&ty=u Index: php-src/ext/date/tests/bug33056.phpt diff -u php-src/ext/date/tests/bug33056.phpt:1.2 php-src/ext/date/tests/bug33056.phpt:1.3 --- php-src/ext/date/tests/bug33056.phpt:1.2 Sun Jul 3 11:01:29 2005 +++ php-src/ext/date/tests/bug33056.phpt Mon Jul 4 17:27:26 2005 @@ -2,7 +2,7 @@ Bug #33056 (strtotime() does not parse 20050518t090000Z) --FILE-- <?php -date_timezone_set("GMT"); +date_default_timezone_set("GMT"); echo strtotime('20050518t090000Z')."\n"; echo strtotime('20050518t091234Z')."\n"; echo strtotime('20050518t191234Z')."\n"; http://cvs.php.net/diff.php/php-src/ext/date/tests/bug33452.phpt?r1=1.2&r2=1.3&ty=u Index: php-src/ext/date/tests/bug33452.phpt diff -u php-src/ext/date/tests/bug33452.phpt:1.2 php-src/ext/date/tests/bug33452.phpt:1.3 --- php-src/ext/date/tests/bug33452.phpt:1.2 Sun Jul 3 11:01:29 2005 +++ php-src/ext/date/tests/bug33452.phpt Mon Jul 4 17:27:26 2005 @@ -2,7 +2,7 @@ Bug #33452 (Support for year accompanying ISO week nr) --FILE-- <?php -date_timezone_set("GMT"); +date_default_timezone_set("GMT"); echo date('Y-W', strtotime('2005-1-1')), "\n"; echo date('o-W', strtotime('2005-1-1')), "\n"; ?> http://cvs.php.net/diff.php/php-src/ext/date/tests/bug33536.phpt?r1=1.1&r2=1.2&ty=u Index: php-src/ext/date/tests/bug33536.phpt diff -u php-src/ext/date/tests/bug33536.phpt:1.1 php-src/ext/date/tests/bug33536.phpt:1.2 --- php-src/ext/date/tests/bug33536.phpt:1.1 Sun Jul 3 17:38:54 2005 +++ php-src/ext/date/tests/bug33536.phpt Mon Jul 4 17:27:26 2005 @@ -2,7 +2,7 @@ Bug #33456 (strtotime defaults to now even on non time string) --FILE-- <?php -date_timezone_set("GMT"); +date_default_timezone_set("GMT"); var_dump(strtotime("monkey")); print date("Y-m-d", strtotime("monkey")) ."\n"; print date("Y-m-d", false) ."\n"; http://cvs.php.net/diff.php/php-src/ext/date/tests/bug33562.phpt?r1=1.1&r2=1.2&ty=u Index: php-src/ext/date/tests/bug33562.phpt diff -u php-src/ext/date/tests/bug33562.phpt:1.1 php-src/ext/date/tests/bug33562.phpt:1.2 --- php-src/ext/date/tests/bug33562.phpt:1.1 Mon Jul 4 03:48:19 2005 +++ php-src/ext/date/tests/bug33562.phpt Mon Jul 4 17:27:26 2005 @@ -2,7 +2,7 @@ Bug #33562 (date("") crashes) --FILE-- <?php -date_timezone_set("GMT"); +date_default_timezone_set("GMT"); echo "[", date(""), "]\n"; echo "done"; ?> http://cvs.php.net/diff.php/php-src/ext/date/tests/bug33563.phpt?r1=1.1&r2=1.2&ty=u Index: php-src/ext/date/tests/bug33563.phpt diff -u php-src/ext/date/tests/bug33563.phpt:1.1 php-src/ext/date/tests/bug33563.phpt:1.2 --- php-src/ext/date/tests/bug33563.phpt:1.1 Mon Jul 4 08:41:20 2005 +++ php-src/ext/date/tests/bug33563.phpt Mon Jul 4 17:27:26 2005 @@ -2,7 +2,7 @@ Bug #33563 (strtotime('+1 month',$abc) cant get right time) --FILE-- <?php -date_timezone_set("GMT"); +date_default_timezone_set("GMT"); $strCurrDate = date('Y-m-d H:i:s',strtotime('2005-06-30 21:04:23')); $strMonAfter = date('Y-m-d H:i:s',strtotime('+1 month',strtotime($strCurrDate))); http://cvs.php.net/diff.php/php-src/ext/date/tests/format-negative-timestamp.phpt?r1=1.2&r2=1.3&ty=u Index: php-src/ext/date/tests/format-negative-timestamp.phpt diff -u php-src/ext/date/tests/format-negative-timestamp.phpt:1.2 php-src/ext/date/tests/format-negative-timestamp.phpt:1.3 --- php-src/ext/date/tests/format-negative-timestamp.phpt:1.2 Sun Jul 3 11:01:29 2005 +++ php-src/ext/date/tests/format-negative-timestamp.phpt Mon Jul 4 17:27:26 2005 @@ -2,7 +2,7 @@ strtotime() - Format: @timestamps --FILE-- <?php -date_timezone_set("GMT"); +date_default_timezone_set("GMT"); $i = 5; $max = getrandmax(); http://cvs.php.net/diff.php/php-src/ext/date/tests/timezone-configuration.phpt?r1=1.1&r2=1.2&ty=u Index: php-src/ext/date/tests/timezone-configuration.phpt diff -u php-src/ext/date/tests/timezone-configuration.phpt:1.1 php-src/ext/date/tests/timezone-configuration.phpt:1.2 --- php-src/ext/date/tests/timezone-configuration.phpt:1.1 Sat Jul 2 17:19:25 2005 +++ php-src/ext/date/tests/timezone-configuration.phpt Mon Jul 4 17:27:26 2005 @@ -10,7 +10,7 @@ putenv('TZ=Europe/London'); echo strtotime("2005-06-18 22:15:44"), "\n"; - date_timezone_set('Europe/Oslo'); + date_default_timezone_set('Europe/Oslo'); echo strtotime("2005-06-18 22:15:44"), "\n"; ?> --EXPECT--
« previous php.cvs (#32684) next »