Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/305945

Change subject: MWTimestamp: Allow providing a DateTime object directly
......................................................................

MWTimestamp: Allow providing a DateTime object directly

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
---
M includes/MWTimestamp.php
1 file changed, 6 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/45/305945/1

diff --git a/includes/MWTimestamp.php b/includes/MWTimestamp.php
index 4964fe6..defdc96 100644
--- a/includes/MWTimestamp.php
+++ b/includes/MWTimestamp.php
@@ -56,10 +56,14 @@
         *
         * @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 );
+               }
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/305945
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie60392e32743d4d082d2c9347ef68418d5eb86ad
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to