@@ -22,29 +22,44 @@ public function canSend(MailatorSchedule $schedule, Collection $logs): bool
2222 return false ;
2323 }
2424
25+ $ diff = (int ) $ schedule ->timestamp_target ->diffInDays (
26+ now ()->floorSeconds (),
27+ absolute: true
28+ );
29+
2530 return $ schedule ->isOnce ()
26- ? $ schedule -> timestamp_target -> diffInDays ( now ()-> floorSeconds ()) === $ schedule ->toDays ()
27- : $ schedule -> timestamp_target -> diffInDays ( now ()-> floorSeconds ()) > $ schedule ->toDays ();
31+ ? $ diff === $ schedule ->toDays ()
32+ : $ diff > $ schedule ->toDays ();
2833 }
2934
3035 if ($ schedule ->toHours () > 0 ) {
3136 if (now ()->floorSeconds ()->lt ($ schedule ->timestampTarget ()->addHours ($ schedule ->toHours ()))) {
3237 return false ;
3338 }
3439
40+ $ diff = (int ) $ schedule ->timestamp_target ->diffInHours (
41+ now ()->floorSeconds (),
42+ absolute: true
43+ );
44+
3545 //till ends we should have at least toDays days
3646 return $ schedule ->isOnce ()
37- ? $ schedule -> timestamp_target -> diffInHours ( now ()-> floorSeconds ()) === $ schedule ->toHours ()
38- : $ schedule -> timestamp_target -> diffInHours ( now ()-> floorSeconds ()) > $ schedule ->toHours ();
47+ ? $ diff === $ schedule ->toHours ()
48+ : $ diff > $ schedule ->toHours ();
3949 }
4050
4151 if (now ()->floorSeconds ()->lte ($ schedule ->timestampTarget ()->addMinutes ($ schedule ->delay_minutes ))) {
4252 return false ;
4353 }
4454
55+ $ diff = (int ) $ schedule ->timestamp_target ->diffInHours (
56+ now ()->floorSeconds (),
57+ absolute: true
58+ );
59+
4560 //till ends we should have at least toDays days
4661 return $ schedule ->isOnce ()
47- ? $ schedule -> timestamp_target -> diffInHours ( now ()-> floorSeconds ()) === $ schedule ->delay_minutes
48- : $ schedule -> timestamp_target -> diffInHours ( now ()-> floorSeconds ()) > $ schedule ->delay_minutes ;
62+ ? $ diff === $ schedule ->delay_minutes
63+ : $ diff > $ schedule ->delay_minutes ;
4964 }
5065}
0 commit comments