Index: trunk/phase3/languages/messages/MessagesTh.php |
— | — | @@ -29,6 +29,54 @@ |
30 | 30 | NS_CATEGORY_TALK => 'คุยเรื่องหมวดหมู่', |
31 | 31 | ); |
32 | 32 | |
| 33 | +/** |
| 34 | + * A list of date format preference keys which can be selected in user |
| 35 | + * preferences. New preference keys can be added, provided they are supported |
| 36 | + * by the language class's timeanddate(). Only the 5 keys listed below are |
| 37 | + * supported by the wikitext converter (DateFormatter.php). |
| 38 | + * |
| 39 | + * The special key "default" is an alias for either dmy or mdy depending on |
| 40 | + * $wgAmericanDates |
| 41 | + */ |
| 42 | +$datePreferences = array( |
| 43 | + 'default', |
| 44 | + 'thai', |
| 45 | + 'mdy', |
| 46 | + 'dmy', |
| 47 | + 'ymd', |
| 48 | + 'ISO 8601', |
| 49 | +); |
| 50 | + |
| 51 | +/** |
| 52 | + * These are formats for dates generated by MediaWiki (as opposed to the wikitext |
| 53 | + * DateFormatter). Documentation for the format string can be found in |
| 54 | + * Language.php, search for sprintfDate. |
| 55 | + * |
| 56 | + * This array is automatically inherited by all subclasses. Individual keys can be |
| 57 | + * overridden. |
| 58 | + */ |
| 59 | +$dateFormats = array( |
| 60 | + 'thai time' => 'H:i', |
| 61 | + 'thai date' => 'j F xkY', |
| 62 | + 'thai both' => 'H:i, j F xkY', |
| 63 | + |
| 64 | + 'mdy time' => 'H:i', |
| 65 | + 'mdy date' => 'F j, Y', |
| 66 | + 'mdy both' => 'H:i, F j, Y', |
| 67 | + |
| 68 | + 'dmy time' => 'H:i', |
| 69 | + 'dmy date' => 'j F Y', |
| 70 | + 'dmy both' => 'H:i, j F Y', |
| 71 | + |
| 72 | + 'ymd time' => 'H:i', |
| 73 | + 'ymd date' => 'Y F j', |
| 74 | + 'ymd both' => 'H:i, Y F j', |
| 75 | + |
| 76 | + 'ISO 8601 time' => 'xnH:xni:xns', |
| 77 | + 'ISO 8601 date' => 'xnY-xnm-xnd', |
| 78 | + 'ISO 8601 both' => 'xnY-xnm-xnd"T"xnH:xni:xns', |
| 79 | +); |
| 80 | + |
33 | 81 | $linkTrail = '/^([a-z]+)(.*)\$/sD'; |
34 | 82 | |
35 | 83 | $messages = array( |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -513,6 +513,9 @@ |
514 | 514 | * xjn n (month number) in Hebrew calendar |
515 | 515 | * xjY Y (full year) in Hebrew calendar |
516 | 516 | * |
| 517 | + * xkY Y (full year) in Thai solar calendar. Months and days are |
| 518 | + * identical to the Gregorian calendar |
| 519 | + * |
517 | 520 | * Characters enclosed in double quotes will be considered literal (with |
518 | 521 | * the quotes themselves removed). Unmatched quotes will be considered |
519 | 522 | * literal quotes. Example: |
— | — | @@ -539,6 +542,7 @@ |
540 | 543 | $rawToggle = false; |
541 | 544 | $iranian = false; |
542 | 545 | $hebrew = false; |
| 546 | + $thai = false; |
543 | 547 | for ( $p = 0; $p < strlen( $format ); $p++ ) { |
544 | 548 | $num = false; |
545 | 549 | $code = $format[$p]; |
— | — | @@ -546,7 +550,7 @@ |
547 | 551 | $code .= $format[++$p]; |
548 | 552 | } |
549 | 553 | |
550 | | - if ( ( $code === 'xi' || $code == 'xj' ) && $p < strlen( $format ) - 1 ) { |
| 554 | + if ( ( $code === 'xi' || $code == 'xj' || $code == 'xk' ) && $p < strlen( $format ) - 1 ) { |
551 | 555 | $code .= $format[++$p]; |
552 | 556 | } |
553 | 557 | |
— | — | @@ -659,6 +663,10 @@ |
660 | 664 | if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts ); |
661 | 665 | $num = $hebrew[0]; |
662 | 666 | break; |
| 667 | + case 'xkY': |
| 668 | + if ( !$thai ) $thai = self::tsToThai( $ts ); |
| 669 | + $num = $thai[0]; |
| 670 | + break; |
663 | 671 | case 'y': |
664 | 672 | $num = substr( $ts, 2, 2 ); |
665 | 673 | break; |
— | — | @@ -914,6 +922,27 @@ |
915 | 923 | } |
916 | 924 | |
917 | 925 | /** |
| 926 | + * Algorithm to convert Gregorian dates to Thai solar dates. |
| 927 | + * |
| 928 | + * Link: http://en.wikipedia.org/wiki/Thai_solar_calendar |
| 929 | + * |
| 930 | + * @param string $ts 14-character timestamp |
| 931 | + * @return array converted year, month, day |
| 932 | + */ |
| 933 | + private static function tsToThai( $ts ) { |
| 934 | + $gy = substr( $ts, 0, 4 ); |
| 935 | + $gm = substr( $ts, 4, 2 ); |
| 936 | + $gd = substr( $ts, 6, 2 ); |
| 937 | + |
| 938 | + # Add 543 years to the Gregorian calendar |
| 939 | + # Months and days are identical |
| 940 | + $gy_thai = $gy + 543; |
| 941 | + |
| 942 | + return array( $gy_thai, $gm, $gd ); |
| 943 | + } |
| 944 | + |
| 945 | + |
| 946 | + /** |
918 | 947 | * Based on Carl Friedrich Gauss algorithm for finding Easter date. |
919 | 948 | * Used for Hebrew date. |
920 | 949 | */ |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -91,6 +91,7 @@ |
92 | 92 | * (bug 8396) Ignore out-of-date serialised message caches |
93 | 93 | * (bug 12195) Undeleting pages now requires 'undelete' permission |
94 | 94 | * (bug 11810) Localize displayed semicolons |
| 95 | +* (bug 11657) Support for Thai solar calendar |
95 | 96 | |
96 | 97 | === Bug fixes in 1.12 === |
97 | 98 | |