From 6f5b9894a2e3010511fbe4dceeb386236f99c964 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Tue, 29 Nov 2005 20:43:53 +0000 Subject: [PATCH] Added missing support for 'B' format identifier to date() function. --- NEWS | 1 + ext/date/php_date.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d4b03e831e1..b434a9a427f 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 200?, PHP 5.1.2 +- Added missing support for 'B' format identifier to date() function. (Ilia) - Improved SPL: (Marcus) . Added class SplFileInfo as root class for DirectoryIterator and SplFileObject diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 6eae37b0ab4..d4e7d29965a 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -494,7 +494,15 @@ static char *date_format(char *format, int format_len, timelib_time *t, int loca /* time */ case 'a': snprintf(buffer, 32, "%s", t->h >= 12 ? "pm" : "am"); break; case 'A': snprintf(buffer, 32, "%s", t->h >= 12 ? "PM" : "AM"); break; - case 'B': snprintf(buffer, 32, "[B unimplemented]"); break; + case 'B': { + int retval = (((((long)t->sse)-(((long)t->sse) - ((((long)t->sse) % 86400) + 3600))) * 10) / 864); + while (retval < 0) { + retval += 1000; + } + retval = retval % 1000; + snprintf(buffer, 32, "%03d", retval); break; + break; + } case 'g': snprintf(buffer, 32, "%d", (t->h % 12) ? (int) t->h % 12 : 12); break; case 'G': snprintf(buffer, 32, "%d", (int) t->h); break; case 'h': snprintf(buffer, 32, "%02d", (t->h % 12) ? (int) t->h % 12 : 12); break;