X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FTimestamp.php;h=56ce46c1ac3a832b3a6f87801a65fb11ac988dea;hb=700e0ee0669fc267c597a12d5a1f30c0454b1d95;hp=c9ba8d918508b505c7fc329189fb3d6261b231c5;hpb=cc71ec73200c02217ca2e2d64c2ee23f2eb1e70b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Timestamp.php b/includes/Timestamp.php index c9ba8d9185..56ce46c1ac 100644 --- a/includes/Timestamp.php +++ b/includes/Timestamp.php @@ -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 " 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 {}