Merge "Add a test for named vs. positional parameter whitespace stripping"
[lhc/web/wiklou.git] / includes / Timestamp.php
index c9ba8d9..56ce46c 100644 (file)
@@ -69,6 +69,8 @@ class MWTimestamp {
         * Make a new timestamp and set it to the specified time,
         * or the current time if unspecified.
         *
+        * @since 1.20
+        *
         * @param $timestamp bool|string Timestamp to set, or false for current time
         */
        public function __construct( $timestamp = false ) {
@@ -81,6 +83,8 @@ class MWTimestamp {
         * Parse the given timestamp into either a DateTime object or a Unix timestamp,
         * and then store it.
         *
+        * @since 1.20
+        *
         * @param $ts string|bool Timestamp to store, or false for now
         * @throws TimestampException
         */
@@ -136,14 +140,10 @@ class MWTimestamp {
                        $strtime = call_user_func_array( "sprintf", $da );
                }
 
-               if( function_exists( "date_create" ) ) {
-                       try {
-                               $final = new DateTime( $strtime, new DateTimeZone( 'GMT' ) );
-                       } catch(Exception $e) {
-                               throw new TimestampException( __METHOD__ . ' Invalid timestamp format.' );
-                       }
-               } else {
-                       $final = strtotime( $strtime );
+               try {
+                       $final = new DateTime( $strtime, new DateTimeZone( 'GMT' ) );
+               } catch(Exception $e) {
+                       throw new TimestampException( __METHOD__ . ' Invalid timestamp format.' );
                }
 
                if( $final === false ) {
@@ -158,6 +158,8 @@ class MWTimestamp {
         * Convert the internal timestamp to the specified format and then
         * return it.
         *
+        * @since 1.20
+        *
         * @param $style int Constant Output format for timestamp
         * @throws TimestampException
         * @return string The formatted timestamp
@@ -192,7 +194,9 @@ class MWTimestamp {
         * generate a readable timestamp by returning "<N> <units> ago", where the
         * largest possible unit is used.
         *
-        * @return string Formatted timestamp
+        * @since 1.20
+        *
+        * @return Message Formatted timestamp
         */
        public function getHumanTimestamp() {
                $then = $this->getTimestamp( TS_UNIX );
@@ -219,6 +223,8 @@ class MWTimestamp {
        }
 
        /**
+        * @since 1.20
+        *
         * @return string
         */
        public function __toString() {
@@ -226,4 +232,7 @@ class MWTimestamp {
        }
 }
 
+/**
+ * @since 1.20
+ */
 class TimestampException extends MWException {}