Rename RESTBase1/Parsoid3 `bodyOnly` parameter to `body_only`
[lhc/web/wiklou.git] / includes / MWTimestamp.php
index d28f88e..102be80 100644 (file)
@@ -106,7 +106,7 @@ class MWTimestamp {
                        $ts,
                        $da
                ) ) {
-                       #TS_ISO_8601_BASIC
+                       # TS_ISO_8601_BASIC
                } elseif ( preg_match(
                        '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.*\d*[\+\- ](\d\d)$/',
                        $ts,
@@ -367,6 +367,26 @@ class MWTimestamp {
                return $this->timestamp->getTimezone();
        }
 
+       /**
+        * Get the localized timezone message, if available.
+        *
+        * Premade translations are not shipped as format() may return whatever the
+        * system uses, localized or not, so translation must be done through wiki.
+        *
+        * @since 1.25
+        * @return Message The localized timezone message
+        */
+       public function getTimezoneMessage() {
+               $tzMsg = $this->format( 'T' );  // might vary on DST changeover!
+               $key = 'timezone-' . strtolower( trim( $tzMsg ) );
+               $msg = wfMessage( $key );
+               if ( $msg->exists() ) {
+                       return $msg;
+               } else {
+                       return new RawMessage( $tzMsg );
+               }
+       }
+
        /**
         * Format the timestamp in a given format.
         *