Skip to content

Commit

Permalink
Allow to pass strings and DateTime to diffIn* methods (prototypes) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls authored Mar 19, 2018
1 parent 8ba7acd commit cbcf13d
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions src/Carbon/Carbon.php
Original file line number Diff line number Diff line change
Expand Up @@ -3181,8 +3181,8 @@ public function subRealSecond($value = 1)
/**
* Get the difference in years
*
* @param \Carbon\Carbon|\DateTimeInterface|null $date
* @param bool $absolute Get the absolute of the difference
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
Expand All @@ -3194,8 +3194,8 @@ public function diffInYears($date = null, $absolute = true)
/**
* Get the difference in months
*
* @param \Carbon\Carbon|\DateTimeInterface|null $date
* @param bool $absolute Get the absolute of the difference
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
Expand All @@ -3209,8 +3209,8 @@ public function diffInMonths($date = null, $absolute = true)
/**
* Get the difference in weeks
*
* @param \Carbon\Carbon|\DateTimeInterface|null $date
* @param bool $absolute Get the absolute of the difference
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
Expand All @@ -3222,8 +3222,8 @@ public function diffInWeeks($date = null, $absolute = true)
/**
* Get the difference in days
*
* @param \Carbon\Carbon|\DateTimeInterface|null $date
* @param bool $absolute Get the absolute of the difference
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
Expand All @@ -3235,9 +3235,9 @@ public function diffInDays($date = null, $absolute = true)
/**
* Get the difference in days using a filter closure
*
* @param Closure $callback
* @param \Carbon\Carbon|null $date
* @param bool $absolute Get the absolute of the difference
* @param Closure $callback
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
Expand All @@ -3249,9 +3249,9 @@ public function diffInDaysFiltered(Closure $callback, $date = null, $absolute =
/**
* Get the difference in hours using a filter closure
*
* @param Closure $callback
* @param \Carbon\Carbon|null $date
* @param bool $absolute Get the absolute of the difference
* @param Closure $callback
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
Expand All @@ -3263,10 +3263,10 @@ public function diffInHoursFiltered(Closure $callback, $date = null, $absolute =
/**
* Get the difference by the given interval using a filter closure
*
* @param CarbonInterval $ci An interval to traverse by
* @param Closure $callback
* @param Carbon|null $date
* @param bool $absolute Get the absolute of the difference
* @param CarbonInterval $ci An interval to traverse by
* @param Closure $callback
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
Expand Down Expand Up @@ -3295,8 +3295,8 @@ public function diffFiltered(CarbonInterval $ci, Closure $callback, $date = null
/**
* Get the difference in weekdays
*
* @param \Carbon\Carbon|null $date
* @param bool $absolute Get the absolute of the difference
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
Expand All @@ -3310,8 +3310,8 @@ public function diffInWeekdays($date = null, $absolute = true)
/**
* Get the difference in weekend days using a filter
*
* @param \Carbon\Carbon|null $date
* @param bool $absolute Get the absolute of the difference
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
Expand All @@ -3325,8 +3325,8 @@ public function diffInWeekendDays($date = null, $absolute = true)
/**
* Get the difference in hours.
*
* @param \Carbon\Carbon|null $date
* @param bool $absolute Get the absolute of the difference
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
Expand All @@ -3338,21 +3338,21 @@ public function diffInHours($date = null, $absolute = true)
/**
* Get the difference in hours using timestamps.
*
* @param \Carbon\Carbon|null $date
* @param bool $absolute Get the absolute of the difference
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
public function diffInRealHours(self $date = null, $absolute = true)
public function diffInRealHours($date = null, $absolute = true)
{
return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR);
}

/**
* Get the difference in minutes.
*
* @param \Carbon\Carbon|null $date
* @param bool $absolute Get the absolute of the difference
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
Expand All @@ -3364,21 +3364,21 @@ public function diffInMinutes($date = null, $absolute = true)
/**
* Get the difference in minutes using timestamps.
*
* @param \Carbon\Carbon|null $date
* @param bool $absolute Get the absolute of the difference
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
public function diffInRealMinutes(self $date = null, $absolute = true)
public function diffInRealMinutes($date = null, $absolute = true)
{
return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE);
}

/**
* Get the difference in seconds.
*
* @param \Carbon\Carbon|null $date
* @param bool $absolute Get the absolute of the difference
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
Expand All @@ -3396,12 +3396,12 @@ public function diffInSeconds($date = null, $absolute = true)
/**
* Get the difference in seconds using timestamps.
*
* @param \Carbon\Carbon|null $date
* @param bool $absolute Get the absolute of the difference
* @param \Carbon\Carbon|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
public function diffInRealSeconds(self $date = null, $absolute = true)
public function diffInRealSeconds($date = null, $absolute = true)
{
$date = $this->resolveCarbon($date);
$value = $date->getTimestamp() - $this->getTimestamp();
Expand Down

0 comments on commit cbcf13d

Please sign in to comment.