Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 30 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| DateFormats | |
0.00% |
0 / 30 |
|
0.00% |
0 / 2 |
132 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| execute | |
0.00% |
0 / 28 |
|
0.00% |
0 / 1 |
110 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Test various language time and date functions |
| 4 | * |
| 5 | * @license GPL-2.0-or-later |
| 6 | * @file |
| 7 | * @ingroup MaintenanceLanguage |
| 8 | */ |
| 9 | |
| 10 | use MediaWiki\Maintenance\Maintenance; |
| 11 | |
| 12 | // @codeCoverageIgnoreStart |
| 13 | require_once __DIR__ . '/../Maintenance.php'; |
| 14 | // @codeCoverageIgnoreEnd |
| 15 | |
| 16 | /** |
| 17 | * Maintenance script that tests various language time and date functions. |
| 18 | * |
| 19 | * @ingroup MaintenanceLanguage |
| 20 | */ |
| 21 | class DateFormats extends Maintenance { |
| 22 | |
| 23 | /** @var string */ |
| 24 | private $ts = '20010115123456'; |
| 25 | |
| 26 | public function __construct() { |
| 27 | parent::__construct(); |
| 28 | $this->addDescription( 'Test various language time and date functions' ); |
| 29 | } |
| 30 | |
| 31 | public function execute() { |
| 32 | global $IP; |
| 33 | foreach ( glob( "$IP/languages/messages/Messages*.php" ) as $filename ) { |
| 34 | $base = basename( $filename ); |
| 35 | $m = []; |
| 36 | if ( !preg_match( '/Messages(.*)\.php$/', $base, $m ) ) { |
| 37 | continue; |
| 38 | } |
| 39 | $code = str_replace( '_', '-', strtolower( $m[1] ) ); |
| 40 | $this->output( "$code " ); |
| 41 | $lang = $this->getServiceContainer()->getLanguageFactory()->getLanguage( $code ); |
| 42 | $prefs = $lang->getDatePreferences(); |
| 43 | if ( !$prefs ) { |
| 44 | $prefs = [ 'default' ]; |
| 45 | } |
| 46 | $this->output( "date: " ); |
| 47 | foreach ( $prefs as $index => $pref ) { |
| 48 | if ( $index > 0 ) { |
| 49 | $this->output( ' | ' ); |
| 50 | } |
| 51 | $this->output( $lang->date( $this->ts, false, $pref ) ); |
| 52 | } |
| 53 | $this->output( "\n$code time: " ); |
| 54 | foreach ( $prefs as $index => $pref ) { |
| 55 | if ( $index > 0 ) { |
| 56 | $this->output( ' | ' ); |
| 57 | } |
| 58 | $this->output( $lang->time( $this->ts, false, $pref ) ); |
| 59 | } |
| 60 | $this->output( "\n$code both: " ); |
| 61 | foreach ( $prefs as $index => $pref ) { |
| 62 | if ( $index > 0 ) { |
| 63 | $this->output( ' | ' ); |
| 64 | } |
| 65 | $this->output( $lang->timeanddate( $this->ts, false, $pref ) ); |
| 66 | } |
| 67 | $this->output( "\n\n" ); |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | // @codeCoverageIgnoreStart |
| 73 | $maintClass = DateFormats::class; |
| 74 | require_once RUN_MAINTENANCE_IF_MAIN; |
| 75 | // @codeCoverageIgnoreEnd |