| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
require_once __DIR__ . '/../Maintenance.php'; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
class DateFormats extends Maintenance { |
| 34 |
|
| 35 |
|
| 36 |
private $ts = '20010115123456'; |
| 37 |
|
| 38 |
public function __construct() { |
| 39 |
parent::__construct(); |
| 40 |
$this->addDescription( 'Test various language time and date functions' ); |
| 41 |
} |
| 42 |
|
| 43 |
public function execute() { |
| 44 |
global $IP; |
| 45 |
foreach ( glob( "$IP/languages/messages/Messages*.php" ) as $filename ) { |
| 46 |
$base = basename( $filename ); |
| 47 |
$m = []; |
| 48 |
if ( !preg_match( '/Messages(.*)\.php$/', $base, $m ) ) { |
| 49 |
continue; |
| 50 |
} |
| 51 |
$code = str_replace( '_', '-', strtolower( $m[1] ) ); |
| 52 |
$this->output( "$code " ); |
| 53 |
$lang = $this->getServiceContainer()->getLanguageFactory()->getLanguage( $code ); |
| 54 |
$prefs = $lang->getDatePreferences(); |
| 55 |
if ( !$prefs ) { |
| 56 |
$prefs = [ 'default' ]; |
| 57 |
} |
| 58 |
$this->output( "date: " ); |
| 59 |
foreach ( $prefs as $index => $pref ) { |
| 60 |
if ( $index > 0 ) { |
| 61 |
$this->output( ' | ' ); |
| 62 |
} |
| 63 |
$this->output( $lang->date( $this->ts, false, $pref ) ); |
| 64 |
} |
| 65 |
$this->output( "\n$code time: " ); |
| 66 |
foreach ( $prefs as $index => $pref ) { |
| 67 |
if ( $index > 0 ) { |
| 68 |
$this->output( ' | ' ); |
| 69 |
} |
| 70 |
$this->output( $lang->time( $this->ts, false, $pref ) ); |
| 71 |
} |
| 72 |
$this->output( "\n$code both: " ); |
| 73 |
foreach ( $prefs as $index => $pref ) { |
| 74 |
if ( $index > 0 ) { |
| 75 |
$this->output( ' | ' ); |
| 76 |
} |
| 77 |
$this->output( $lang->timeanddate( $this->ts, false, $pref ) ); |
| 78 |
} |
| 79 |
$this->output( "\n\n" ); |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
$maintClass = DateFormats::class; |
| 86 |
require_once RUN_MAINTENANCE_IF_MAIN; |
| 87 |
|