Merge "Enable $wgVectorUseIconWatch by default."
[lhc/web/wiklou.git] / includes / Timestamp.php
index 56ce46c..7dbfabf 100644 (file)
@@ -42,7 +42,6 @@ class MWTimestamp {
                TS_RFC2822 => 'D, d M Y H:i:s',
                TS_ORACLE => 'd-m-Y H:i:s.000000', // Was 'd-M-y h.i.s A' . ' +00:00' before r51500
                TS_POSTGRES => 'Y-m-d H:i:s',
-               TS_DB2 => 'Y-m-d H:i:s',
        );
 
        /**
@@ -54,7 +53,9 @@ class MWTimestamp {
                "seconds" => 1000, // 1000 milliseconds per second
                "minutes" => 60, // 60 seconds per minute
                "hours" => 60, // 60 minutes per hour
-               "days" => 24 // 24 hours per day
+               "days" => 24, // 24 hours per day
+               "months" => 30, // approximately 30 days per month
+               "years" => 12, // 12 months per year
        );
 
        /**
@@ -71,7 +72,7 @@ class MWTimestamp {
         *
         * @since 1.20
         *
-        * @param $timestamp bool|string Timestamp to set, or false for current time
+        * @param bool|string $timestamp Timestamp to set, or false for current time
         */
        public function __construct( $timestamp = false ) {
                $this->setTimestamp( $timestamp );
@@ -85,7 +86,7 @@ class MWTimestamp {
         *
         * @since 1.20
         *
-        * @param $ts string|bool Timestamp to store, or false for now
+        * @param string|bool $ts Timestamp to store, or false for now
         * @throws TimestampException
         */
        public function setTimestamp( $ts = false ) {
@@ -116,8 +117,6 @@ class MWTimestamp {
                        # TS_POSTGRES
                } elseif ( preg_match( '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.*\d* GMT$/', $ts, $da ) ) {
                        # TS_POSTGRES
-               } elseif (preg_match( '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.\d\d\d$/', $ts, $da ) ) {
-                       # TS_DB2
                } elseif ( preg_match( '/^[ \t\r\n]*([A-Z][a-z]{2},[ \t\r\n]*)?' . # Day of week
                                                                '\d\d?[ \t\r\n]*[A-Z][a-z]{2}[ \t\r\n]*\d{2}(?:\d{2})?' .  # dd Mon yyyy
                                                                '[ \t\r\n]*\d\d[ \t\r\n]*:[ \t\r\n]*\d\d[ \t\r\n]*:[ \t\r\n]*\d\d/S', $ts ) ) { # hh:mm:ss
@@ -142,7 +141,7 @@ class MWTimestamp {
 
                try {
                        $final = new DateTime( $strtime, new DateTimeZone( 'GMT' ) );
-               } catch(Exception $e) {
+               } catch( Exception $e ) {
                        throw new TimestampException( __METHOD__ . ' Invalid timestamp format.' );
                }
 
@@ -160,7 +159,7 @@ class MWTimestamp {
         *
         * @since 1.20
         *
-        * @param $style int Constant Output format for timestamp
+        * @param int $style Constant Output format for timestamp
         * @throws TimestampException
         * @return string The formatted timestamp
         */
@@ -216,7 +215,7 @@ class MWTimestamp {
 
                if( $message ) {
                        $initial = call_user_func_array( 'wfMessage', $message );
-                       return wfMessage( 'ago', $initial );
+                       return wfMessage( 'ago', $initial->parse() );
                } else {
                        return wfMessage( 'just-now' );
                }