* (bug 1668) a redesign of the "Date format" system, languages are now able to
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Sat, 26 Mar 2005 01:28:33 +0000 (01:28 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Sat, 26 Mar 2005 01:28:33 +0000 (01:28 +0000)
  specify an arbitary amount of date formats which they wish to use in the
  $wgDateFormatsXx array, if the array is empty the "Date format" option will
  not be shown, the only languages that currently take atvantage of the
  multiple formats are Icelandic, English and Frysk, I removed all but the
  first item of the $wgDateFormatsXx array from those that don't which should
  show something like "use default".

29 files changed:
includes/SpecialPreferences.php
languages/Language.php
languages/LanguageBg.php
languages/LanguageBn.php
languages/LanguageCa.php
languages/LanguageCy.php
languages/LanguageDa.php
languages/LanguageEs.php
languages/LanguageFo.php
languages/LanguageFy.php
languages/LanguageGa.php
languages/LanguageHu.php
languages/LanguageId.php
languages/LanguageIs.php
languages/LanguageLt.php
languages/LanguageMs.php
languages/LanguageNn.php
languages/LanguageNv.php
languages/LanguagePt.php
languages/LanguageRo.php
languages/LanguageSl.php
languages/LanguageSq.php
languages/LanguageSr.php
languages/LanguageSv.php
languages/LanguageTa.php
languages/LanguageTh.php
languages/LanguageTt.php
languages/LanguageUk.php
languages/LanguageWa.php

index 0cc5b2f..a6cd0fc 100644 (file)
@@ -101,7 +101,7 @@ class PreferencesForm {
        }
 
        function execute() {
-               global $wgUser, $wgOut, $wgUseDynamicDates;
+               global $wgUser, $wgOut;
                
                if ( $wgUser->isAnon() ) {
                        $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
@@ -367,7 +367,7 @@ class PreferencesForm {
         * @access private
         */
        function mainPrefsForm( $err ) {
-               global $wgUser, $wgOut, $wgLang, $wgContLang, $wgUseDynamicDates, $wgValidSkinNames;
+               global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
                global $wgAllowRealName, $wgImageLimits;
                global $wgLanguageNames, $wgDisableLangConversion;
                global $wgEmailNotificationForWatchlistPages, $wgEmailNotificationForUserTalkPages,$wgEmailNotificationForMinorEdits;
@@ -605,16 +605,13 @@ class PreferencesForm {
                
                # Date format
                #
-               if ( $wgUseDynamicDates ) {
+
+               if ($dateopts) {
                        $wgOut->addHTML( "<fieldset>\n<legend>$dateFormat</legend>\n" );
-                       for ( $i = 0; $i < count( $dateopts ); ++$i) {
-                               if ( $i == $this->mDate ) {
-                                       $checked = ' checked="checked"';
-                               } else {
-                                       $checked = "";
-                               }
+                       foreach($dateopts as $key => $option) {
+                               ($key == $this->mDate) ? $checked = ' checked="checked"' : $checked = '';
                                $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
-                                       "value=\"$i\"$checked /> {$dateopts[$i]}</label></div>\n" );
+                                       "value=\"$key\"$checked />$option</label></div>\n" );
                        }
                        $wgOut->addHTML( "</fieldset>\n\n");
                }
index dd14786..1cbc205 100644 (file)
@@ -122,11 +122,11 @@ define( 'MW_DATE_DEFAULT', false );
 define( 'MW_DATE_USER_FORMAT', true );
 
 /* private */ $wgDateFormatsEn = array(
-       'No preference',
-       'January 15, 2001',
-       '15 January 2001',
-       '2001 January 15',
-       '2001-01-15'
+       'Default',
+       '16:12, January 15, 2001',
+       '16:12, 15 January 2001',
+       '16:12, 2001 January 15',
+       'ISO 8601' => '2001-01-15 16:12:34'
 );
 
 /* private */ $wgUserTogglesEn = array(
@@ -1788,10 +1788,6 @@ ta[\'ca-nstab-category\'] = new Array(\'c\',\'View the category page\');
 'specialloguserlabel' => 'User: ',
 'speciallogtitlelabel' => 'Title: ',
 
-# labels for Group: and User: ond Special:Listusers
-'speciallistusersuserlabel' => 'User: ',
-'speciallistusersgrouplabel' => 'Group: ',
-
 'passwordtooshort' => 'Your password is too short. It must have at least $1 characters.',
 
 # external editor support
@@ -1971,35 +1967,33 @@ class Language {
        }
 
        function date( $ts, $adj = false, $format = MW_DATE_USER_FORMAT, $timecorrection = false ) {
-               global $wgAmericanDates, $wgUser, $wgUseDynamicDates;
-
+               global $wgAmericanDates, $wgUser;
+               
                $ts=wfTimestamp(TS_MW,$ts);
 
                if ( $adj ) { $ts = $this->userAdjust( $ts, $timecorrection ); }
 
-               if ( $wgUseDynamicDates ) {
-                       if ( $format == MW_DATE_USER_FORMAT ) {
-                               $datePreference = $wgUser->getOption( 'date' );
-                       } else {
-                               $options = $this->getDefaultUserOptions();
-                               $datePreference = $options['date'];
-                       }
-                       if ( $datePreference == 0 ) {
-                               $datePreference = $wgAmericanDates ? 1 : 2;
-                       }
+               
+               if ( $format == MW_DATE_USER_FORMAT ) {
+                       $datePreference = $wgUser->getOption( 'date' );
                } else {
+                       $options = $this->getDefaultUserOptions();
+                       $datePreference = $options['date'];
+               }
+
+               if ($datePreference == '0') {
                        $datePreference = $wgAmericanDates ? 1 : 2;
                }
 
                $month = $this->getMonthAbbreviation( substr( $ts, 4, 2 ) );
                $day = $this->formatNum( 0 + substr( $ts, 6, 2 ) );
                $year = $this->formatNum( substr( $ts, 0, 4 ) );
-
+               
                switch( $datePreference ) {
-                       case 1: return "$month $day, $year";
-                       case 2: return "$day $month $year";
-                       case 4: return substr($ts, 0, 4). '-' . substr($ts, 4, 2). '-' .substr($ts, 6, 2);
-                       default: return "$year $month $day";
+                       case '2': return "$day $month $year";
+                       case '3': return "$year $month $day";
+                       case 'ISO 8601': return substr($ts, 0, 4). '-' . substr($ts, 4, 2). '-' .substr($ts, 6, 2);
+                       default: return "$month $day, $year";
                }
        }
 
@@ -2010,7 +2004,7 @@ class Language {
                if ( $adj ) { $ts = $this->userAdjust( $ts, $timecorrection ); }
 
                $t = substr( $ts, 8, 2 ) . ':' . substr( $ts, 10, 2 );
-               if ( $seconds || $wgUser->getOption( 'date' ) == 4) {
+               if ( $seconds || $wgUser->getOption( 'date' ) == 'ISO 8601' ) {
                        $t .= ':' . substr( $ts, 12, 2 );
                }
                return $this->formatNum( $t );
@@ -2019,11 +2013,11 @@ class Language {
        function timeanddate( $ts, $adj = false, $format = MW_DATE_USER_FORMAT, $timecorrection = false, $dateandtime = false) {
                global $wgUser;
                $ts=wfTimestamp(TS_MW,$ts);
-               if ( 4 == $wgUser->getOption( 'date' ) ) {
-                       return $this->date( $ts, $adj, $format, $timecorrection ) . ' ' .
+
+               switch ( $wgUser->getOption( 'date' ) ) {
+                       case 'ISO 8601': return $this->date( $ts, $adj, $format, $timecorrection ) . ' ' .
                                $this->time( $ts, $adj, false, $timecorrection );
-               } else {
-                       return $this->time( $ts, $adj, false, $timecorrection ) . ', ' .
+                       default: return $this->time( $ts, $adj, false, $timecorrection ) . ', ' .
                                $this->date( $ts, $adj, $format, $timecorrection );
                }
        }
index 7bf4c6b..2f5f9bf 100644 (file)
 
 /* private */ $wgDateFormatsBg = array(
   'Без предпочитание',
-  'януари 15, 2001',
-  '15 януари 2001',
-  '2001 януари 15',
-  '2001-01-15'
 );
 
 
index c6881e3..a23419b 100644 (file)
@@ -43,9 +43,6 @@
 
 /* private */ $wgDateFormatsBn = array(
   "No preference",
-  "January 15, 2001",
-  "15 January 2001",
-  "2001 January 15"
 );
 
 
index cf5e204..bac612d 100644 (file)
 
 /* private */ $wgDateFormatsCa = array(
        "No preference",
-       "January 15, 2001",
-       "15 January 2001",
-       "2001 January 15",
-       "2001-01-15"
 );
 
 
index 00a2432..cabf7d1 100644 (file)
 
 /* private */ $wgDateFormatsCy = array(
        "Dim dewis",
-       "Ionawr 15, 2001",
-       "15 Ionawr 2001",
-       "2001 Ionawr 15",
-       "2001-01-15"
 );
 
 /* private */ $wgBookstoreListCy = array(
index 6638569..e7aab21 100644 (file)
@@ -57,10 +57,6 @@ require_once( "LanguageUtf8.php" );
 
 /* private */ $wgDateFormatsDa = array(
        "Ingen foretrukken",
-       "januar 15, 2001",
-       "15. januar 2001",
-       "2001 januar 15",
-       "2001-01-15"
 );
 
 
index 545aa5d..9f3f625 100644 (file)
@@ -56,9 +56,6 @@ require_once( "LanguageUtf8.php" );
 
 /* private */ $wgDateFormatsEs = array(
        "Sin preferencia",
-       "enero 15, 2001",
-       "15 de enero de 2001",
-       "2001 enero 15"
 );
 
 /* Please customize this with some Spanish-language bookshops
index 81724cf..94d283d 100644 (file)
@@ -49,10 +49,6 @@ require_once( 'LanguageUtf8.php');
 
 /* private */ $wgDateFormatsFo = array(
        "Ongi forrættindi",
-       "januar 15, 2001",
-       "15. januar 2001",
-       "2001 januar 15",
-       "2001-01-15"
 );
 
 /* private */ $wgBookstoreListFo = array(
index 9384a8b..0750752 100644 (file)
@@ -53,10 +53,11 @@ if($wgMetaNamespace === FALSE)
 
 
 /* private */ $wgDateFormatsFy = array(
-       "Gjin foarkar",
-       "jannewaris 8, 2001",
-       "8 jannewaris 2001",
-       "2001 jannewaris 8"
+       'Gjin foarkar',
+       '16:12, jan 15, 2001',
+       '16:12, 15 jan 2001',
+       '16:12, 2001 jan 15',
+       'ISO 8601' => '2001-01-15 16:12:34'
 );
 
 /* private */ $wgBookstoreListFy = array(
@@ -1081,52 +1082,35 @@ class LanguageFy extends LanguageUtf8 {
 
  # Inherit userAdjust()
  
-       function date( $ts, $adj = false )
-       {
-               global $wgAmericanDates, $wgUser, $wgUseDynamicDates;
+       function date( $ts, $adj = false ) {
+               global $wgUser;
 
                if ( $adj ) { $ts = $this->userAdjust( $ts ); }
                
-               if ( $wgUseDynamicDates ) {
-                       $datePreference = $wgUser->getOption( 'date' );         
-                       if ( $datePreference == 0 ) {
-                               $datePreference = $wgAmericanDates ? 1 : 2;
-                       }
-               } else {
-                       $datePreference = $wgAmericanDates ? 1 : 2;
+               switch ( $wgUser->getOption( 'date' ) ) {
+                       # jan 8, 2001
+                       case '0': case '1': return $d = $this->getMonthAbbreviation( substr( $ts, 4, 2 ) )
+                               . ' ' . (0 + substr( $ts, 6, 2 )) . ', ' . substr( $ts, 0, 4 );
+                       # 8 jannewaris 2001
+                       case '2': return (0 + substr( $ts, 6, 2 )) . ' ' .
+                               $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ) . ' ' .
+                               substr( $ts, 0, 4 );
+                       case 'ISO 8601': return substr($ts, 0, 4). '-' . substr($ts, 4, 2). '-' .substr($ts, 6, 2);
+                       # 2001 jannewaris 8
+                       default: return substr( $ts, 0, 4 ) . ' ' .
+                               $this->getMonthAbbreviation( substr( $ts, 4, 2 ) )
+                               . ' ' . (0 + substr( $ts, 6, 2 ));
                }
+       }
+       function timeanddate( $ts, $adj = false ) {
+               global $wgUser;
                
-               if ( $datePreference == 1 ) {
-                       # MDY
-                       $d = $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ) .
-                         " " . (0 + substr( $ts, 6, 2 )) . ", " .
-                         substr( $ts, 0, 4 );
-               } else if ( $datePreference == 2 ) {
-                       #DMY
-                       $d = (0 + substr( $ts, 6, 2 )) . " " .
-                         $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ) . " " .
-                         substr( $ts, 0, 4 );
-               } else {
-                       #YMD
-                       $d = substr( $ts, 0, 4 ) . " " . $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ) .
-                               " " . (0 + substr( $ts, 6, 2 ));
+               switch ( $wgUser->getOption( 'date' ) ) {
+                       case 'ISO 8601': return $this->date( $ts, $adj ) . ' ' . $this->time( $ts, $adj ); 
+                       default: return $this->time( $ts, $adj ) . ', ' . $this->date( $ts, $adj );
                }
-
-               return $d;
-       }
-
-       function time( $ts, $adj = false )
-       {
-               if ( $adj ) { $ts = $this->userAdjust( $ts ); }
-
-               $t = substr( $ts, 8, 2 ) . "." . substr( $ts, 10, 2 );
-               return $t;
        }
 
-# Inherit timeanddate()
-
-# Inherit rfc1123()
-
        function getValidSpecialPages()
        {
                global $wgValidSpecialPagesFy;
index 1e31d59..f5e641b 100755 (executable)
@@ -63,10 +63,6 @@ DISCUSSION!
 
 /* private */ $wgDateFormatsGa = array(
     "Is cuma liom",
-    "Eanáir 15, 2001",
-    "15 Eanáir 2001",
-    "2001 Eanáir 15",
-    "2001-01-15"
 );
 
 # If possible, find Irish language book services on the Internet, searchable by ISBN
index 4e28ab3..44210e7 100644 (file)
@@ -79,9 +79,6 @@ if( 0 == strcasecmp( "Wikipédia", $wgSitename ) ) {
 
 /* private */ $wgDateFormatsHu = array(
        "Mindegy",
-       "Július 8, 2003",
-       "8 Július, 2003",
-       "2003 Július 8"
 );
 
 
index 870c2c1..de380c1 100644 (file)
@@ -72,10 +72,6 @@ if($wgMetaNamespace === FALSE)
 
 /* private */ $wgDateFormatsId = array(
        "Tiada pilihan",
-       "Januari 15, 2001",
-       "15 Januari 2001",
-       "2001 Januari 15",
-       "2001-01-15" 
 );
 
 /* private */ $wgUserTogglesId = array(
index 2b3736c..28ff99b 100644 (file)
@@ -869,7 +869,7 @@ class LanguageIs extends LanguageUtf8 {
                
                switch( $wgUser->getOption( 'date' )  ) {
                        # 15. jan. 2001 kl. 16:12 || 16:12, 15. jan. 2001
-                       case 2: case 4: return (0 + substr( $ts, 6, 2 )) . '. ' .
+                       case '2': case '4': return (0 + substr( $ts, 6, 2 )) . '. ' .
                                $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ) . '. ' .
                                substr($ts, 0, 4);
                        # 2001-01-15 16:12:34
@@ -900,7 +900,7 @@ class LanguageIs extends LanguageUtf8 {
                
                switch ( $wgUser->getOption( 'date' ) ) {
                        # 16:12, 15. janúar 2001 || 16:12, 15. jan. 2001
-                       case 3: case 4: return $this->time( $ts, $adj ) . ', ' . $this->date( $ts, $adj );
+                       case '3': case '4': return $this->time( $ts, $adj ) . ', ' . $this->date( $ts, $adj );
                        # 2001-01-15 16:12:34
                        case 'ISO 8601': return $this->date( $ts, $adj ) . ' ' . $this->time( $ts, $adj );
                        # 15. janúar 2001 kl. 16:12 || 15. jan. 2001 kl. 16:12
index 2dea87d..5996eef 100644 (file)
@@ -27,10 +27,6 @@ require_once( "LanguageUtf8.php" );
 
 /* private */ $wgDateFormatsLt = array(
         "Nesvarbu",
-        "Sausio 15, 2001",
-        "15 Sausio 2001",
-        "2001 Sausio 15",
-        "2001-01-15"
 );
 
 /* private */ $wgWeekdayNamesLt = array(
index 2526704..352830d 100644 (file)
@@ -46,8 +46,6 @@
 
 /* private */ $wgDateFormatsMs = array(
        "Tiada pilihan", # "No preference",
-       "15 Januari 2001", # "Januari 15, 2001",
-       "15 Januari 2001", # "2001 Januari 15"
 );
 
 
index f89e07f..9dcd52b 100644 (file)
@@ -74,10 +74,6 @@ $wgValidationTypesNn = array (
 
 /* private */ $wgDateFormatsNn = array(
        'Ingen preferanse',
-       'januar 15, 2001',
-       '15 januar 2001',
-       '2001 januar 15',
-       '2001-01-15'
 );
 
 /* private */ $wgBookstoreListNn = array(
index 50fc3a8..57fd7c4 100755 (executable)
@@ -54,10 +54,6 @@ if($wgMetaNamespace === FALSE)
 
 /* private */ $wgDateFormatsNv = array(
        'No preference',
-       'Yas Niłt\'ees 15, 2001',
-       '15 Yas Niłt\'ees 2001',
-       '2001 Yas Niłt\'ees 15',
-       '2001-01-15'
 );
 
 /* private */ $wgUserTogglesNv = array(
index b792e5d..ebbd989 100644 (file)
@@ -60,9 +60,6 @@
 
 /* private */ $wgDateFormatsPt = array(
     "Sem preferência",
-    "Janeiro 15, 2001",
-    "15 Janeiro 2001",
-    "2001 Janeiro 15"
 );
 
 
index 47ff9ba..6224756 100644 (file)
@@ -50,9 +50,6 @@ require_once("LanguageUtf8.php");
 
 /* private */ $wgDateFormatsRo = array(
        "Nici o preferinţă",
-       "Ianuarie 15, 2001",
-       "15 Ianuarie 2001",
-       "2001 Ianuarie 15"
 );
 
 /* private */ $wgBookstoreListRo = array(
index ae89dae..4f0048d 100644 (file)
@@ -117,10 +117,6 @@ require_once( "LanguageUtf8.php" );
 
 /* private */ $wgDateFormatsSl = array(
         'No preference',
-        'januar 15, 2001',
-        '15 januar 2001',
-        '2001 januar 15',
-        '2001-01-15'
 );
 
 
index 9525cc3..51014a2 100644 (file)
@@ -48,9 +48,6 @@ require_once("LanguageUtf8.php");
 
 /* private */ $wgDateFormatsSq = array(
        "Pa preferencë",
-       "Janar 15, 2001",
-       "15 Janar 2001",
-       "2001 Janar 15"
 );
 
 
index 1ca9df2..b9bce86 100644 (file)
@@ -34,9 +34,6 @@ require_once( "LanguageUtf8.php" );
 
 /* private */ $wgDateFormatsSr = array(
  "Без посебних жеља",
- "Јануар 15, 2001",
- "15 Јануар 2001",
- "2001 Јануар 15"
 );
 
 
index 39ace2f..96befc3 100644 (file)
@@ -62,10 +62,6 @@ require_once( "LanguageUtf8.php" );
 
 /* private */ $wgDateFormatsSv = array(
        "Ingen inställning",
-       "Januari 15, 2001",
-       "15 Januari 2001",
-       "2001 Januari 15",
-       "2001-01-15"
 );
 
 /* private */ $wgBookstoreListSv = array(
index 8b1fa8e..47a0644 100644 (file)
@@ -57,9 +57,6 @@ require_once( "LanguageUtf8.php" );
 
 /* private */ $wgDateFormatsTa = array(
        "முன்னுரிமை இல்லை",
-       "ஜனவரி 15, 2001",
-       "15 ஜனவரி 2001",
-       "2001 ஜனவரி 15"
 );
 
 
index 3f54134..bc84fc1 100644 (file)
 
 /* private */ $wgDateFormatsTh = array(
        "No preference",
-       "มกราคม 15, 2001",
-       "15 มกราคม 2001",
-       "2001 มกราคม 15",
-       "2001-01-15"
 );
 
 
index 10874d4..917ce58 100644 (file)
@@ -55,10 +55,6 @@ require_once( "LanguageUtf8.php" );
 
 /* private */ $wgDateFormatsTt = array(
         "köyläwsez",
-        "Ğínwar 15, 2001",
-        "15. Ğínwar 2001",
-        "2001 Ğínwar 15",
-        "2001-01-15"
 );
 
 
index fbd1c4b..65dd5e3 100755 (executable)
@@ -51,9 +51,6 @@ require_once( "LanguageUtf8.php" );
 /* Non-std date formats are only enabled for English, which is idiosyncratic that way */
 /* private */ $wgDateFormatsUk = array(
        "Немає значення",
-       "Січень 15, 2001",
-       "15 січня 2001",
-       "2001 січень 15"
 );
 
 
index 3a41a56..1f7f554 100644 (file)
@@ -44,10 +44,6 @@ require_once( "LanguageUtf8.php" );
 
 /* private */ $wgDateFormatsWa = array( /* cwè fé chal ??? */
        "Nole preferince",
-       "January 15, 2001",
-       "15 January 2001",
-       "2001 January 15",
-       "2001-01-15"
 );
 
 /* private */ $wgBookstoreListWa = array(