MediaWiki  REL1_22
date-formats.php
Go to the documentation of this file.
00001 <?php
00024 require_once __DIR__ . '/../Maintenance.php';
00025 
00031 class DateFormats extends Maintenance {
00032 
00033     private $ts = '20010115123456';
00034 
00035     public function __construct() {
00036         parent::__construct();
00037         $this->mDescription = "Test various language time and date functions";
00038     }
00039 
00040     public function execute() {
00041         global $IP;
00042         foreach ( glob( "$IP/languages/messages/Messages*.php" ) as $filename ) {
00043             $base = basename( $filename );
00044             $m = array();
00045             if ( !preg_match( '/Messages(.*)\.php$/', $base, $m ) ) {
00046                 continue;
00047             }
00048             $code = str_replace( '_', '-', strtolower( $m[1] ) );
00049             $this->output( "$code " );
00050             $lang = Language::factory( $code );
00051             $prefs = $lang->getDatePreferences();
00052             if ( !$prefs ) {
00053                 $prefs = array( 'default' );
00054             }
00055             $this->output( "date: " );
00056             foreach ( $prefs as $index => $pref ) {
00057                 if ( $index > 0 ) {
00058                     $this->output( ' | ' );
00059                 }
00060                 $this->output( $lang->date( $this->ts, false, $pref ) );
00061             }
00062             $this->output( "\n$code time: " );
00063             foreach ( $prefs as $index => $pref ) {
00064                 if ( $index > 0 ) {
00065                     $this->output( ' | ' );
00066                 }
00067                 $this->output( $lang->time( $this->ts, false, $pref ) );
00068             }
00069             $this->output( "\n$code both: " );
00070             foreach ( $prefs as $index => $pref ) {
00071                 if ( $index > 0 ) {
00072                     $this->output( ' | ' );
00073                 }
00074                 $this->output( $lang->timeanddate( $this->ts, false, $pref ) );
00075             }
00076             $this->output( "\n\n" );
00077         }
00078     }
00079 }
00080 
00081 $maintClass = "DateFormats";
00082 require_once RUN_MAINTENANCE_IF_MAIN;