aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/calcurse.h1
-rw-r--r--src/recur.c12
-rw-r--r--src/ui-day.c19
-rw-r--r--src/utils.c16
4 files changed, 36 insertions, 12 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index 0c959a9..25c63a0 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -1269,6 +1269,7 @@ long overflow_mul(long, long, long *);
time_t next_wday(time_t, int);
int wday_per_year(int, int);
int wday_per_month(int, int, int);
+char *day_ins(char **, time_t);
/* vars.c */
extern int col, row;
diff --git a/src/recur.c b/src/recur.c
index 510fddb..d028d09 100644
--- a/src/recur.c
+++ b/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? */
if (!recur_item_find_occurrence(tstart, tend - tstart, rpt, NULL,
update_time_in_date(tstart, 0, 0),
- NULL))
- return _("recurrence error: not on start day");
+ NULL)) {
+ char *fmt = _("recurrence error: not on start day (%s)");
+ return day_ins(&fmt, tstart);
+ }
/* Filter item. */
if (filter) {
@@ -589,8 +591,10 @@ char *recur_event_scan(FILE * f, struct tm start, int id,
/* Does it occur on the start day? */
if (!recur_item_find_occurrence(tstart, -1, rpt, NULL,
update_time_in_date(tstart, 0, 0),
- NULL))
- return _("recurrence error: not on start day");
+ NULL)) {
+ char *fmt = _("recurrence error: not on start day (%s)");
+ return day_ins(&fmt, tstart);
+ }
/* Filter item. */
if (filter) {
diff --git a/src/ui-day.c b/src/ui-day.c
index 5a8d960..bd83cac 100644
--- a/src/ui-day.c
+++ b/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;
const char *msg_wrong_time =
_("Invalid time: start time must come before end time!");
- const char *msg_match =
- _("Repetition must begin on start day.");
+ char *msg_match =
+ _("Repetition must begin on start day (%s).");
const char *msg_enter = _("Press [Enter] to continue");
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,
update_time_in_date(newtime, 0, 0),
NULL)) {
- msg = (char *)msg_match;
+ msg = day_ins(&msg_match, newtime);
+ status_mesg(msg, msg_enter);
+ mem_free(msg);
} else {
if (move) {
*start = newtime;
@@ -200,9 +202,8 @@ static void update_start_time(time_t *start, long *dur, struct rpt *rpt, int mov
break;
}
}
- msg = (char *)msg_wrong_time;
+ status_mesg(msg_wrong_time, msg_enter);
}
- status_mesg(msg, msg_enter);
keys_wgetch(win[KEY].p);
}
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
* is an exception day).
*/
- const char *msg_match =
- _("Repetition must begin on start day; any change discarded.");
+ char *msg_match =
+ _("Repetition must begin on start day (%s); any change discarded.");
if (!recur_item_find_occurrence(start, dur, &nrpt, NULL,
update_time_in_date(start, 0, 0),
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);
goto cleanup;
}
diff --git a/src/utils.c b/src/utils.c
index 5322db1..8c539c3 100644
--- a/src/utils.c
+++ b/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 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;
+}