MediaWiki  1.23.2
DateFormatter Class Reference

Date formatter, recognises dates in plain text and formats them according to user preferences. More...

Public Member Functions

 __construct (Language $lang)
 
 formatDate ( $bits, $link=true)
 
 getMonthRegex ()
 
 makeIsoMonth ( $monthName)
 Makes an ISO month, e.g. More...
 
 makeIsoYear ( $year)
 
 makeNormalYear ( $iso)
 
 reformat ( $preference, $text, $options=array( 'linked'))
 
 replace ( $matches)
 

Static Public Member Functions

static & getInstance ( $lang=null)
 Get a DateFormatter object. More...
 

Public Attributes

 $monthNames = ''
 
 $mSource
 
 $mTarget
 
 $pDays
 
 $pMonths
 
 $preferences
 
 $pYears
 
 $regexes
 
 $rules
 
 $rxDM
 
 $rxDMY
 
 $rxMD
 
 $rxMDY
 
 $rxYDM
 
 $rxYMD
 
 $xMonths
 
const ALL = -1
 
const DM = 7
 
const DMY = 2
 
const ISO1 = 4
 
const ISO2 = 5
 
const LAST = 8
 
const LASTPREF = 4
 
const MD = 8
 
const MDY = 1
 
const NONE = 0
 
const YDM = 6
 
const YMD = 3
 

Protected Attributes

 $lang
 

Detailed Description

Date formatter, recognises dates in plain text and formats them according to user preferences.

Todo:
preferences, OutputPage

Definition at line 29 of file DateFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

DateFormatter::__construct ( Language  $lang)
Parameters
$langLanguage In which language to format the date

Definition at line 54 of file DateFormatter.php.

References $lang, ALL, array(), DM, DMY, getMonthRegex(), ISO1, ISO2, MD, MDY, NONE, YDM, and YMD.

Member Function Documentation

◆ formatDate()

DateFormatter::formatDate (   $bits,
  $link = true 
)
Parameters
$bitsarray
$linkbool
Returns
string

Definition at line 222 of file DateFormatter.php.

References $link, $matches, $mTarget, array(), makeIsoMonth(), makeIsoYear(), makeNormalYear(), of, and Html\rawElement().

Referenced by replace().

◆ getInstance()

static& DateFormatter::getInstance (   $lang = null)
static

Get a DateFormatter object.

Parameters
$langLanguage|string|null In which language to format the date Defaults to the site content language
Returns
DateFormatter object

Definition at line 127 of file DateFormatter.php.

References $lang, $wgContLang, $wgMemc, global, wfGetLangObj(), and wfMemcKey().

Referenced by CoreParserFunctions\formatDate().

◆ getMonthRegex()

DateFormatter::getMonthRegex ( )
Todo:
document
Returns
string

Definition at line 318 of file DateFormatter.php.

References array().

Referenced by __construct().

◆ makeIsoMonth()

DateFormatter::makeIsoMonth (   $monthName)

Makes an ISO month, e.g.

02, from a month name

Parameters
string$monthNamemonth name
Returns
string ISO month name

Definition at line 332 of file DateFormatter.php.

References $n.

Referenced by formatDate().

◆ makeIsoYear()

DateFormatter::makeIsoYear (   $year)
Todo:
document
Parameters
string$yearYear name
Returns
string ISO year name

Definition at line 342 of file DateFormatter.php.

Referenced by formatDate().

◆ makeNormalYear()

DateFormatter::makeNormalYear (   $iso)
Todo:
document
Returns
int|string

Definition at line 359 of file DateFormatter.php.

Referenced by formatDate().

◆ reformat()

DateFormatter::reformat (   $preference,
  $text,
  $options = array( 'linked' ) 
)
Parameters
string$preferenceUser preference
string$textText to reformat
array$optionscan contain 'linked' and/or 'match-whole'
Returns
string

Definition at line 149 of file DateFormatter.php.

References $options, ALL, array(), LAST, and NONE.

◆ replace()

DateFormatter::replace (   $matches)
Parameters
$matches
Returns
string

Definition at line 199 of file DateFormatter.php.

References $matches, $mSource, array(), and formatDate().

Member Data Documentation

◆ $lang

DateFormatter::$lang
protected

Definition at line 36 of file DateFormatter.php.

Referenced by __construct(), and getInstance().

◆ $monthNames

DateFormatter::$monthNames = ''

Definition at line 31 of file DateFormatter.php.

◆ $mSource

DateFormatter::$mSource

Definition at line 30 of file DateFormatter.php.

Referenced by replace().

◆ $mTarget

DateFormatter::$mTarget

Definition at line 30 of file DateFormatter.php.

Referenced by formatDate().

◆ $pDays

DateFormatter::$pDays

Definition at line 33 of file DateFormatter.php.

◆ $pMonths

DateFormatter::$pMonths

Definition at line 33 of file DateFormatter.php.

◆ $preferences

DateFormatter::$preferences

Definition at line 34 of file DateFormatter.php.

◆ $pYears

DateFormatter::$pYears

Definition at line 33 of file DateFormatter.php.

◆ $regexes

DateFormatter::$regexes

Definition at line 33 of file DateFormatter.php.

◆ $rules

DateFormatter::$rules

Definition at line 34 of file DateFormatter.php.

◆ $rxDM

DateFormatter::$rxDM

Definition at line 31 of file DateFormatter.php.

◆ $rxDMY

DateFormatter::$rxDMY

Definition at line 31 of file DateFormatter.php.

◆ $rxMD

DateFormatter::$rxMD

Definition at line 31 of file DateFormatter.php.

◆ $rxMDY

DateFormatter::$rxMDY

Definition at line 31 of file DateFormatter.php.

◆ $rxYDM

DateFormatter::$rxYDM

Definition at line 31 of file DateFormatter.php.

◆ $rxYMD

DateFormatter::$rxYMD

Definition at line 31 of file DateFormatter.php.

◆ $xMonths

DateFormatter::$xMonths

Definition at line 34 of file DateFormatter.php.

◆ ALL

const DateFormatter::ALL = -1

Definition at line 38 of file DateFormatter.php.

Referenced by __construct(), and reformat().

◆ DM

const DateFormatter::DM = 7

Definition at line 47 of file DateFormatter.php.

Referenced by __construct().

◆ DMY

const DateFormatter::DMY = 2

Definition at line 41 of file DateFormatter.php.

Referenced by __construct().

◆ ISO1

const DateFormatter::ISO1 = 4

Definition at line 43 of file DateFormatter.php.

Referenced by __construct().

◆ ISO2

const DateFormatter::ISO2 = 5

Definition at line 45 of file DateFormatter.php.

Referenced by __construct().

◆ LAST

const DateFormatter::LAST = 8

Definition at line 49 of file DateFormatter.php.

Referenced by reformat().

◆ LASTPREF

const DateFormatter::LASTPREF = 4

Definition at line 44 of file DateFormatter.php.

◆ MD

const DateFormatter::MD = 8

Definition at line 48 of file DateFormatter.php.

Referenced by __construct().

◆ MDY

const DateFormatter::MDY = 1

Definition at line 40 of file DateFormatter.php.

Referenced by __construct().

◆ NONE

const DateFormatter::NONE = 0

Definition at line 39 of file DateFormatter.php.

Referenced by __construct(), and reformat().

◆ YDM

const DateFormatter::YDM = 6

Definition at line 46 of file DateFormatter.php.

Referenced by __construct().

◆ YMD

const DateFormatter::YMD = 3

Definition at line 42 of file DateFormatter.php.

Referenced by __construct().


The documentation for this class was generated from the following file: