diff options
author | Derick Rethans <derick@php.net> | 2005-07-03 19:14:55 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2005-07-03 19:14:55 +0000 |
commit | 0ef991e5ae409ecddedc6cfbb8231236ef84b936 (patch) | |
tree | fcbc18aa1afea8ab62816b308ffd8e6b1efb3afd /ext/standard | |
parent | dda7692c87fed5131658772cc2c2ad6802d905cc (diff) | |
download | php-git-0ef991e5ae409ecddedc6cfbb8231236ef84b936.tar.gz |
- Fixed bug #33532 (Different output for strftime() and date()).
- Re-implemented checkdate(), strftime() and gmstrftime() with the new timelib
code.
Diffstat (limited to 'ext/standard')
-rw-r--r-- | ext/standard/basic_functions.c | 5 | ||||
-rw-r--r-- | ext/standard/datetime.c | 99 | ||||
-rw-r--r-- | ext/standard/datetime.h | 7 |
3 files changed, 0 insertions, 111 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index e86b726295..6203334a3a 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -172,15 +172,10 @@ function_entry basic_functions[] = { #if HAVE_STRPTIME PHP_FE(strptime, NULL) #endif -#if HAVE_STRFTIME - PHP_FE(strftime, NULL) - PHP_FE(gmstrftime, NULL) -#endif PHP_FE(idate, NULL) PHP_FE(getdate, NULL) PHP_FE(localtime, NULL) - PHP_FE(checkdate, NULL) PHP_FE(flush, NULL) PHP_FE(wordwrap, NULL) diff --git a/ext/standard/datetime.c b/ext/standard/datetime.c index 5e1933f5e9..8a2ceecf17 100644 --- a/ext/standard/datetime.c +++ b/ext/standard/datetime.c @@ -353,105 +353,6 @@ PHPAPI char *php_std_date(time_t t TSRMLS_DC) } /* }}} */ -/* {{{ proto bool checkdate(int month, int day, int year) - Returns true(1) if it is a valid date in gregorian calendar */ -PHP_FUNCTION(checkdate) -{ - long m, d, y; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &m, &d, &y) == FAILURE) { - RETURN_FALSE; - } - - if (y < 1 || y > 32767 || m < 1 || m > 12 || d < 1 || d > phpday_tab[isleap(y)][m - 1]) { - RETURN_FALSE; - } - RETURN_TRUE; /* True : This month, day, year arguments are valid */ -} -/* }}} */ - -#if HAVE_STRFTIME -/* {{{ _php_strftime - */ -PHPAPI void _php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm) -{ - pval **format_arg, **timestamp_arg; - char *format, *buf; - time_t timestamp; - struct tm *ta, tmbuf; - int max_reallocs = 5; - size_t buf_len=64, real_len; - - switch (ZEND_NUM_ARGS()) { - case 1: - if (zend_get_parameters_ex(1, &format_arg)==FAILURE) { - RETURN_FALSE; - } - time(×tamp); - break; - case 2: - if (zend_get_parameters_ex(2, &format_arg, ×tamp_arg)==FAILURE) { - RETURN_FALSE; - } - convert_to_long_ex(timestamp_arg); - timestamp = Z_LVAL_PP(timestamp_arg); - break; - default: - WRONG_PARAM_COUNT; - break; - } - - convert_to_string_ex(format_arg); - if (Z_STRLEN_PP(format_arg)==0) { - RETURN_FALSE; - } -#ifdef PHP_WIN32 - if (timestamp < 0) { - RETURN_FALSE; - } -#endif - format = Z_STRVAL_PP(format_arg); - if (gm) { - ta = php_gmtime_r(×tamp, &tmbuf); - } else { - ta = php_localtime_r(×tamp, &tmbuf); - } - - buf = (char *) emalloc(buf_len); - while ((real_len=strftime(buf, buf_len, format, ta))==buf_len || real_len==0) { - buf_len *= 2; - buf = (char *) erealloc(buf, buf_len); - if (!--max_reallocs) { - break; - } - } - - if (real_len && real_len != buf_len) { - buf = (char *) erealloc(buf, real_len + 1); - RETURN_STRINGL(buf, real_len, 0); - } - efree(buf); - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto string strftime(string format [, int timestamp]) - Format a local time/date according to locale settings */ -PHP_FUNCTION(strftime) -{ - _php_strftime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); -} -/* }}} */ - -/* {{{ proto string gmstrftime(string format [, int timestamp]) - Format a GMT/UCT time/date according to locale settings */ -PHP_FUNCTION(gmstrftime) -{ - _php_strftime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); -} -/* }}} */ - -#endif #if HAVE_STRPTIME /* {{{ proto string strptime(string timestamp, string format) diff --git a/ext/standard/datetime.h b/ext/standard/datetime.h index 4c1e39fb50..f7c57815ca 100644 --- a/ext/standard/datetime.h +++ b/ext/standard/datetime.h @@ -30,15 +30,8 @@ PHP_FUNCTION(checkdate); #if HAVE_STRPTIME PHP_FUNCTION(strptime); #endif -#if HAVE_STRFTIME -PHP_FUNCTION(strftime); -PHP_FUNCTION(gmstrftime); -#endif PHPAPI int php_idate(char format, int timestamp, int gm); PHPAPI char *php_std_date(time_t t TSRMLS_DC); -#if HAVE_STRFTIME -PHPAPI void _php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm); -#endif #endif /* DATETIME_H */ |