r45208 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45207‎ | r45208 | r45209 >
Date:22:51, 30 December 2008
Author:danny_b
Status:ok (Comments)
Tags:
Comment:
* handle the "o" format character for PHP 5.1.0+, older versions need emulation
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/Language.php
@@ -535,9 +535,10 @@
536536 * internationalisation, a reduced set of format characters, and a better
537537 * escaping format.
538538 *
539 - * Supported format characters are dDjlNwzWFmMntLYyaAgGhHiscrU. See the
540 - * PHP manual for definitions. There are a number of extensions, which
541 - * start with "x":
 539+ * Supported format characters are dDjlNwzWFmMntLoYyaAgGhHiscrU. See the
 540+ * PHP manual for definitions. "o" format character is supported since
 541+ * PHP 5.1.0, previous versions return literal o.
 542+ * There are a number of extensions, which start with "x":
542543 *
543544 * xn Do not translate digits of the next numeric format character
544545 * xN Toggle raw digit (xn) flag, stays set until explicitly unset
@@ -558,10 +559,10 @@
559560 * xjn n (month number) in Hebrew calendar
560561 * xjY Y (full year) in Hebrew calendar
561562 *
562 - * xmj j (day number) in Hijri calendar
563 - * xmF F (month name) in Hijri calendar
564 - * xmn n (month number) in Hijri calendar
565 - * xmY Y (full year) in Hijri calendar
 563+ * xmj j (day number) in Hijri calendar
 564+ * xmF F (month name) in Hijri calendar
 565+ * xmn n (month number) in Hijri calendar
 566+ * xmY Y (full year) in Hijri calendar
566567 *
567568 * xkY Y (full year) in Thai solar calendar. Months and days are
568569 * identical to the Gregorian calendar
@@ -582,6 +583,8 @@
583584 * @param $ts String: 14-character timestamp
584585 * YYYYMMDDHHMMSS
585586 * 01234567890123
 587+ * @todo emulation of "o" format character for PHP pre 5.1.0
 588+ * @todo handling of "o" format character for Iranian, Hebrew, Hijri & Thai?
586589 */
587590 function sprintfDate( $format, $ts ) {
588591 $s = '';
@@ -719,6 +722,16 @@
720723 if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
721724 $num = gmdate( 'L', $unix );
722725 break;
 726+ # 'o' is supported since PHP 5.1.0
 727+ # return literal if not supported
 728+ # TODO: emulation for pre 5.1.0 versions
 729+ case 'o':
 730+ if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 731+ if ( version_compare(PHP_VERSION, '5.1.0') === 1 )
 732+ $num = date( 'o', $unix );
 733+ else
 734+ $s .= 'o';
 735+ break;
723736 case 'Y':
724737 $num = substr( $ts, 0, 4 );
725738 break;

Follow-up revisions

RevisionCommit summaryAuthorDate
r107806(Half of bug 33454) The week based year number (format char 'o') was being ca...bawolff08:20, 2 January 2012

Comments

#Comment by Nikerabbit (talk | contribs)   10:18, 23 February 2009

Shouldn't the check be version_compare(PHP_VERSION, '5.1.0') >= 0

Status & tagging log