Skip to content

Commit

Permalink
Merge pull request #148 from prooph/fix_date_interval_issue
Browse files Browse the repository at this point in the history
Calculate seconds and initialize interval with it
  • Loading branch information
prolic authored Apr 30, 2018
2 parents bce4c40 + dd0c300 commit 9bd496e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/Projection/PdoEventStoreProjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -962,10 +962,12 @@ private function shouldUpdateLock(DateTimeImmutable $now): bool
return true;
}

//Create a 0 interval
$updateLockThreshold = new \DateInterval('PT0S');
$intervalSeconds = floor($this->updateLockThreshold / 1000);

//Create an interval based on seconds
$updateLockThreshold = new \DateInterval("PT{$intervalSeconds}S");
//and manually add split seconds
$updateLockThreshold->f = $this->updateLockThreshold / 1000;
$updateLockThreshold->f = ($this->updateLockThreshold % 1000) / 1000;

$threshold = $this->lastLockUpdate->add($updateLockThreshold);

Expand Down
8 changes: 5 additions & 3 deletions src/Projection/PdoEventStoreReadModelProjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -909,10 +909,12 @@ private function shouldUpdateLock(DateTimeImmutable $now): bool
return true;
}

//Create a 0 interval
$updateLockThreshold = new \DateInterval('PT0S');
$intervalSeconds = floor($this->updateLockThreshold / 1000);

//Create an interval based on seconds
$updateLockThreshold = new \DateInterval("PT{$intervalSeconds}S");
//and manually add split seconds
$updateLockThreshold->f = $this->updateLockThreshold / 1000;
$updateLockThreshold->f = ($this->updateLockThreshold % 1000) / 1000;

$threshold = $this->lastLockUpdate->add($updateLockThreshold);

Expand Down

0 comments on commit 9bd496e

Please sign in to comment.