From 39379b8f58eeab32fa5d190bffcd36b73c97e0a7 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Fri, 8 Jul 2005 12:26:30 +0000 Subject: [PATCH] rename php_format_date() to date_format() add wrapper for date_format() to use it in other extensions --- ext/date/php_date.c | 24 ++++++++++++++++++------ ext/date/php_date.h | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index b4652386b7..19d36e48e4 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -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_PARAMETERS, int localtime) 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,13 +368,15 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime) 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; } /* }}} */ diff --git a/ext/date/php_date.h b/ext/date/php_date.h index 894477eda9..792edae371 100644 --- a/ext/date/php_date.h +++ b/ext/date/php_date.h @@ -69,5 +69,6 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt); #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 */ -- 2.40.0