From 4b6c551919ab0d48fedd20bbc01af05bd2a520a8 Mon Sep 17 00:00:00 2001 From: Danny B Date: Tue, 30 Dec 2008 22:51:05 +0000 Subject: [PATCH] * handle the "o" format character for PHP 5.1.0+, older versions need emulation --- languages/Language.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/languages/Language.php b/languages/Language.php index b7c9efc19b..6502aa0d4f 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -535,9 +535,10 @@ class Language { * internationalisation, a reduced set of format characters, and a better * escaping format. * - * Supported format characters are dDjlNwzWFmMntLYyaAgGhHiscrU. See the - * PHP manual for definitions. There are a number of extensions, which - * start with "x": + * Supported format characters are dDjlNwzWFmMntLoYyaAgGhHiscrU. See the + * PHP manual for definitions. "o" format character is supported since + * PHP 5.1.0, previous versions return literal o. + * There are a number of extensions, which start with "x": * * xn Do not translate digits of the next numeric format character * xN Toggle raw digit (xn) flag, stays set until explicitly unset @@ -558,10 +559,10 @@ class Language { * xjn n (month number) in Hebrew calendar * xjY Y (full year) in Hebrew calendar * - * xmj j (day number) in Hijri calendar - * xmF F (month name) in Hijri calendar - * xmn n (month number) in Hijri calendar - * xmY Y (full year) in Hijri calendar + * xmj j (day number) in Hijri calendar + * xmF F (month name) in Hijri calendar + * xmn n (month number) in Hijri calendar + * xmY Y (full year) in Hijri calendar * * xkY Y (full year) in Thai solar calendar. Months and days are * identical to the Gregorian calendar @@ -582,6 +583,8 @@ class Language { * @param $ts String: 14-character timestamp * YYYYMMDDHHMMSS * 01234567890123 + * @todo emulation of "o" format character for PHP pre 5.1.0 + * @todo handling of "o" format character for Iranian, Hebrew, Hijri & Thai? */ function sprintfDate( $format, $ts ) { $s = ''; @@ -719,6 +722,16 @@ class Language { if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts ); $num = gmdate( 'L', $unix ); break; + # 'o' is supported since PHP 5.1.0 + # return literal if not supported + # TODO: emulation for pre 5.1.0 versions + case 'o': + if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts ); + if ( version_compare(PHP_VERSION, '5.1.0') === 1 ) + $num = date( 'o', $unix ); + else + $s .= 'o'; + break; case 'Y': $num = substr( $ts, 0, 4 ); break; -- 2.20.1