MediaWiki
REL1_37
date-formats.php
Go to the documentation of this file.
1
<?php
24
use
MediaWiki\MediaWikiServices
;
25
26
require_once __DIR__ .
'/../Maintenance.php'
;
27
33
class
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;
84
require_once RUN_MAINTENANCE_IF_MAIN;
$IP
$IP
Definition
WebStart.php:49
DateFormats
Maintenance script that tests various language time and date functions.
Definition
date-formats.php:33
DateFormats\$ts
$ts
Definition
date-formats.php:35
DateFormats\__construct
__construct()
Default constructor.
Definition
date-formats.php:37
DateFormats\execute
execute()
Do the actual work.
Definition
date-formats.php:42
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition
Maintenance.php:59
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition
Maintenance.php:435
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:329
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition
MediaWikiServices.php:190
$maintClass
$maintClass
Definition
date-formats.php:83
$base
$base
Definition
generateLocalAutoload.php:11
$lang
if(!isset( $args[0])) $lang
Definition
testCompression.php:37
maintenance
language
date-formats.php
Generated on Fri Apr 5 2024 23:41:21 for MediaWiki by
1.9.8