Skip to content

Commit

Permalink
fix carbon 3
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMuller committed Aug 23, 2024
1 parent 85c5247 commit 3337e05
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Stopwatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function totalRunDuration(): CarbonInterval
throw new Exception('Stopwatch has not been finished yet.');
}

return $this->endTime->diffAsCarbonInterval($this->startTime, absolute: true);
return $this->startTime->diffAsCarbonInterval($this->endTime, absolute: true);
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/StopwatchCheckpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public function __construct(
) {
$this->time = CarbonImmutable::now();

$this->timeSinceStopwatchStart = $this->time->diffAsCarbonInterval($stopwatchStartTime, absolute: true)->cascade();
$this->timeSinceStopwatchStart = $stopwatchStartTime->diffAsCarbonInterval($this->time, absolute: true)->cascade();

$this->timeSinceLastCheckpoint = $previousCheckpoint !== null
? $this->time->diffAsCarbonInterval($previousCheckpoint->time, absolute: true)->cascade()
? $previousCheckpoint->time->diffAsCarbonInterval($this->time, absolute: true)->cascade()
: $this->timeSinceStopwatchStart;

$this->timeSinceLastCheckpointFormatted = round($this->timeSinceLastCheckpoint->totalMilliseconds, 1) . 'ms';
Expand Down

0 comments on commit 3337e05

Please sign in to comment.