MediaWiki REL1_39
date-formats.php
Go to the documentation of this file.
1<?php
25
26require_once __DIR__ . '/../Maintenance.php';
27
33class DateFormats extends Maintenance {
34
35 private $ts = '20010115123456';
36
37 public function __construct() {
38 parent::__construct();
39 $this->addDescription( 'Test various language time and date functions' );
40 }
41
42 public function execute() {
43 global $IP;
44 foreach ( glob( "$IP/languages/messages/Messages*.php" ) as $filename ) {
45 $base = basename( $filename );
46 $m = [];
47 if ( !preg_match( '/Messages(.*)\.php$/', $base, $m ) ) {
48 continue;
49 }
50 $code = str_replace( '_', '-', strtolower( $m[1] ) );
51 $this->output( "$code " );
52 $lang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( $code );
53 $prefs = $lang->getDatePreferences();
54 if ( !$prefs ) {
55 $prefs = [ 'default' ];
56 }
57 $this->output( "date: " );
58 foreach ( $prefs as $index => $pref ) {
59 if ( $index > 0 ) {
60 $this->output( ' | ' );
61 }
62 $this->output( $lang->date( $this->ts, false, $pref ) );
63 }
64 $this->output( "\n$code time: " );
65 foreach ( $prefs as $index => $pref ) {
66 if ( $index > 0 ) {
67 $this->output( ' | ' );
68 }
69 $this->output( $lang->time( $this->ts, false, $pref ) );
70 }
71 $this->output( "\n$code both: " );
72 foreach ( $prefs as $index => $pref ) {
73 if ( $index > 0 ) {
74 $this->output( ' | ' );
75 }
76 $this->output( $lang->timeanddate( $this->ts, false, $pref ) );
77 }
78 $this->output( "\n\n" );
79 }
80 }
81}
82
83$maintClass = DateFormats::class;
84require_once RUN_MAINTENANCE_IF_MAIN;
if(!defined( 'MEDIAWIKI')) if(ini_get('mbstring.func_overload')) if(!defined( 'MW_ENTRY_POINT')) global $IP
Environment checks.
Definition Setup.php:91
Maintenance script that tests various language time and date functions.
__construct()
Default constructor.
execute()
Do the actual work.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
output( $out, $channel=null)
Throw some output to the user.
addDescription( $text)
Set the description text.
Service locator for MediaWiki core services.
$maintClass
if(!isset( $args[0])) $lang