Fix display of time left before next appointment
In the notify bar, the clock is shown in hours, minutes and seconds, whereas the time left to the next appointment is shown in hours and minutes only. When you read the clock in hours and minutes (discarding the seconds), you are mentally rounding down to the nearest minute. To agree with that reading, the time left (in seconds) should be (programmatically) rounded up to the nearest minute for display. In that way the time left is counted down whenever the minute "hand" of the clock "ticks", and reaches zero when the clock reaches the time of the next appointment, not one minute before. Also, the clock (in hours and minutes) and the time left always add up to the time of the next appointment. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
c8d5397214
commit
371c7eb00f
@ -236,8 +236,11 @@ static void next_arg(void)
|
|||||||
|
|
||||||
if (next_app.got_app) {
|
if (next_app.got_app) {
|
||||||
time_left = next_app.time - current_time;
|
time_left = next_app.time - current_time;
|
||||||
hours_left = (time_left / HOURINSEC);
|
/* In minutes rounded up. */
|
||||||
min_left = (time_left - hours_left * HOURINSEC) / MININSEC;
|
min_left = time_left / MININSEC +
|
||||||
|
(time_left % MININSEC ? 1 : 0);
|
||||||
|
hours_left = min_left / HOURINMIN;
|
||||||
|
min_left = min_left % HOURINMIN;
|
||||||
fputs(_("next appointment:\n"), stdout);
|
fputs(_("next appointment:\n"), stdout);
|
||||||
fprintf(stdout, " [%02d:%02d] %s\n", hours_left,
|
fprintf(stdout, " [%02d:%02d] %s\n", hours_left,
|
||||||
min_left, next_app.txt);
|
min_left, next_app.txt);
|
||||||
|
12
src/notify.c
12
src/notify.c
@ -279,12 +279,14 @@ void notify_update_bar(void)
|
|||||||
if (time_left > 0) {
|
if (time_left > 0) {
|
||||||
int hours_left, minutes_left;
|
int hours_left, minutes_left;
|
||||||
|
|
||||||
hours_left = (time_left / HOURINSEC);
|
/* In minutes rounded up. */
|
||||||
minutes_left =
|
minutes_left = time_left / MININSEC +
|
||||||
(time_left -
|
(time_left % MININSEC ? 1 : 0);
|
||||||
hours_left * HOURINSEC) / MININSEC;
|
|
||||||
pthread_mutex_lock(&nbar.mutex);
|
|
||||||
|
|
||||||
|
hours_left = minutes_left / HOURINMIN;
|
||||||
|
minutes_left = minutes_left % HOURINMIN;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&nbar.mutex);
|
||||||
blinking = time_left <= nbar.cntdwn && notify_trigger();
|
blinking = time_left <= nbar.cntdwn && notify_trigger();
|
||||||
|
|
||||||
WINS_NBAR_LOCK;
|
WINS_NBAR_LOCK;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user