* @ingroup Parser
*/
class DateFormatter {
- var $mSource, $mTarget;
- var $monthNames = '', $rxDM, $rxMD, $rxDMY, $rxYDM, $rxMDY, $rxYMD;
+ public $mSource, $mTarget;
+ public $monthNames = '', $rxDM, $rxMD, $rxDMY, $rxYDM, $rxMDY, $rxYMD;
- var $regexes, $pDays, $pMonths, $pYears;
- var $rules, $xMonths, $preferences;
+ public $regexes, $pDays, $pMonths, $pYears;
+ public $rules, $xMonths, $preferences;
protected $lang;
/**
* @param Language $lang In which language to format the date
*/
- function __construct( Language $lang ) {
+ public function __construct( Language $lang ) {
$this->lang = $lang;
$this->monthNames = $this->getMonthRegex();
*
* @return string
*/
- function reformat( $preference, $text, $options = array( 'linked' ) ) {
+ public function reformat( $preference, $text, $options = array( 'linked' ) ) {
$linked = in_array( 'linked', $options );
$match_whole = in_array( 'match-whole', $options );
* @param array $matches
* @return string
*/
- function replace( $matches ) {
+ public function replace( $matches ) {
# Extract information from $matches
$linked = true;
if ( isset( $this->mLinked ) ) {
* @param bool $link
* @return string
*/
- function formatDate( $bits, $link = true ) {
+ public function formatDate( $bits, $link = true ) {
$format = $this->targets[$this->mTarget];
if ( !$link ) {
* @todo document
* @return string
*/
- function getMonthRegex() {
+ public function getMonthRegex() {
$names = array();
for ( $i = 1; $i <= 12; $i++ ) {
$names[] = $this->lang->getMonthName( $i );
* @param string $monthName Month name
* @return string ISO month name
*/
- function makeIsoMonth( $monthName ) {
+ public function makeIsoMonth( $monthName ) {
$n = $this->xMonths[$this->lang->lc( $monthName )];
return sprintf( '%02d', $n );
}
* @param string $year Year name
* @return string ISO year name
*/
- function makeIsoYear( $year ) {
+ public function makeIsoYear( $year ) {
# Assumes the year is in a nice format, as enforced by the regex
if ( substr( $year, -2 ) == 'BC' ) {
$num = intval( substr( $year, 0, -3 ) ) - 1;
* @param string $iso
* @return int|string
*/
- function makeNormalYear( $iso ) {
+ public function makeNormalYear( $iso ) {
if ( $iso[0] == '-' ) {
$text = ( intval( substr( $iso, 1 ) ) + 1 ) . ' BC';
} else {