For cases where you already have a DateTime object on hand and want to
use MWTimestamp's formatting code. Since MWTimestamp stores DateTime
objects internally, just set it to the $timestamp member variable.
Change-Id: Ie60392e32743d4d082d2c9347ef68418d5eb86ad
*
* @since 1.20
*
- * @param bool|string|int|float $timestamp Timestamp to set, or false for current time
+ * @param bool|string|int|float|DateTime $timestamp Timestamp to set, or false for current time
*/
public function __construct( $timestamp = false ) {
- $this->setTimestamp( $timestamp );
+ if ( $timestamp instanceof DateTime ) {
+ $this->timestamp = $timestamp;
+ } else {
+ $this->setTimestamp( $timestamp );
+ }
}
/**