Commit 864cf967 authored by attilak's avatar attilak

Simplify date calculations

parent c385a0b2
...@@ -388,14 +388,10 @@ class Cron ...@@ -388,14 +388,10 @@ class Cron
// OFFER_CLOSED or the AUTHORISATION success=false one. // OFFER_CLOSED or the AUTHORISATION success=false one.
case Notification::OFFER_CLOSED: case Notification::OFFER_CLOSED:
// OFFER_CLOSED notifications needs to be at least 10 minutes old to be processed // OFFER_CLOSED notifications needs to be at least 10 minutes old to be processed
$offerClosedMinDate = new \DateTime(); $offerClosedMinDate = new \DateTime('-10 minutes');
$offerClosedMinDate->modify('-10 minutes');
$createdAt = \DateTime::createFromFormat('Y-m-d H:i:s', $notification['created_at']); $createdAt = \DateTime::createFromFormat('Y-m-d H:i:s', $notification['created_at']);
// To get the difference between $offerClosedMinDate and $createdAt, $offerClosedMinDate time in seconds
// is deducted from $createdAt time in seconds, divided by 60 and rounded down to integer $minutesUntilProcessing = $createdAt->diff($offerClosedMinDate)->i;
$minutesUntilProcessing = floor(
($createdAt->getTimestamp() - $offerClosedMinDate->getTimestamp()) / 60
);
if ($minutesUntilProcessing > 0) { if ($minutesUntilProcessing > 0) {
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
...@@ -422,13 +418,10 @@ class Cron ...@@ -422,13 +418,10 @@ class Cron
} }
// AUTHORISATION success=false notifications needs to be at least 10 minutes old to be processed // AUTHORISATION success=false notifications needs to be at least 10 minutes old to be processed
$authorisationSuccessFalseMinDate = new \DateTime(); $authorisationSuccessFalseMinDate = new \DateTime('-10 minutes');
$authorisationSuccessFalseMinDate->modify('-10 minutes');
$createdAt = \DateTime::createFromFormat('Y-m-d H:i:s', $notification['created_at']); $createdAt = \DateTime::createFromFormat('Y-m-d H:i:s', $notification['created_at']);
$minutesUntilProcessing = floor( $minutesUntilProcessing = $createdAt->diff($authorisationSuccessFalseMinDate)->i;
($createdAt->getTimestamp() - $authorisationSuccessFalseMinDate->getTimestamp()) / 60
);
if ($minutesUntilProcessing > 0) { if ($minutesUntilProcessing > 0) {
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment