Index: trunk/phase3/tests/phpunit/languages/LanguageTest.php |
— | — | @@ -192,4 +192,32 @@ |
193 | 193 | array( 'Be-x-old', 'With extension (two dashes)' ), |
194 | 194 | ); |
195 | 195 | } |
| 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 | + } |
196 | 224 | } |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -824,6 +824,7 @@ |
825 | 825 | * xij j (day number) in Iranian calendar |
826 | 826 | * xiF F (month name) in Iranian calendar |
827 | 827 | * xin n (month number) in Iranian calendar |
| 828 | + * xiy y (two digit year) in Iranian calendar |
828 | 829 | * xiY Y (full year) in Iranian calendar |
829 | 830 | * |
830 | 831 | * xjj j (day number) in Hebrew calendar |
— | — | @@ -1086,6 +1087,12 @@ |
1087 | 1088 | case 'y': |
1088 | 1089 | $num = substr( $ts, 2, 2 ); |
1089 | 1090 | break; |
| 1091 | + case 'xiy': |
| 1092 | + if ( !$iranian ) { |
| 1093 | + $iranian = self::tsToIranian( $ts ); |
| 1094 | + } |
| 1095 | + $num = substr( $iranian[0], -2 ); |
| 1096 | + break; |
1090 | 1097 | case 'a': |
1091 | 1098 | $s .= intval( substr( $ts, 8, 2 ) ) < 12 ? 'am' : 'pm'; |
1092 | 1099 | break; |