aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2019-06-06 20:42:10 -0400
committerLukas Fleischer <lfleischer@calcurse.org>2019-06-06 20:57:48 -0400
commitd659a8e2eec44bba08ec498912e5217b28c4409b (patch)
tree730c036840b171f3a61faab6ff50e92facc30e1f
parent16b346a1f485941bce108ae07d8a1abc3d4d852c (diff)
downloadcalcurse-d659a8e2eec44bba08ec498912e5217b28c4409b.tar.gz
calcurse-d659a8e2eec44bba08ec498912e5217b28c4409b.zip
Use empty end date instead of 0 when editing repetitions
Since commit 987fa9d (Allow to omit end date in repetitions, 2019-06-03), one can provide an empty date instead of using the value 0 to omit the end date of a repetition. Use this as default value when editing repetitions without an end date. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
-rw-r--r--src/ui-day.c5
-rw-r--r--src/utils.c24
2 files changed, 12 insertions, 17 deletions
diff --git a/src/ui-day.c b/src/ui-day.c
index c90edc1..fa106c8 100644
--- a/src/ui-day.c
+++ b/src/ui-day.c
@@ -364,7 +364,10 @@ static void update_rept(struct rpt **rpt, const long start)
for (;;) {
mem_free(timstr);
- timstr = date_sec2date_str((*rpt)->until, DATEFMT(conf.input_datefmt));
+ if ((*rpt)->until)
+ timstr = date_sec2date_str((*rpt)->until, DATEFMT(conf.input_datefmt));
+ else
+ timstr = mem_strdup("");
status_mesg(msg_until_1, "");
if (updatestring(win[STA].p, &timstr, 0, 1) == GETSTRING_ESC)
goto cleanup;
diff --git a/src/utils.c b/src/utils.c
index 0acad9f..8a8de75 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -487,22 +487,6 @@ int date_cmp_day(time_t d1, time_t d2)
return 0;
}
-/* Return a string containing the date, given a date in seconds. */
-char *date_sec2date_str(time_t sec, const char *datefmt)
-{
- struct tm lt;
- char *datestr = (char *)mem_calloc(BUFSIZ, sizeof(char));
-
- if (sec == 0) {
- strncpy(datestr, "0", BUFSIZ);
- } else {
- localtime_r(&sec, &lt);
- strftime(datestr, BUFSIZ, datefmt, &lt);
- }
-
- return datestr;
-}
-
/* Generic function to format date. */
void date_sec2date_fmt(time_t sec, const char *fmt, char *datef)
{
@@ -522,6 +506,14 @@ void date_sec2date_fmt(time_t sec, const char *fmt, char *datef)
#endif
}
+/* Return a string containing the date, given a date in seconds. */
+char *date_sec2date_str(time_t sec, const char *datefmt)
+{
+ char *datestr = (char *)mem_calloc(BUFSIZ, sizeof(char));
+ date_sec2date_fmt(sec, datefmt, datestr);
+ return datestr;
+}
+
/*
* Used to change date by adding a certain amount of days or months.
* Returns 0 on success, 1 otherwise.