hasBeenScheduledForToday property

bool get hasBeenScheduledForToday

Whether the timers for today have already been set up.

Based on RandomRecurrentTrigger.lastTriggerTimestamp.

Implementation

bool get hasBeenScheduledForToday {
  // fast out if no timestamp is set previously
  if (configuration?.lastTriggerTimestamp == null) return false;

  final now = DateTime.now();
  final midnight = DateTime(now.year, now.month, now.day);
  final sinceLastTime = now.millisecond - configuration!.lastTriggerTimestamp!.millisecond;
  final sinceMidnight = now.millisecond - midnight.millisecond;

  return (sinceLastTime < sinceMidnight);
}