* @ingroup Parser
*/
class DateFormatter {
- public $mSource, $mTarget;
- public $monthNames = '', $rxDM, $rxMD, $rxDMY, $rxYDM, $rxMDY, $rxYMD;
+ private $mSource, $mTarget;
+ private $monthNames = '';
- public $regexes, $pDays, $pMonths, $pYears;
- public $rules, $xMonths, $preferences;
+ private $regexes;
+ private $rules, $xMonths, $preferences;
- protected $lang, $mLinked;
+ private $lang, $mLinked;
+
+ /** @var string[] */
+ private $keys;
+
+ /** @var string[] */
+ private $targets;
const ALL = -1;
const NONE = 0;
}
/**
+ * Regexp replacement callback
+ *
* @param array $matches
* @return string
*/
- public function replace( $matches ) {
+ private function replace( $matches ) {
# Extract information from $matches
$linked = true;
if ( isset( $this->mLinked ) ) {
* Return a regex that can be used to find month names in string
* @return string regex to find the months with
*/
- public function getMonthRegex() {
+ private function getMonthRegex() {
$names = [];
for ( $i = 1; $i <= 12; $i++ ) {
$names[] = $this->lang->getMonthName( $i );
* @param string $monthName Month name
* @return string ISO month name
*/
- public function makeIsoMonth( $monthName ) {
+ private function makeIsoMonth( $monthName ) {
$n = $this->xMonths[$this->lang->lc( $monthName )];
return sprintf( '%02d', $n );
}
* @param string $year Year name
* @return string ISO year name
*/
- public function makeIsoYear( $year ) {
+ private 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;
* @return int|string int representing year number in case of AD dates, or string containing
* year number and 'BC' at the end otherwise.
*/
- public function makeNormalYear( $iso ) {
+ private function makeNormalYear( $iso ) {
if ( $iso[0] == '-' ) {
$text = ( intval( substr( $iso, 1 ) ) + 1 ) . ' BC';
} else {