MediaWiki master
|
Date formatter. More...
Public Member Functions | |
__construct (Language $lang) | |
reformat ( $preference, $text, $options=[]) | |
Static Public Member Functions | |
static | getInstance (?Language $lang=null) |
Get a DateFormatter object. | |
Date formatter.
Recognises dates and formats them according to a specified preference.
This class was originally introduced to detect and transform dates in free text. It is now only used by the {{#dateformat}} parser function. This is a very rudimentary date formatter; Language::sprintfDate() has many more features and is the correct choice for most new code. The main advantage of this date formatter is that it is able to format incomplete dates with an unspecified year.
Definition at line 41 of file DateFormatter.php.
MediaWiki\Parser\DateFormatter::__construct | ( | Language | $lang | ) |
Language | $lang | In which language to format the date |
Definition at line 129 of file DateFormatter.php.
References MediaWiki\Language\Language\getMonthAbbreviation(), and MediaWiki\Language\Language\getMonthName().
|
static |
Get a DateFormatter object.
Language | null | $lang | In which language to format the date Defaults to the site content language |
Definition at line 168 of file DateFormatter.php.
References MediaWiki\MediaWikiServices\getInstance().
MediaWiki\Parser\DateFormatter::reformat | ( | $preference, | |
$text, | |||
$options = [] ) |
string | $preference | User preference, must be one of "default", "dmy", "mdy", "ymd" or "ISO 8601". |
string | $text | Text to reformat |
array | $options | Ignored. Since 1.33, 'match-whole' is implied, and 'linked' has been removed. |
Definition at line 182 of file DateFormatter.php.
References $source.