Nothing Special   »   [go: up one dir, main page]

r106143 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106142‎ | r106143 | r106144 >
Date:00:32, 14 December 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
* (bug 32461) Add two-digit short form year for Persian calendar ({{#time:xiy}})

Patch by Platonides https://bugzilla.wikimedia.org/attachment.cgi?id=9490&action=diff
Plus test case. Note the test case uses Latin-style digits because it's testing English; in fa you'd get the persian digits as in the examples on the bug.
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/languages/LanguageTest.php
@@ -192,4 +192,32 @@
193193 array( 'Be-x-old', 'With extension (two dashes)' ),
194194 );
195195 }
 196+
 197+ /**
 198+ * @dataProvider provideSprintfDateSamples
 199+ */
 200+ function testSprintfDate( $format, $ts, $expected, $msg ) {
 201+ $this->assertEquals(
 202+ $expected,
 203+ $this->lang->sprintfDate( $format, $ts ),
 204+ "sprintfDate('$format', '$ts'): $msg"
 205+ );
 206+ }
 207+
 208+ function provideSprintfDateSamples() {
 209+ return array(
 210+ array(
 211+ 'xiY',
 212+ '20111212000000',
 213+ '1390', // note because we're testing English locale we get Latin-standard digits
 214+ 'Iranian calendar full year'
 215+ ),
 216+ array(
 217+ 'xiy',
 218+ '20111212000000',
 219+ '90',
 220+ 'Iranian calendar short year'
 221+ ),
 222+ );
 223+ }
196224 }
Index: trunk/phase3/languages/Language.php
@@ -824,6 +824,7 @@
825825 * xij j (day number) in Iranian calendar
826826 * xiF F (month name) in Iranian calendar
827827 * xin n (month number) in Iranian calendar
 828+ * xiy y (two digit year) in Iranian calendar
828829 * xiY Y (full year) in Iranian calendar
829830 *
830831 * xjj j (day number) in Hebrew calendar
@@ -1086,6 +1087,12 @@
10871088 case 'y':
10881089 $num = substr( $ts, 2, 2 );
10891090 break;
 1091+ case 'xiy':
 1092+ if ( !$iranian ) {
 1093+ $iranian = self::tsToIranian( $ts );
 1094+ }
 1095+ $num = substr( $iranian[0], -2 );
 1096+ break;
10901097 case 'a':
10911098 $s .= intval( substr( $ts, 8, 2 ) ) < 12 ? 'am' : 'pm';
10921099 break;

Comments

#Comment by Nikerabbit (talk | contribs)   07:55, 14 December 2011

Some time to go until they have y2k problem.

#Comment by Brion VIBBER (talk | contribs)   19:16, 14 December 2011

Yeah but y1.4k is right around the corner!

Status & tagging log