diff options
author | Stanislav Malyshev <stas@php.net> | 2012-12-04 21:02:55 -0800 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2012-12-04 21:02:55 -0800 |
commit | 1c8f106d9a65a29a29c68a9cde02c03e8dd6cac5 (patch) | |
tree | 08011460d507151055783ef7be7d6aafe0cacfb7 | |
parent | 86bf83dcf2dcb4a8b89519997765d2b0674247f9 (diff) | |
parent | fd650ec93e15bbbc05542e4acdde13d1fd9bcf73 (diff) | |
download | php-git-1c8f106d9a65a29a29c68a9cde02c03e8dd6cac5.tar.gz |
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
fix bug #63666 - Poor date() performance
-rw-r--r-- | ext/date/php_date.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 0abd693ca4..d5a952ed78 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -952,6 +952,7 @@ static char *date_format(char *format, int format_len, timelib_time *t, int loca timelib_time_offset *offset = NULL; timelib_sll isoweek, isoyear; int rfc_colon; + int weekYearSet = 0; if (!format_len) { return estrdup(""); @@ -978,7 +979,6 @@ static char *date_format(char *format, int format_len, timelib_time *t, int loca offset = timelib_get_time_zone_info(t->sse, t->tz_info); } } - timelib_isoweek_from_date(t->y, t->m, t->d, &isoweek, &isoyear); for (i = 0; i < format_len; i++) { rfc_colon = 0; @@ -994,8 +994,12 @@ static char *date_format(char *format, int format_len, timelib_time *t, int loca case 'z': length = slprintf(buffer, 32, "%d", (int) timelib_day_of_year(t->y, t->m, t->d)); break; /* week */ - case 'W': length = slprintf(buffer, 32, "%02d", (int) isoweek); break; /* iso weeknr */ - case 'o': length = slprintf(buffer, 32, "%d", (int) isoyear); break; /* iso year */ + case 'W': + if(!weekYearSet) { timelib_isoweek_from_date(t->y, t->m, t->d, &isoweek, &isoyear); weekYearSet = 1; } + length = slprintf(buffer, 32, "%02d", (int) isoweek); break; /* iso weeknr */ + case 'o': + if(!weekYearSet) { timelib_isoweek_from_date(t->y, t->m, t->d, &isoweek, &isoyear); weekYearSet = 1; } + length = slprintf(buffer, 32, "%d", (int) isoyear); break; /* iso year */ /* month */ case 'F': length = slprintf(buffer, 32, "%s", mon_full_names[t->m - 1]); break; |