Index: apps/plugins/alarmclock.c =================================================================== --- apps/plugins/alarmclock.c (révision 25207) +++ apps/plugins/alarmclock.c (copie de travail) @@ -28,6 +28,7 @@ generic_actions}; static int current = 0; +static bool overlap = false; static int alarm[2] = {0, 0}, maxval[2] = {24, 60}; static bool quit = false, usb = false, waiting = false, done = false; @@ -36,9 +37,14 @@ } int rem_seconds(void) { - return (((alarm[0] - rb->get_time()->tm_hour) * 3600) - +((alarm[1] - rb->get_time()->tm_min) * 60) - -(rb->get_time()->tm_sec)); + int seconds = (((alarm[0] - rb->get_time()->tm_hour) * 3600) + +((alarm[1] - rb->get_time()->tm_min) * 60) + -(rb->get_time()->tm_sec)); + + /* The overlap flag means that the alarm should ring on the next day */ + if (seconds > 0) overlap = false; + + return seconds + (overlap ? 24 * 3600 : 0); } void draw_centered_string(struct screen * display, char * string) { @@ -87,7 +93,7 @@ else if (audio_status & AUDIO_STATUS_PAUSE) return true; - return false; + return false; } void play(void) { @@ -151,8 +157,12 @@ break; case PLA_FIRE: { + if (alarm[0] == 0 && alarm[1] == 0) + alarm[1] = 1; /* Ensure that there is enough time + for the overlap flag to be reset */ + if (rem_seconds() < 0) - alarm[0] += 24; + overlap = true; waiting = true; break;