Skip to content

Commit

Permalink
fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
antograssiot committed Jul 14, 2016
1 parent d5fe21b commit a40b330
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ChronosInterval.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public static function instance(DateInterval $di)
$instance = new static($di->y, $di->m, 0, $di->d, $di->h, $di->i, $di->s);
$instance->invert = $di->invert;
$instance->days = $di->days;

return $instance;
}

Expand Down Expand Up @@ -344,6 +345,7 @@ public function __set($name, $val)
public function weeksAndDays($weeks, $days)
{
$this->dayz = ($weeks * ChronosInterface::DAYS_PER_WEEK) + $days;

return $this;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ public function __construct($time = 'now', $tz = null)
$tz = new DateTimeZone('UTC');
if (static::$testNow === null) {
$time = $this->stripTime($time);

return parent::__construct($time, $tz);
}

$relative = static::hasRelativeKeywords($time);
if (!empty($time) && $time !== 'now' && !$relative) {
$time = $this->stripTime($time);

return parent::__construct($time, $tz);
}

Expand Down
1 change: 1 addition & 0 deletions src/DifferenceFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public function diffForHumans(ChronosInterface $date, ChronosInterface $other =
if ($this->translate->exists($tryKeyExists)) {
$time = $this->translate->plural($tryKeyExists, $count, ['count' => $count]);
}

return $this->translate->singular($transId, ['time' => $time]);
}
}
2 changes: 2 additions & 0 deletions src/MutableDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ public function __construct($time = 'now', $tz = null)
$tz = new DateTimeZone('UTC');
if (static::$testNow === null) {
$time = $this->stripTime($time);

return parent::__construct($time, $tz);
}

$relative = static::hasRelativeKeywords($time);
if (!empty($time) && $time !== 'now' && !$relative) {
$time = $this->stripTime($time);

return parent::__construct($time, $tz);
}

Expand Down
1 change: 1 addition & 0 deletions src/Traits/ComparisonTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ public function isBirthday(ChronosInterface $dt = null)
if ($dt === null) {
$dt = static::now($this->tz);
}

return $this->format('md') === $dt->format('md');
}

Expand Down
6 changes: 6 additions & 0 deletions src/Traits/DifferenceTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ trait DifferenceTrait
public function diffInYears(ChronosInterface $dt = null, $abs = true)
{
$dt = $dt === null ? static::now($this->tz) : $dt;

return (int)$this->diff($dt, $abs)->format('%r%y');
}

Expand All @@ -60,6 +61,7 @@ public function diffInYears(ChronosInterface $dt = null, $abs = true)
public function diffInMonths(ChronosInterface $dt = null, $abs = true)
{
$dt = $dt === null ? static::now($this->tz) : $dt;

return $this->diffInYears($dt, $abs) * ChronosInterface::MONTHS_PER_YEAR + (int)$this->diff($dt, $abs)->format('%r%m');
}

Expand All @@ -85,6 +87,7 @@ public function diffInWeeks(ChronosInterface $dt = null, $abs = true)
public function diffInDays(ChronosInterface $dt = null, $abs = true)
{
$dt = $dt === null ? static::now($this->tz) : $dt;

return (int)$this->diff($dt, $abs)->format('%r%a');
}

Expand Down Expand Up @@ -246,6 +249,7 @@ public function secondsUntilEndOfDay()
public static function fromNow($datetime)
{
$timeNow = new static();

return $timeNow->diff($datetime);
}

Expand Down Expand Up @@ -289,8 +293,10 @@ public static function diffFormatter($formatter = null)
if (static::$diffFormatter === null) {
static::$diffFormatter = new DifferenceFormatter();
}

return static::$diffFormatter;
}

return static::$diffFormatter = $formatter;
}
}
3 changes: 3 additions & 0 deletions src/Traits/FactoryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static function instance(DateTimeInterface $dt)
if ($dt instanceof static) {
return clone $dt;
}

return new static($dt->format('Y-m-d H:i:s.u'), $dt->getTimeZone());
}

Expand Down Expand Up @@ -119,6 +120,7 @@ public static function maxValue()
public static function minValue()
{
$max = PHP_INT_SIZE === 4 ? PHP_INT_MAX : PHP_INT_MAX / 10;

return static::createFromTimestamp(~$max);
}

Expand Down Expand Up @@ -158,6 +160,7 @@ public static function create($year = null, $month = null, $day = null, $hour =
}

$instance = static::createFromFormat('Y-n-j G:i:s', sprintf('%s-%s-%s %s:%02s:%02s', 0, $month, $day, $hour, $minute, $second), $tz);

return $instance->addYears($year);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Traits/FrozenTimeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ protected function stripTime($time)
if ($this->hasRelativeKeywords($time)) {
return date('Y-m-d 00:00:00', strtotime($time));
}

return preg_replace('/\d{1,2}:\d{1,2}:\d{1,2}/', '00:00:00', $time);
}

Expand Down Expand Up @@ -159,6 +160,7 @@ public function modify($relative)
if ($new->format('H:i:s') !== '00:00:00') {
return $new->setTime(0, 0, 0);
}

return $new;
}
}
Loading

0 comments on commit a40b330

Please sign in to comment.