aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui-day.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-02-25 21:31:16 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-02-26 09:14:40 +0100
commitf5d8b5e021a62bf3e36e18aa9aebee331fece8dd (patch)
tree959b101037e40ee4b7f5fa6392fceb416b666e42 /src/ui-day.c
parentc34f9aba29b965bf1da7e16da91ebf94ae123e89 (diff)
downloadcalcurse-f5d8b5e021a62bf3e36e18aa9aebee331fece8dd.tar.gz
calcurse-f5d8b5e021a62bf3e36e18aa9aebee331fece8dd.zip
Support durations in recurrence ending dates
When spending the end date of recurring items, allow date duration specifiers such as "+5d" or "+3w2d". Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/ui-day.c')
-rw-r--r--src/ui-day.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/src/ui-day.c b/src/ui-day.c
index 63c5da8..fdb3c09 100644
--- a/src/ui-day.c
+++ b/src/ui-day.c
@@ -254,6 +254,7 @@ static void update_rept(struct rpt **rpt, const long start)
time_t t;
struct date new_date;
int newmonth, newday, newyear;
+ unsigned days;
asprintf(&outstr, _("Enter the new ending date: [%s] or '0'"),
DATEFMT_DESC(conf.input_datefmt));
@@ -270,21 +271,38 @@ static void update_rept(struct rpt **rpt, const long start)
newuntil = 0;
break;
}
- if (!parse_date
- (timstr, conf.input_datefmt, &newyear, &newmonth,
- &newday, ui_calendar_get_slctd_day())) {
- asprintf(&outstr, msg_fmts,
- DATEFMT_DESC(conf.input_datefmt));
- status_mesg(msg_wrong_date, outstr);
- mem_free(outstr);
- wgetch(win[KEY].p);
- continue;
+ if (*timstr == '+') {
+ if (!parse_date_duration(timstr + 1, &days)) {
+ asprintf(&outstr, msg_fmts,
+ DATEFMT_DESC(conf.input_datefmt));
+ status_mesg(msg_wrong_date, outstr);
+ mem_free(outstr);
+ wgetch(win[KEY].p);
+ continue;
+ }
+ t = start;
+ localtime_r(&t, &lt);
+ date_change(&lt, 0, days);
+ new_date.dd = lt.tm_mday;
+ new_date.mm = lt.tm_mon + 1;
+ new_date.yyyy = lt.tm_year + 1900;
+ } else {
+ if (!parse_date(timstr, conf.input_datefmt, &newyear,
+ &newmonth, &newday,
+ ui_calendar_get_slctd_day())) {
+ asprintf(&outstr, msg_fmts,
+ DATEFMT_DESC(conf.input_datefmt));
+ status_mesg(msg_wrong_date, outstr);
+ mem_free(outstr);
+ wgetch(win[KEY].p);
+ continue;
+ }
+ t = start;
+ localtime_r(&t, &lt);
+ new_date.dd = newday;
+ new_date.mm = newmonth;
+ new_date.yyyy = newyear;
}
- t = start;
- localtime_r(&t, &lt);
- new_date.dd = newday;
- new_date.mm = newmonth;
- new_date.yyyy = newyear;
newuntil = date2sec(new_date, lt.tm_hour, lt.tm_min);
if (newuntil >= start)
break;