X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=languages%2FLanguage.php;h=97920950e00c076a61f8c693d5f47c0914726fc8;hb=3c25a52df91930c56f4f9da9b216ebed993022c1;hp=1623c36129b824ac6f1f904be25f6bbf94db7c93;hpb=cd5a34611af3d755ce2bd2793fc22ecceef9568c;p=lhc%2Fweb%2Fwiklou.git diff --git a/languages/Language.php b/languages/Language.php index 1623c36129..97920950e0 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -220,7 +220,8 @@ class Language { // Check if there is a language class for the code $class = self::classFromCode( $code, $fallback ); - if ( class_exists( $class ) ) { + // LanguageCode does not inherit Language + if ( class_exists( $class ) && is_a( $class, 'Language', true ) ) { $lang = new $class; return $lang; } @@ -1089,7 +1090,7 @@ class Language { * @param string $ts 14-character timestamp * YYYYMMDDHHMMSS * 01234567890123 - * @param DateTimeZone $zone Timezone of $ts + * @param DateTimeZone|null $zone Timezone of $ts * @param int &$ttl The amount of time (in seconds) the output may be cached for. * Only makes sense if $ts is the current time. * @todo handling of "o" format character for Iranian, Hebrew, Hijri & Thai? @@ -1882,6 +1883,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 @@ -3488,6 +3497,7 @@ class Language { * @return string */ function truncate( $string, $length, $ellipsis = '...', $adjustLength = true ) { + wfDeprecated( __METHOD__, '1.31' ); return $this->truncateForDatabase( $string, $length, $ellipsis, $adjustLength ); } @@ -4075,7 +4085,7 @@ class Language { * match up with it. * * @param string $str The validated block duration in English - * @param User $user User object to use timezone from or null for $wgUser + * @param User|null $user User object to use timezone from or null for $wgUser * @param int $now Current timestamp, for formatting relative block durations * @return string Somehow translated block duration * @see LanguageFi.php for example implementation @@ -4399,7 +4409,7 @@ class Language { * @return bool */ public function equals( Language $lang ) { - return $lang->getCode() === $this->mCode; + return $lang === $this || $lang->getCode() === $this->mCode; } /**