From: Raimond Spekking Date: Thu, 6 Dec 2007 20:14:36 +0000 (+0000) Subject: * (bug 11657) Support for Thai solar calendar X-Git-Tag: 1.31.0-rc.0~50518 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=78d45ea73926c526c8302ff6703476092e59dc2f;p=lhc%2Fweb%2Fwiklou.git * (bug 11657) Support for Thai solar calendar --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ec5e273ce5..be0b761e59 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -91,6 +91,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 8396) Ignore out-of-date serialised message caches * (bug 12195) Undeleting pages now requires 'undelete' permission * (bug 11810) Localize displayed semicolons +* (bug 11657) Support for Thai solar calendar === Bug fixes in 1.12 === diff --git a/languages/Language.php b/languages/Language.php index a6e8e9fab6..9cbe943033 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -513,6 +513,9 @@ class Language { * xjn n (month number) in Hebrew calendar * xjY Y (full year) in Hebrew calendar * + * xkY Y (full year) in Thai solar 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 * literal quotes. Example: @@ -539,6 +542,7 @@ class Language { $rawToggle = false; $iranian = false; $hebrew = false; + $thai = false; for ( $p = 0; $p < strlen( $format ); $p++ ) { $num = false; $code = $format[$p]; @@ -546,7 +550,7 @@ class Language { $code .= $format[++$p]; } - if ( ( $code === 'xi' || $code == 'xj' ) && $p < strlen( $format ) - 1 ) { + if ( ( $code === 'xi' || $code == 'xj' || $code == 'xk' ) && $p < strlen( $format ) - 1 ) { $code .= $format[++$p]; } @@ -659,6 +663,10 @@ class Language { if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts ); $num = $hebrew[0]; break; + case 'xkY': + if ( !$thai ) $thai = self::tsToThai( $ts ); + $num = $thai[0]; + break; case 'y': $num = substr( $ts, 2, 2 ); break; @@ -913,6 +921,27 @@ class Language { return array( $hebrewYear, $month, $day ); } + /** + * Algorithm to convert Gregorian dates to Thai solar dates. + * + * Link: http://en.wikipedia.org/wiki/Thai_solar_calendar + * + * @param string $ts 14-character timestamp + * @return array converted year, month, day + */ + private static function tsToThai( $ts ) { + $gy = substr( $ts, 0, 4 ); + $gm = substr( $ts, 4, 2 ); + $gd = substr( $ts, 6, 2 ); + + # Add 543 years to the Gregorian calendar + # Months and days are identical + $gy_thai = $gy + 543; + + return array( $gy_thai, $gm, $gd ); + } + + /** * Based on Carl Friedrich Gauss algorithm for finding Easter date. * Used for Hebrew date. diff --git a/languages/messages/MessagesTh.php b/languages/messages/MessagesTh.php index 0422d93820..3381f50170 100644 --- a/languages/messages/MessagesTh.php +++ b/languages/messages/MessagesTh.php @@ -29,6 +29,54 @@ $namespaceNames = array( NS_CATEGORY_TALK => 'คุยเรื่องหมวดหมู่', ); +/** + * A list of date format preference keys which can be selected in user + * preferences. New preference keys can be added, provided they are supported + * by the language class's timeanddate(). Only the 5 keys listed below are + * supported by the wikitext converter (DateFormatter.php). + * + * The special key "default" is an alias for either dmy or mdy depending on + * $wgAmericanDates + */ +$datePreferences = array( + 'default', + 'thai', + 'mdy', + 'dmy', + 'ymd', + 'ISO 8601', +); + +/** + * These are formats for dates generated by MediaWiki (as opposed to the wikitext + * DateFormatter). Documentation for the format string can be found in + * Language.php, search for sprintfDate. + * + * This array is automatically inherited by all subclasses. Individual keys can be + * overridden. + */ +$dateFormats = array( + 'thai time' => 'H:i', + 'thai date' => 'j F xkY', + 'thai both' => 'H:i, j F xkY', + + 'mdy time' => 'H:i', + 'mdy date' => 'F j, Y', + 'mdy both' => 'H:i, F j, Y', + + 'dmy time' => 'H:i', + 'dmy date' => 'j F Y', + 'dmy both' => 'H:i, j F Y', + + 'ymd time' => 'H:i', + 'ymd date' => 'Y F j', + 'ymd both' => 'H:i, Y F j', + + 'ISO 8601 time' => 'xnH:xni:xns', + 'ISO 8601 date' => 'xnY-xnm-xnd', + 'ISO 8601 both' => 'xnY-xnm-xnd"T"xnH:xni:xns', +); + $linkTrail = '/^([a-z]+)(.*)\$/sD'; $messages = array(