Index: ext/date/php_date.c =================================================================== RCS file: /repository/php-src/ext/date/php_date.c,v retrieving revision 1.36 diff -u -p -d -r1.36 php_date.c --- ext/date/php_date.c 8 Jul 2005 10:23:33 -0000 1.36 +++ ext/date/php_date.c 8 Jul 2005 11:52:48 -0000 @@ -233,8 +233,8 @@ static char *english_suffix(int number) } /* }}} */ -/* {{{ php_format_date - (gm)date helper */ -static char *php_format_date(char *format, int format_len, timelib_time *t, int localtime) +/* {{{ date_format - (gm)date helper */ +static char *date_format(char *format, int format_len, timelib_time *t, int localtime) { smart_str string = {0}; int i; @@ -341,14 +341,24 @@ static void php_date(INTERNAL_FUNCTION_P char *format; int format_len; long ts = time(NULL); - timelib_time *t; char *string; - timelib_tzinfo *tzi; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &format, &format_len, &ts) == FAILURE) { RETURN_FALSE; } + string = php_format_date(format, format_len, ts, localtime); + + RETVAL_STRING(string, 0); +} +/* }}} */ + +PHPAPI char *php_format_date(char *format, int format_len, long ts, int localtime) /* {{{ */ +{ + timelib_time *t; + timelib_tzinfo *tzi; + char *string; + t = timelib_time_ctor(); if (localtime) { @@ -358,15 +368,16 @@ static void php_date(INTERNAL_FUNCTION_P tzi = NULL; timelib_unixtime2gmt(t, ts); } - string = php_format_date(format, format_len, t, localtime); + + string = date_format(format, format_len, t, localtime); - RETVAL_STRING(string, 0); if (localtime) { timelib_tzinfo_dtor(tzi); } + timelib_time_dtor(t); -} -/* }}} */ + return string; +} /* }}} */ /* {{{ proto string date(string format [, long timestamp]) Format a local date/time */ Index: ext/date/php_date.h =================================================================== RCS file: /repository/php-src/ext/date/php_date.h,v retrieving revision 1.13 diff -u -p -d -r1.13 php_date.h --- ext/date/php_date.h 4 Jul 2005 21:27:25 -0000 1.13 +++ ext/date/php_date.h 8 Jul 2005 11:52:48 -0000 @@ -69,5 +69,6 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION #define _php_strftime php_strftime PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm); #endif +PHPAPI char *php_format_date(char *format, int format_len, long ts, int localtime); #endif /* PHP_DATE_H */