Skip to content

Commit

Permalink
Merge pull request #2346 from briannesbitt/fix/drop-fixes-for-old-php…
Browse files Browse the repository at this point in the history
…-versions

Drop fixes for old PHP versions
  • Loading branch information
kylekatarnls authored Jun 1, 2021
2 parents e63dde5 + 908c984 commit 0833b01
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 49 deletions.
27 changes: 0 additions & 27 deletions src/Carbon/CarbonInterval.php
Original file line number Diff line number Diff line change
Expand Up @@ -919,10 +919,6 @@ public static function diff($start, $end = null, bool $absolute = false): self
$start = $start instanceof CarbonInterface ? $start : Carbon::make($start);
$end = $end instanceof CarbonInterface ? $end : Carbon::make($end);
$interval = static::instance($start->diffAsDateInterval($end, $absolute));
$interval->fixDiffInterval();

// The line below fixes https://bugs.php.net/bug.php?id=77007
$interval->abs($absolute);

$interval->startDate = $start;
$interval->endDate = $end;
Expand Down Expand Up @@ -2807,29 +2803,6 @@ private function fixNegativeMicroseconds(): void
$this->invert();
}

/**
* Work-around for https://bugs.php.net/bug.php?id=77145
*
* @SuppressWarnings(UnusedPrivateMethod)
*
* @codeCoverageIgnore
*/
private function fixDiffInterval(): void
{
if ($this->f > 0 && $this->y === -1 && $this->m === 11 && $this->d >= 27 && $this->h === 23 && $this->i === 59 && $this->s === 59) {
$this->y = 0;
$this->m = 0;
$this->d = 0;
$this->h = 0;
$this->i = 0;
$this->s = 0;
$this->f = (1000000 - round($this->f * 1000000)) / 1000000;
$this->invert();
} elseif ($this->f < 0) {
$this->fixNegativeMicroseconds();
}
}

/**
* @template T of DateInterval
*
Expand Down
10 changes: 0 additions & 10 deletions src/Carbon/Traits/Creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ public function __construct($time = null, $tz = null)
static::mockConstructorParameters($time, $tz);
}

// Work-around for PHP bug https://bugs.php.net/bug.php?id=67127
if (strpos((string) .1, '.') === false) {
$locale = setlocale(LC_NUMERIC, '0');
setlocale(LC_NUMERIC, 'C');
}

try {
parent::__construct($time ?: 'now', static::safeCreateDateTimeZone($tz) ?: null);
} catch (Exception $exception) {
Expand All @@ -91,10 +85,6 @@ public function __construct($time = null, $tz = null)

$this->constructedObjectId = spl_object_hash($this);

if (isset($locale)) {
setlocale(LC_NUMERIC, $locale);
}

static::setLastErrors(parent::getLastErrors());
}

Expand Down
12 changes: 0 additions & 12 deletions src/Carbon/Traits/Units.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,18 +297,6 @@ public function addUnit($unit, $value = 1, $overflow = null)
$value *= static::MICROSECONDS_PER_MILLISECOND;
}

// Work-around for bug https://bugs.php.net/bug.php?id=75642
if ($unit === 'micro' || $unit === 'microsecond') {
$microseconds = $this->micro + $value;
$second = (int) floor($microseconds / static::MICROSECONDS_PER_SECOND);
$microseconds %= static::MICROSECONDS_PER_SECOND;
if ($microseconds < 0) {
$microseconds += static::MICROSECONDS_PER_SECOND;
}
$date = $date->microseconds($microseconds);
$unit = 'second';
$value = $second;
}
$date = $date->modify("$value $unit");

if (isset($timeString)) {
Expand Down

0 comments on commit 0833b01

Please sign in to comment.