Index: trunk/phase3/languages/messages/MessagesKo.php |
— | — | @@ -247,11 +247,20 @@ |
248 | 248 | 'inherit' => true, |
249 | 249 | ); |
250 | 250 | |
| 251 | +$datePreferences = array( |
| 252 | + 'default', |
| 253 | + 'juche', |
| 254 | + 'ISO 8601', |
| 255 | +); |
251 | 256 | $defaultDateFormat = 'ko'; |
252 | 257 | $dateFormats = array( |
253 | | - 'ko time' => 'H:i', |
254 | | - 'ko date' => 'Y년 M월 j일 (D)', |
255 | | - 'ko both' => 'Y년 M월 j일 (D) H:i', |
| 258 | + 'ko time' => 'H:i', |
| 259 | + 'ko date' => 'Y년 M월 j일 (D)', |
| 260 | + 'ko both' => 'Y년 M월 j일 (D) H:i', |
| 261 | + |
| 262 | + 'juche time' => 'H:i', |
| 263 | + 'juche date' => 'xoY년 M월 j일 (D)', |
| 264 | + 'juche both' => 'xoY년 M월 j일 (D) H:i', |
256 | 265 | ); |
257 | 266 | |
258 | 267 | $messages = array( |
Index: trunk/phase3/languages/messages/MessagesZh_tw.php |
— | — | @@ -48,13 +48,13 @@ |
49 | 49 | $defaultDateFormat = 'zh'; |
50 | 50 | |
51 | 51 | $dateFormats = array( |
52 | | - 'zh time' => 'H:i', |
53 | | - 'zh date' => 'Y年n月j日 (l)', |
54 | | - 'zh both' => 'Y年n月j日 (D) H:i', |
| 52 | + 'zh time' => 'H:i', |
| 53 | + 'zh date' => 'Y年n月j日 (l)', |
| 54 | + 'zh both' => 'Y年n月j日 (D) H:i', |
55 | 55 | |
56 | | - 'minguo time' => 'H:i', |
57 | | - 'minguo date' => 'xoY年n月j日 (l)', |
58 | | - 'minguo both' => 'xoY年n月j日 (D) H:i', |
| 56 | + 'minguo time' => 'H:i', |
| 57 | + 'minguo date' => 'xoY年n月j日 (l)', |
| 58 | + 'minguo both' => 'xoY年n月j日 (D) H:i', |
59 | 59 | |
60 | 60 | 'CNS 7648 time' => 'H:i', |
61 | 61 | 'CNS 7648 date' => 'R.O.C. xoY-m-d (l)', |
Index: trunk/phase3/languages/messages/MessagesJa.php |
— | — | @@ -32,15 +32,20 @@ |
33 | 33 | |
34 | 34 | $datePreferences = array( |
35 | 35 | 'default', |
| 36 | + 'nengo', |
36 | 37 | 'ISO 8601', |
37 | 38 | ); |
38 | 39 | |
39 | 40 | $defaultDateFormat = 'ja'; |
40 | 41 | |
41 | 42 | $dateFormats = array( |
42 | | - 'ja time' => 'H:i', |
43 | | - 'ja date' => 'Y年n月j日 (D)', |
44 | | - 'ja both' => 'Y年n月j日 (D) H:i', |
| 43 | + 'ja time' => 'H:i', |
| 44 | + 'ja date' => 'Y年n月j日 (D)', |
| 45 | + 'ja both' => 'Y年n月j日 (D) H:i', |
| 46 | + |
| 47 | + 'nengo time' => 'H:i', |
| 48 | + 'nengo date' => 'xtY年n月j日 (D)', |
| 49 | + 'nengo both' => 'xtY年n月j日 (D) H:i', |
45 | 50 | ); |
46 | 51 | |
47 | 52 | $namespaceNames = array( |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -567,7 +567,10 @@ |
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 |
| 571 | + * xoY Y (full year) in Minguo calendar or Juche year. |
| 572 | + * Months and days are identical to the |
| 573 | + * Gregorian calendar |
| 574 | + * xtY Y (full year) in Japanese nengo. Months and days are |
572 | 575 | * identical to the Gregorian calendar |
573 | 576 | * |
574 | 577 | * Characters enclosed in double quotes will be considered literal (with |
— | — | @@ -601,6 +604,7 @@ |
602 | 605 | $hijri = false; |
603 | 606 | $thai = false; |
604 | 607 | $minguo = false; |
| 608 | + $tenno = false; |
605 | 609 | for ( $p = 0; $p < strlen( $format ); $p++ ) { |
606 | 610 | $num = false; |
607 | 611 | $code = $format[$p]; |
— | — | @@ -608,7 +612,7 @@ |
609 | 613 | $code .= $format[++$p]; |
610 | 614 | } |
611 | 615 | |
612 | | - if ( ( $code === 'xi' || $code == 'xj' || $code == 'xk' || $code == 'xm' || $code == 'xo' ) && $p < strlen( $format ) - 1 ) { |
| 616 | + if ( ( $code === 'xi' || $code == 'xj' || $code == 'xk' || $code == 'xm' || $code == 'xo' || $code == 'xt' ) && $p < strlen( $format ) - 1 ) { |
613 | 617 | $code .= $format[++$p]; |
614 | 618 | } |
615 | 619 | |
— | — | @@ -752,13 +756,17 @@ |
753 | 757 | $num = $hebrew[0]; |
754 | 758 | break; |
755 | 759 | case 'xkY': |
756 | | - if ( !$thai ) $thai = self::tsToThai( $ts ); |
| 760 | + if ( !$thai ) $thai = self::tsToYear( $ts, 'thai' ); |
757 | 761 | $num = $thai[0]; |
758 | 762 | break; |
759 | 763 | case 'xoY': |
760 | | - if ( !$minguo ) $minguo = self::tsToMinguo( $ts ); |
| 764 | + if ( !$minguo ) $minguo = self::tsToYear( $ts, 'minguo' ); |
761 | 765 | $num = $minguo[0]; |
762 | 766 | break; |
| 767 | + case 'xtY': |
| 768 | + if ( !$tenno ) $tenno = self::tsToYear( $ts, 'tenno' ); |
| 769 | + $num = $tenno[0]; |
| 770 | + break; |
763 | 771 | case 'y': |
764 | 772 | $num = substr( $ts, 2, 2 ); |
765 | 773 | break; |
— | — | @@ -1120,46 +1128,59 @@ |
1121 | 1129 | } |
1122 | 1130 | |
1123 | 1131 | /** |
1124 | | - * Algorithm to convert Gregorian dates to Thai solar dates. |
| 1132 | + * Algorithm to convert Gregorian dates to Thai solar dates, |
| 1133 | + * Minguo dates or Minguo dates. |
1125 | 1134 | * |
1126 | 1135 | * Link: http://en.wikipedia.org/wiki/Thai_solar_calendar |
| 1136 | + * http://en.wikipedia.org/wiki/Minguo_calendar |
| 1137 | + * http://en.wikipedia.org/wiki/Japanese_era_name |
1127 | 1138 | * |
1128 | | - * @param $ts String: 14-character timestamp |
| 1139 | + * @param $ts String: 14-character timestamp, calender name |
1129 | 1140 | * @return array converted year, month, day |
1130 | 1141 | */ |
1131 | | - private static function tsToThai( $ts ) { |
| 1142 | + private static function tsToYear( $ts, $cName ) { |
1132 | 1143 | $gy = substr( $ts, 0, 4 ); |
1133 | 1144 | $gm = substr( $ts, 4, 2 ); |
1134 | 1145 | $gd = substr( $ts, 6, 2 ); |
1135 | 1146 | |
1136 | | - # Add 543 years to the Gregorian calendar |
1137 | | - # Months and days are identical |
1138 | | - $gy_thai = $gy + 543; |
| 1147 | + if (!strcmp($cName,'thai')) { |
| 1148 | + # Thai solar dates |
| 1149 | + # Add 543 years to the Gregorian calendar |
| 1150 | + # Months and days are identical |
| 1151 | + $gy_offset = $gy + 543; |
| 1152 | + } else if ((!strcmp($cName,'minguo')) || !strcmp($cName,'juche')) { |
| 1153 | + # Minguo dates |
| 1154 | + # Deduct 1911 years from the Gregorian calendar |
| 1155 | + # Months and days are identical |
| 1156 | + $gy_offset = $gy - 1911; |
| 1157 | + } else if (!strcmp($cName,'tenno')) { |
| 1158 | + # Minguo dates up to Showa period |
| 1159 | + # Deduct years from the Gregorian calendar |
| 1160 | + # depending on the nengo periods |
| 1161 | + # Months and days are identical |
| 1162 | + if (($gy < 1989) || (($gy == 1989) && ($gm == 1) && ($gd < 8))) { |
| 1163 | + # Shōwa period |
| 1164 | + $gy_gannen = $gy - 1926 + 1; |
| 1165 | + $gy_offset = $gy_gannen + $gy_offset; |
| 1166 | + if ($gy_gannen == 1) |
| 1167 | + $gy_offset = '元'; |
| 1168 | + $gy_offset = '昭和'.$gy_offset; |
| 1169 | + } else { |
| 1170 | + # Heisei period |
| 1171 | + $gy_gannen = $gy - 1989 + 1; |
| 1172 | + $gy_offset = $gy_gannen + $gy_offset; |
| 1173 | + if ($gy_gannen == 1) |
| 1174 | + $gy_offset = '元'; |
| 1175 | + $gy_offset = '平成'.$gy_offset; |
| 1176 | + } |
| 1177 | + } else { |
| 1178 | + $gy_offset = $gy; |
| 1179 | + } |
1139 | 1180 | |
1140 | | - return array( $gy_thai, $gm, $gd ); |
| 1181 | + return array( $gy_offset, $gm, $gd ); |
1141 | 1182 | } |
1142 | 1183 | |
1143 | 1184 | /** |
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 ); |
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 | | - |
1163 | | - /** |
1164 | 1185 | * Roman number formatting up to 3000 |
1165 | 1186 | */ |
1166 | 1187 | static function romanNumeral( $num ) { |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -62,6 +62,7 @@ |
63 | 63 | * Added Minguo calendar support for the Taiwan Chinese language |
64 | 64 | * Database: unionQueries function to be used for UNION sql construction, so |
65 | 65 | it can be overloaded on DB abstraction level for DB specific functionality |
| 66 | +* (bug 18849) Implement Japanese and North Korean calendars |
66 | 67 | |
67 | 68 | === Bug fixes in 1.16 === |
68 | 69 | |