Commit b7cf6183 by David Renty

asElapsedTime style improvements

parent f7871e24
...@@ -470,16 +470,19 @@ class Formatter extends Component ...@@ -470,16 +470,19 @@ class Formatter extends Component
*/ */
public function asElapsedTime($value) public function asElapsedTime($value)
{ {
if ($value === null) {
return $this->nullDisplay;
}
if ($value instanceof \DateInterval) { if ($value instanceof \DateInterval) {
$interval = $value; $interval = $value;
} else { } else {
if ($value === null) {
return $this->nullDisplay;
}
$value = $this->normalizeDatetimeValue($value); $value = $this->normalizeDatetimeValue($value);
$dateNow = new DateTime('now', new \DateTimeZone($this->timeZone)); $timezone = new \DateTimeZone($this->timeZone);
$dateThen = new DateTime(null, new \DateTimeZone($this->timeZone));
$dateNow = new DateTime('now', $timezone);
$dateThen = new DateTime(null, $timezone);
$dateThen->setTimestamp($value); $dateThen->setTimestamp($value);
$interval = $dateNow->diff($dateThen); $interval = $dateNow->diff($dateThen);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment