Include start day in error message for recurrence rule
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
61a743c56a
commit
92dc069fc4
@ -1269,6 +1269,7 @@ long overflow_mul(long, long, long *);
|
|||||||
time_t next_wday(time_t, int);
|
time_t next_wday(time_t, int);
|
||||||
int wday_per_year(int, int);
|
int wday_per_year(int, int);
|
||||||
int wday_per_month(int, int, int);
|
int wday_per_month(int, int, int);
|
||||||
|
char *day_ins(char **, time_t);
|
||||||
|
|
||||||
/* vars.c */
|
/* vars.c */
|
||||||
extern int col, row;
|
extern int col, row;
|
||||||
|
12
src/recur.c
12
src/recur.c
@ -518,8 +518,10 @@ char *recur_apoint_scan(FILE *f, struct tm start, struct tm end,
|
|||||||
/* Does it occur on the start day? */
|
/* Does it occur on the start day? */
|
||||||
if (!recur_item_find_occurrence(tstart, tend - tstart, rpt, NULL,
|
if (!recur_item_find_occurrence(tstart, tend - tstart, rpt, NULL,
|
||||||
update_time_in_date(tstart, 0, 0),
|
update_time_in_date(tstart, 0, 0),
|
||||||
NULL))
|
NULL)) {
|
||||||
return _("recurrence error: not on start day");
|
char *fmt = _("recurrence error: not on start day (%s)");
|
||||||
|
return day_ins(&fmt, tstart);
|
||||||
|
}
|
||||||
|
|
||||||
/* Filter item. */
|
/* Filter item. */
|
||||||
if (filter) {
|
if (filter) {
|
||||||
@ -589,8 +591,10 @@ char *recur_event_scan(FILE * f, struct tm start, int id,
|
|||||||
/* Does it occur on the start day? */
|
/* Does it occur on the start day? */
|
||||||
if (!recur_item_find_occurrence(tstart, -1, rpt, NULL,
|
if (!recur_item_find_occurrence(tstart, -1, rpt, NULL,
|
||||||
update_time_in_date(tstart, 0, 0),
|
update_time_in_date(tstart, 0, 0),
|
||||||
NULL))
|
NULL)) {
|
||||||
return _("recurrence error: not on start day");
|
char *fmt = _("recurrence error: not on start day (%s)");
|
||||||
|
return day_ins(&fmt, tstart);
|
||||||
|
}
|
||||||
|
|
||||||
/* Filter item. */
|
/* Filter item. */
|
||||||
if (filter) {
|
if (filter) {
|
||||||
|
19
src/ui-day.c
19
src/ui-day.c
@ -175,8 +175,8 @@ static void update_start_time(time_t *start, long *dur, struct rpt *rpt, int mov
|
|||||||
time_t newtime;
|
time_t newtime;
|
||||||
const char *msg_wrong_time =
|
const char *msg_wrong_time =
|
||||||
_("Invalid time: start time must come before end time!");
|
_("Invalid time: start time must come before end time!");
|
||||||
const char *msg_match =
|
char *msg_match =
|
||||||
_("Repetition must begin on start day.");
|
_("Repetition must begin on start day (%s).");
|
||||||
const char *msg_enter = _("Press [Enter] to continue");
|
const char *msg_enter = _("Press [Enter] to continue");
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
@ -188,7 +188,9 @@ static void update_start_time(time_t *start, long *dur, struct rpt *rpt, int mov
|
|||||||
newtime, *dur, rpt, NULL,
|
newtime, *dur, rpt, NULL,
|
||||||
update_time_in_date(newtime, 0, 0),
|
update_time_in_date(newtime, 0, 0),
|
||||||
NULL)) {
|
NULL)) {
|
||||||
msg = (char *)msg_match;
|
msg = day_ins(&msg_match, newtime);
|
||||||
|
status_mesg(msg, msg_enter);
|
||||||
|
mem_free(msg);
|
||||||
} else {
|
} else {
|
||||||
if (move) {
|
if (move) {
|
||||||
*start = newtime;
|
*start = newtime;
|
||||||
@ -200,9 +202,8 @@ static void update_start_time(time_t *start, long *dur, struct rpt *rpt, int mov
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg = (char *)msg_wrong_time;
|
status_mesg(msg_wrong_time, msg_enter);
|
||||||
}
|
}
|
||||||
status_mesg(msg, msg_enter);
|
|
||||||
keys_wgetch(win[KEY].p);
|
keys_wgetch(win[KEY].p);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -858,12 +859,14 @@ static int update_rept(time_t start, long dur, struct rpt **rpt, llist_t *exc,
|
|||||||
* RFC5545 and ensures that the recurrence set is non-empty (unless it
|
* RFC5545 and ensures that the recurrence set is non-empty (unless it
|
||||||
* is an exception day).
|
* is an exception day).
|
||||||
*/
|
*/
|
||||||
const char *msg_match =
|
char *msg_match =
|
||||||
_("Repetition must begin on start day; any change discarded.");
|
_("Repetition must begin on start day (%s); any change discarded.");
|
||||||
if (!recur_item_find_occurrence(start, dur, &nrpt, NULL,
|
if (!recur_item_find_occurrence(start, dur, &nrpt, NULL,
|
||||||
update_time_in_date(start, 0, 0),
|
update_time_in_date(start, 0, 0),
|
||||||
NULL)) {
|
NULL)) {
|
||||||
status_mesg(msg_match, msg_cont);
|
mem_free(outstr);
|
||||||
|
outstr = day_ins(&msg_match, start);
|
||||||
|
status_mesg(outstr, msg_cont);
|
||||||
keys_wgetch(win[KEY].p);
|
keys_wgetch(win[KEY].p);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
16
src/utils.c
16
src/utils.c
@ -2067,3 +2067,19 @@ int wday_per_month(int month, int year, int weekday)
|
|||||||
|
|
||||||
return last_wday / 7 + (last_wday % 7 > 0);
|
return last_wday / 7 + (last_wday % 7 > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return allocated string with day of 't' inserted in 'template' in the user's
|
||||||
|
* preferred format; template must be a "printf" template with exactly one
|
||||||
|
* string conversion (%s).
|
||||||
|
*/
|
||||||
|
char *day_ins(char **template, time_t t)
|
||||||
|
{
|
||||||
|
char *day, *msg;
|
||||||
|
|
||||||
|
day = date_sec2date_str(update_time_in_date(t, 0 , 0),
|
||||||
|
DATEFMT(conf.input_datefmt));
|
||||||
|
asprintf(&msg, *template, day);
|
||||||
|
mem_free(day);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user