* 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 ) {
* 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
*/
$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 ) {
* 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
* 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 );
}
/**
+ * @since 1.20
+ *
* @return string
*/
public function __toString() {
}
}
+/**
+ * @since 1.20
+ */
class TimestampException extends MWException {}