From 2f2bdad9127abc2b2cc09aecdc5f37e06793e561 Mon Sep 17 00:00:00 2001 From: Shinjiman Date: Tue, 19 May 2009 16:38:21 +0000 Subject: [PATCH] added Minguo calendar support for the Taiwan Chinese language --- languages/Language.php | 28 +++++++++++++++++++++++++++- languages/messages/MessagesZh_tw.php | 23 +++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/languages/Language.php b/languages/Language.php index e296d901f8..aa96d6f87b 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -567,6 +567,8 @@ class Language { * * xkY Y (full year) in Thai solar calendar. Months and days are * identical to the Gregorian calendar + * xoY Y (full year) in Minguo calendar. Months and days are + * identical to the Gregorian calendar * * Characters enclosed in double quotes will be considered literal (with * the quotes themselves removed). Unmatched quotes will be considered @@ -598,6 +600,7 @@ class Language { $hebrew = false; $hijri = false; $thai = false; + $minguo = false; for ( $p = 0; $p < strlen( $format ); $p++ ) { $num = false; $code = $format[$p]; @@ -605,7 +608,7 @@ class Language { $code .= $format[++$p]; } - if ( ( $code === 'xi' || $code == 'xj' || $code == 'xk' || $code == 'xm' ) && $p < strlen( $format ) - 1 ) { + if ( ( $code === 'xi' || $code == 'xj' || $code == 'xk' || $code == 'xm' || $code == 'xo' ) && $p < strlen( $format ) - 1 ) { $code .= $format[++$p]; } @@ -752,6 +755,10 @@ class Language { if ( !$thai ) $thai = self::tsToThai( $ts ); $num = $thai[0]; break; + case 'xoY': + if ( !$minguo ) $minguo = self::tsToMinguo( $ts ); + $num = $minguo[0]; + break; case 'y': $num = substr( $ts, 2, 2 ); break; @@ -1132,6 +1139,25 @@ class Language { return array( $gy_thai, $gm, $gd ); } + /** + * Algorithm to convert Gregorian dates to Minguo dates. + * + * Link: http://en.wikipedia.org/wiki/Minguo_calendar + * + * @param $ts String: 14-character timestamp + * @return array converted year, month, day + */ + private static function tsToMinguo( $ts ) { + $gy = substr( $ts, 0, 4 ); + $gm = substr( $ts, 4, 2 ); + $gd = substr( $ts, 6, 2 ); + + # Deduct 1911 years from the Gregorian calendar + # Months and days are identical + $gy_minguo = $gy - 1911; + + return array( $gy_minguo, $gm, $gd ); + } /** * Roman number formatting up to 3000 diff --git a/languages/messages/MessagesZh_tw.php b/languages/messages/MessagesZh_tw.php index a39a7d9ef4..a83a503268 100644 --- a/languages/messages/MessagesZh_tw.php +++ b/languages/messages/MessagesZh_tw.php @@ -38,6 +38,29 @@ $namespaceNames = array( NS_CATEGORY_TALK => '分類討論' ); +$datePreferences = array( + 'default', + 'minguo', + 'CNS 7648', + 'ISO 8601', +); + +$defaultDateFormat = 'zh'; + +$dateFormats = array( + 'zh time' => 'H:i', + 'zh date' => 'Y年n月j日 (l)', + 'zh both' => 'Y年n月j日 (D) H:i', + + 'minguo time' => 'H:i', + 'minguo date' => 'xoY年n月j日 (l)', + 'minguo both' => 'xoY年n月j日 (D) H:i', + + 'CNS 7648 time' => 'H:i', + 'CNS 7648 date' => 'R.O.C. xoY-m-d (l)', + 'CNS 7648 both' => 'R.O.C. xoY-m-d (D) H:i', +); + $messages = array( # User preference toggles 'tog-underline' => '鏈結標注底線', -- 2.20.1