Merge "Special:AllMessages: Ignore case of first letter when sorting"
[lhc/web/wiklou.git] / includes / parser / DateFormatter.php
index 0bf2ffc..3db8d1e 100644 (file)
  * @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;
 
@@ -51,7 +51,7 @@ class DateFormatter {
        /**
         * @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();
@@ -146,7 +146,7 @@ class DateFormatter {
         *
         * @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 );
 
@@ -196,7 +196,7 @@ class DateFormatter {
         * @param array $matches
         * @return string
         */
-       function replace( $matches ) {
+       public function replace( $matches ) {
                # Extract information from $matches
                $linked = true;
                if ( isset( $this->mLinked ) ) {
@@ -220,7 +220,7 @@ class DateFormatter {
         * @param bool $link
         * @return string
         */
-       function formatDate( $bits, $link = true ) {
+       public function formatDate( $bits, $link = true ) {
                $format = $this->targets[$this->mTarget];
 
                if ( !$link ) {
@@ -315,10 +315,10 @@ class DateFormatter {
        }
 
        /**
-        * @todo document
-        * @return string
+        * Return a regex that can be used to find month names in string
+        * @return string regex to find the months with
         */
-       function getMonthRegex() {
+       public function getMonthRegex() {
                $names = array();
                for ( $i = 1; $i <= 12; $i++ ) {
                        $names[] = $this->lang->getMonthName( $i );
@@ -332,17 +332,17 @@ class DateFormatter {
         * @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 );
        }
 
        /**
-        * @todo document
+        * Make an ISO year from a year name, for instance: '-1199' from '1200 BC'
         * @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;
@@ -356,11 +356,12 @@ class DateFormatter {
        }
 
        /**
-        * @todo document
-        * @param string $iso
-        * @return int|string
+        * Make a year one from an ISO year, for instance: '400 BC' from '-0399'.
+        * @param string $iso ISO year
+        * @return int|string int representing year number in case of AD dates, or string containing
+        *   year number and 'BC' at the end otherwise.
         */
-       function makeNormalYear( $iso ) {
+       public function makeNormalYear( $iso ) {
                if ( $iso[0] == '-' ) {
                        $text = ( intval( substr( $iso, 1 ) ) + 1 ) . ' BC';
                } else {