Index: trunk/phase3/languages/messages/MessagesZh_tw.php |
— | — | @@ -38,6 +38,29 @@ |
39 | 39 | NS_CATEGORY_TALK => '分類討論' |
40 | 40 | ); |
41 | 41 | |
| 42 | +$datePreferences = array( |
| 43 | + 'default', |
| 44 | + 'minguo', |
| 45 | + 'CNS 7648', |
| 46 | + 'ISO 8601', |
| 47 | +); |
| 48 | + |
| 49 | +$defaultDateFormat = 'zh'; |
| 50 | + |
| 51 | +$dateFormats = array( |
| 52 | + 'zh time' => 'H:i', |
| 53 | + 'zh date' => 'Y年n月j日 (l)', |
| 54 | + 'zh both' => 'Y年n月j日 (D) H:i', |
| 55 | + |
| 56 | + 'minguo time' => 'H:i', |
| 57 | + 'minguo date' => 'xoY年n月j日 (l)', |
| 58 | + 'minguo both' => 'xoY年n月j日 (D) H:i', |
| 59 | + |
| 60 | + 'CNS 7648 time' => 'H:i', |
| 61 | + 'CNS 7648 date' => 'R.O.C. xoY-m-d (l)', |
| 62 | + 'CNS 7648 both' => 'R.O.C. xoY-m-d (D) H:i', |
| 63 | +); |
| 64 | + |
42 | 65 | $messages = array( |
43 | 66 | # User preference toggles |
44 | 67 | 'tog-underline' => '鏈結標注底線', |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -567,6 +567,8 @@ |
568 | 568 | * |
569 | 569 | * xkY Y (full year) in Thai solar calendar. Months and days are |
570 | 570 | * identical to the Gregorian calendar |
| 571 | + * xoY Y (full year) in Minguo calendar. Months and days are |
| 572 | + * identical to the Gregorian calendar |
571 | 573 | * |
572 | 574 | * Characters enclosed in double quotes will be considered literal (with |
573 | 575 | * the quotes themselves removed). Unmatched quotes will be considered |
— | — | @@ -598,6 +600,7 @@ |
599 | 601 | $hebrew = false; |
600 | 602 | $hijri = false; |
601 | 603 | $thai = false; |
| 604 | + $minguo = false; |
602 | 605 | for ( $p = 0; $p < strlen( $format ); $p++ ) { |
603 | 606 | $num = false; |
604 | 607 | $code = $format[$p]; |
— | — | @@ -605,7 +608,7 @@ |
606 | 609 | $code .= $format[++$p]; |
607 | 610 | } |
608 | 611 | |
609 | | - if ( ( $code === 'xi' || $code == 'xj' || $code == 'xk' || $code == 'xm' ) && $p < strlen( $format ) - 1 ) { |
| 612 | + if ( ( $code === 'xi' || $code == 'xj' || $code == 'xk' || $code == 'xm' || $code == 'xo' ) && $p < strlen( $format ) - 1 ) { |
610 | 613 | $code .= $format[++$p]; |
611 | 614 | } |
612 | 615 | |
— | — | @@ -752,6 +755,10 @@ |
753 | 756 | if ( !$thai ) $thai = self::tsToThai( $ts ); |
754 | 757 | $num = $thai[0]; |
755 | 758 | break; |
| 759 | + case 'xoY': |
| 760 | + if ( !$minguo ) $minguo = self::tsToMinguo( $ts ); |
| 761 | + $num = $minguo[0]; |
| 762 | + break; |
756 | 763 | case 'y': |
757 | 764 | $num = substr( $ts, 2, 2 ); |
758 | 765 | break; |
— | — | @@ -1132,7 +1139,26 @@ |
1133 | 1140 | return array( $gy_thai, $gm, $gd ); |
1134 | 1141 | } |
1135 | 1142 | |
| 1143 | + /** |
| 1144 | + * Algorithm to convert Gregorian dates to Minguo dates. |
| 1145 | + * |
| 1146 | + * Link: http://en.wikipedia.org/wiki/Minguo_calendar |
| 1147 | + * |
| 1148 | + * @param $ts String: 14-character timestamp |
| 1149 | + * @return array converted year, month, day |
| 1150 | + */ |
| 1151 | + private static function tsToMinguo( $ts ) { |
| 1152 | + $gy = substr( $ts, 0, 4 ); |
| 1153 | + $gm = substr( $ts, 4, 2 ); |
| 1154 | + $gd = substr( $ts, 6, 2 ); |
1136 | 1155 | |
| 1156 | + # Deduct 1911 years from the Gregorian calendar |
| 1157 | + # Months and days are identical |
| 1158 | + $gy_minguo = $gy - 1911; |
| 1159 | + |
| 1160 | + return array( $gy_minguo, $gm, $gd ); |
| 1161 | + } |
| 1162 | + |
1137 | 1163 | /** |
1138 | 1164 | * Roman number formatting up to 3000 |
1139 | 1165 | */ |