Upstream spatie/period state of the touched files before f2bcd9f5d3
This commit is contained in:
1 parent
9086ebcaab
commit
79eb344eb0
3 files changed
+1
-45
No files matched your search
@@ -66,13 +66,6 @@ trait PeriodGetters
|
||||
|
||||
public function length(): int
|
||||
{
|
||||
// Excluding the boundaries of a period that is only a few units long can push the
|
||||
// included start past the included end. Such a period contains nothing, which is what
|
||||
// iterating over it yields, so its length is 0 rather than a distance measured backwards.
|
||||
if ($this->includedStart() > $this->includedEnd()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Length of month and year are not fixed, so we can't predict the length without iterate
|
||||
// TODO: maybe we can use cal_days_in_month ?
|
||||
if ($this->precision->equals(Precision::MONTH(), Precision::YEAR())) {
|
||||
@@ -80,7 +73,7 @@ trait PeriodGetters
|
||||
}
|
||||
|
||||
if ($this->precision->equals(Precision::HOUR(), Precision::MINUTE(), Precision::SECOND())) {
|
||||
$length = $this->includedEnd()->getTimestamp() - $this->includedStart()->getTimestamp();
|
||||
$length = abs($this->includedEnd()->getTimestamp() - $this->includedStart()->getTimestamp());
|
||||
|
||||
if ($this->precision->equals(Precision::SECOND())) {
|
||||
return $length + 1;
|
||||
|
||||
Reference in new issue
Block a user