From 6db5ae1ab7f352d582b513e5fdf3281587255a5f Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Mon, 12 Nov 2007 23:32:15 +0000 Subject: [PATCH] I fail to see the need of Iranian invasion to very core of code. needs to be more modular, I suppose. --- RELEASE-NOTES | 1 - languages/Language.php | 104 +------------------------- languages/messages/MessagesEn.php | 14 ---- maintenance/language/messageTypes.inc | 12 --- maintenance/language/messages.inc | 14 ---- 5 files changed, 4 insertions(+), 141 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c82e5718ac..92d742c63e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -51,7 +51,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 1405) Add wgUseNPPatrol option to control patroling for new articles on Special:Newpages * LogLine hook added to allow formatting custom entries in Special:Log. -* Support for Iranian calendar * (bug 1401) Allow hiding logged-in users, bots and patrolled pages on Special:Newpages * ChangesListInsertArticleLink hook added for adding extra article info to RC. * MediaWikiPerformAction hook added for diverting control after the main diff --git a/languages/Language.php b/languages/Language.php index 290e22da70..616b70f553 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -90,13 +90,6 @@ class Language { 'sep', 'oct', 'nov', 'dec' ); - static public $mIranianCalendarMonthMsgs = array( - 'iranian-calendar-m1', 'iranian-calendar-m2', 'iranian-calendar-m3', - 'iranian-calendar-m4', 'iranian-calendar-m5', 'iranian-calendar-m6', - 'iranian-calendar-m7', 'iranian-calendar-m8', 'iranian-calendar-m9', - 'iranian-calendar-m10', 'iranian-calendar-m11', 'iranian-calendar-m12' - ); - /** * Create a language object for a given language code */ @@ -400,11 +393,6 @@ class Language { return $this->getMessageFromDB( self::$mWeekdayAbbrevMsgs[$key-1] ); } - function getIranianCalendarMonthName( $key ) { - return $this->getMessageFromDB( self::$mIranianCalendarMonthMsgs[$key-1] ); - } - - /** * Used by date() and time() to adjust the time output. * @public @@ -476,11 +464,6 @@ class Language { * xx Literal x * xg Genitive month name * - * xij j (day number) in Iranian calendar - * xiF F (month name) in Iranian calendar - * xin n (month number) in Iranian calendar - * xiY Y (full year) in Iranian calendar - * * Characters enclosed in double quotes will be considered literal (with * the quotes themselves removed). Unmatched quotes will be considered * literal quotes. Example: @@ -504,18 +487,13 @@ class Language { $roman = false; $unix = false; $rawToggle = false; - $iranian = false; for ( $p = 0; $p < strlen( $format ); $p++ ) { $num = false; $code = $format[$p]; if ( $code == 'x' && $p < strlen( $format ) - 1 ) { $code .= $format[++$p]; } - - if ( $code === 'xi' && $p < strlen( $format ) - 1 ) { - $code .= $format[++$p]; - } - + switch ( $code ) { case 'xx': $s .= 'x'; @@ -542,10 +520,6 @@ class Language { case 'j': $num = intval( substr( $ts, 6, 2 ) ); break; - case 'xij': - if ( !$iranian ) $iranian = self::tsToIranian( $ts ); - $num = $iranian[2]; - break; case 'l': if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts ); $s .= $this->getWeekdayName( gmdate( 'w', $unix ) + 1 ); @@ -566,14 +540,10 @@ class Language { case 'W': if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts ); $num = gmdate( 'W', $unix ); - break; + break; case 'F': $s .= $this->getMonthName( substr( $ts, 4, 2 ) ); break; - case 'xiF': - if ( !$iranian ) $iranian = self::tsToIranian( $ts ); - $s .= $this->getIranianCalendarMonthName( $iranian[1] ); - break; case 'm': $num = substr( $ts, 4, 2 ); break; @@ -583,10 +553,6 @@ class Language { case 'n': $num = intval( substr( $ts, 4, 2 ) ); break; - case 'xin': - if ( !$iranian ) $iranian = self::tsToIranian( $ts ); - $num = $iranian[1]; - break; case 't': if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts ); $num = gmdate( 't', $unix ); @@ -594,14 +560,10 @@ class Language { case 'L': if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts ); $num = gmdate( 'L', $unix ); - break; + break; case 'Y': $num = substr( $ts, 0, 4 ); break; - case 'xiY': - if ( !$iranian ) $iranian = self::tsToIranian( $ts ); - $num = $iranian[0]; - break; case 'y': $num = substr( $ts, 2, 2 ); break; @@ -686,64 +648,6 @@ class Language { return $s; } - private static $GREG_DAYS = array( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ); - private static $IRANIAN_DAYS = array( 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 ); - /** - * Algorithm by Roozbeh Pournader and Mohammad Toossi to convert - * Gregorian dates to Iranian dates. Originally written in C, it - * is released under the terms of GNU Lesser General Public - * License. Conversion to PHP was performed by Niklas Laxström. - * - * Link: http://www.farsiweb.info/jalali/jalali.c - */ - private static function tsToIranian( $ts ) { - $gy = substr( $ts, 0, 4 ) -1600; - $gm = substr( $ts, 4, 2 ) -1; - $gd = substr( $ts, 6, 2 ) -1; - - # Days passed from the beginning (including leap years) - $gDayNo = 365*$gy - + floor(($gy+3) / 4) - - floor(($gy+99) / 100) - + floor(($gy+399) / 400); - - - // Add days of the past months of this year - for( $i = 0; $i < $gm; $i++ ) { - $gDayNo += self::$GREG_DAYS[$i]; - } - - // Leap years - if ( $gm > 1 && (($gy%4===0 && $gy%100!==0 || ($gy%400==0)))) { - $gDayNo++; - } - - // Days passed in current month - $gDayNo += $gd; - - $jDayNo = $gDayNo - 79; - - $jNp = floor($jDayNo / 12053); - $jDayNo %= 12053; - - $jy = 979 + 33*$jNp + 4*floor($jDayNo/1461); - $jDayNo %= 1461; - - if ( $jDayNo >= 366 ) { - $jy += floor(($jDayNo-1)/365); - $jDayNo = floor(($jDayNo-1)%365); - } - - for ( $i = 0; $i < 11 && $jDayNo >= self::$IRANIAN_DAYS[$i]; $i++ ) { - $jDayNo -= self::$IRANIAN_DAYS[$i]; - } - - $jm= $i+1; - $jd= $jDayNo+1; - - return array($jy, $jm, $jd); - } - /** * Roman number formatting up to 3000 */ @@ -2013,4 +1917,4 @@ class Language { $text = $this->getMessageFromDB( $msg ); return str_replace( '$1', $this->formatNum( $size ), $text ); } -} +} \ No newline at end of file diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index dd108e7943..531944b25e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -3000,18 +3000,4 @@ $1', 'watchlisttools-edit' => 'View and edit watchlist', 'watchlisttools-raw' => 'Edit raw watchlist', -# Iranian month names -'iranian-calendar-m1' => 'Farvardin', # only translate this message to other languages if you have to change it -'iranian-calendar-m2' => 'Ordibehesht', # only translate this message to other languages if you have to change it -'iranian-calendar-m3' => 'Khordad', # only translate this message to other languages if you have to change it -'iranian-calendar-m4' => 'Tir', # only translate this message to other languages if you have to change it -'iranian-calendar-m5' => 'Mordad', # only translate this message to other languages if you have to change it -'iranian-calendar-m6' => 'Shahrivar', # only translate this message to other languages if you have to change it -'iranian-calendar-m7' => 'Mehr', # only translate this message to other languages if you have to change it -'iranian-calendar-m8' => 'Aban', # only translate this message to other languages if you have to change it -'iranian-calendar-m9' => 'Azar', # only translate this message to other languages if you have to change it -'iranian-calendar-m10' => 'Dey', # only translate this message to other languages if you have to change it -'iranian-calendar-m11' => 'Bahman', # only translate this message to other languages if you have to change it -'iranian-calendar-m12' => 'Esfand', # only translate this message to other languages if you have to change it - ); diff --git a/maintenance/language/messageTypes.inc b/maintenance/language/messageTypes.inc index 3cb8e90079..8cf3a3eae6 100644 --- a/maintenance/language/messageTypes.inc +++ b/maintenance/language/messageTypes.inc @@ -214,18 +214,6 @@ $wgOptionalMessages = array( 'size-kilobytes', 'size-megabytes', 'size-gigabytes', - 'iranian-calendar-m1', - 'iranian-calendar-m2', - 'iranian-calendar-m3', - 'iranian-calendar-m4', - 'iranian-calendar-m5', - 'iranian-calendar-m6', - 'iranian-calendar-m7', - 'iranian-calendar-m8', - 'iranian-calendar-m9', - 'iranian-calendar-m10', - 'iranian-calendar-m11', - 'iranian-calendar-m12', ); /** EXIF messages, which may be set as optional in several checks, but are generally mandatory */ diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 88984d13a2..5e7733f8e3 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2226,20 +2226,6 @@ $wgMessageStructure = array( 'watchlisttools-edit', 'watchlisttools-raw', ), - 'iranian-dates' => array( - 'iranian-calendar-m1', - 'iranian-calendar-m2', - 'iranian-calendar-m3', - 'iranian-calendar-m4', - 'iranian-calendar-m5', - 'iranian-calendar-m6', - 'iranian-calendar-m7', - 'iranian-calendar-m8', - 'iranian-calendar-m9', - 'iranian-calendar-m10', - 'iranian-calendar-m11', - 'iranian-calendar-m12', - ), ); /** Comments for each block */ $wgBlockComments = array( -- 2.20.1