wiki.techinc.nl/maintenance/language/date-formats.php
Umherirrender c8ec25a961 maintenance: Add missing documentation to class properties
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: I7dec01892a987a87b1b79374a1c28f97d055e8fa
2024-09-13 19:29:24 +02:00

87 lines
2.6 KiB
PHP

<?php
/**
* Test various language time and date functions
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
* @ingroup MaintenanceLanguage
*/
// @codeCoverageIgnoreStart
require_once __DIR__ . '/../Maintenance.php';
// @codeCoverageIgnoreEnd
/**
* Maintenance script that tests various language time and date functions.
*
* @ingroup MaintenanceLanguage
*/
class DateFormats extends Maintenance {
/** @var string */
private $ts = '20010115123456';
public function __construct() {
parent::__construct();
$this->addDescription( 'Test various language time and date functions' );
}
public function execute() {
global $IP;
foreach ( glob( "$IP/languages/messages/Messages*.php" ) as $filename ) {
$base = basename( $filename );
$m = [];
if ( !preg_match( '/Messages(.*)\.php$/', $base, $m ) ) {
continue;
}
$code = str_replace( '_', '-', strtolower( $m[1] ) );
$this->output( "$code " );
$lang = $this->getServiceContainer()->getLanguageFactory()->getLanguage( $code );
$prefs = $lang->getDatePreferences();
if ( !$prefs ) {
$prefs = [ 'default' ];
}
$this->output( "date: " );
foreach ( $prefs as $index => $pref ) {
if ( $index > 0 ) {
$this->output( ' | ' );
}
$this->output( $lang->date( $this->ts, false, $pref ) );
}
$this->output( "\n$code time: " );
foreach ( $prefs as $index => $pref ) {
if ( $index > 0 ) {
$this->output( ' | ' );
}
$this->output( $lang->time( $this->ts, false, $pref ) );
}
$this->output( "\n$code both: " );
foreach ( $prefs as $index => $pref ) {
if ( $index > 0 ) {
$this->output( ' | ' );
}
$this->output( $lang->timeanddate( $this->ts, false, $pref ) );
}
$this->output( "\n\n" );
}
}
}
// @codeCoverageIgnoreStart
$maintClass = DateFormats::class;
require_once RUN_MAINTENANCE_IF_MAIN;
// @codeCoverageIgnoreEnd