From: superyetkin Date: Sat, 21 Apr 2018 21:12:02 +0000 (+0300) Subject: Fix the bug for dates between 1912 and 1941 in Thai language X-Git-Tag: 1.34.0-rc.0~4832^2 X-Git-Url: http://git.cyclocoop.org///%22%40url%40//%22?a=commitdiff_plain;h=3aaa2367b254a0152cd965bcab5c24476f9ae8ba;p=lhc%2Fweb%2Fwiklou.git Fix the bug for dates between 1912 and 1941 in Thai language Added an if-else block to see if the parameters passed to the function designate a year between 1912 and 1941 or not. Resulting month values are also adjusted. Added a unit test for the related formatting. Bug: T68648 Change-Id: Ic676b5c140de8878971a786a1a1811770a848016 --- diff --git a/languages/Language.php b/languages/Language.php index d750f7d519..0941e3dc34 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1884,6 +1884,14 @@ class Language { # Add 543 years to the Gregorian calendar # Months and days are identical $gy_offset = $gy + 543; + # fix for dates between 1912 and 1941 + # https://en.wikipedia.org/?oldid=836596673#New_year + if ( $gy >= 1912 && $gy <= 1940 ) { + if ( $gm <= 3 ) { + $gy_offset--; + } + $gm = ( $gm - 3 ) % 12; + } } elseif ( ( !strcmp( $cName, 'minguo' ) ) || !strcmp( $cName, 'juche' ) ) { # Minguo dates # Deduct 1911 years from the Gregorian calendar diff --git a/tests/phpunit/languages/LanguageTest.php b/tests/phpunit/languages/LanguageTest.php index 050ed83bed..04ffdabfb0 100644 --- a/tests/phpunit/languages/LanguageTest.php +++ b/tests/phpunit/languages/LanguageTest.php @@ -1029,6 +1029,13 @@ class LanguageTest extends LanguageClassesTestCase { '2555', 'Thai year' ], + [ + 'xkY', + '19410101090705', + '2484', + '2484', + 'Thai year' + ], [ 'xoY', '20120102090705',