@@ -984,17 +984,18 @@ ShouldRunTask(entry *schedule, TimestampTz currentTime, bool doWild,
984
984
* so cur_tm cannot be used after this point.
985
985
*/
986
986
struct pg_tm * tomorrow_tm = pg_localtime (& tomorrowTime_t , pg_tzset (cron_timezone ));
987
- bool lastdom = ( schedule -> flags & DOM_LAST ) != 0 && tomorrow_tm -> tm_mday == 1 ;
988
- bool thisdom = lastdom || bit_test (schedule -> dom , dayOfMonth ) != 0 ;
987
+ bool is_lastdom = tomorrow_tm -> tm_mday == 1 ;
988
+ bool thisdom = bit_test (schedule -> dom , dayOfMonth ) != 0 || ( is_lastdom && ( schedule -> flags & DOM_LAST ) != 0 ) ;
989
989
bool thisdow = bit_test (schedule -> dow , dayOfWeek );
990
-
991
990
if (bit_test (schedule -> minute , minute ) &&
992
- bit_test (schedule -> hour , hour ) &&
993
- bit_test (schedule -> month , month ) &&
994
- ( (schedule -> flags & (DOM_STAR |DOW_STAR )) != 0
995
- ? (thisdom && thisdow ) : (thisdom ) || thisdow )) {
996
- if ((doNonWild && !(schedule -> flags & (MIN_STAR |HR_STAR )))
997
- || (doWild && (schedule -> flags & (MIN_STAR |HR_STAR ))))
991
+ bit_test (schedule -> hour , hour ) &&
992
+ bit_test (schedule -> month , month ) &&
993
+ ((schedule -> flags & (DOM_STAR | DOW_STAR )) != 0
994
+ ? (thisdom && thisdow )
995
+ : (thisdom || thisdow )))
996
+ {
997
+ if ((doNonWild && (schedule -> flags & (MIN_STAR | HR_STAR )) == 0 ) ||
998
+ (doWild && (schedule -> flags & (MIN_STAR | HR_STAR )) != 0 ))
998
999
{
999
1000
return true;
1000
1001
}
0 commit comments