Skip to content

Commit ab28521

Browse files
Done
1 parent ec099d9 commit ab28521

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/app/utils/utils.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,16 @@ class Utils {
304304
final nextAlarm = todayAlarm.add(const Duration(days: 1));
305305
duration = nextAlarm.difference(now);
306306
}
307-
} else if (now.isBefore(todayAlarm) && days[now.weekday - 1]) {
308-
// If alarm is set for today and time hasn't passed
309-
duration = todayAlarm.difference(now);
307+
} else if (days[now.weekday - 1]) {
308+
// If alarm is set for today
309+
if (now.isBefore(todayAlarm)) {
310+
// Time hasn't passed yet for the repeating alarm
311+
duration = todayAlarm.difference(now);
312+
} else {
313+
// Schedule the alarm for the next occurrence of the same day
314+
final nextAlarm = todayAlarm.add(const Duration(days: 7));
315+
duration = nextAlarm.difference(now);
316+
}
310317
} else {
311318
// Finding the next day when alarm will ring
312319
int daysUntilNextAlarm = 7;

0 commit comments

Comments
 (0)