summaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-10-09 20:19:15 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2016-10-09 20:21:04 +0200
commitadf29c8ee9a5fd4f224dd52f4399bf4550a3039a (patch)
tree55466798f2e92cc20fbd8f0814b6682735ce6815 /src/utils.c
parent343d68596d0bf16d6e041d3a7871ceacbf54300b (diff)
downloadcalcurse-adf29c8ee9a5fd4f224dd52f4399bf4550a3039a.zip
Support dates when specifying start/end times
Add support for combined date/time or date-only strings when specifying the start or end time of a new item. This is a follow-up to 1f39b5c (Add support for moving items to another day, 2016-09-30). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/utils.c b/src/utils.c
index 335f325..9727c74 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1112,7 +1112,8 @@ int parse_duration(const char *string, unsigned *duration)
* updated and the date remains the same. If the string contains both a date
* and a time, the time stamp is updated to match the given string.
*
- * Returns 1 on success and 0 on failure.
+ * Returns a positive value on success and 0 on failure. The least-significant
+ * bit is set if the date was updated. Bit 1 is set if the time was updated.
*/
int parse_datetime(const char *string, long *ts)
{
@@ -1122,6 +1123,7 @@ int parse_datetime(const char *string, long *ts)
unsigned int hour, minute;
int year, month, day;
struct date new_date;
+ int ret = 0;
while (p) {
if (parse_date(p, conf.input_datefmt, &year, &month, &day,
@@ -1130,8 +1132,10 @@ int parse_datetime(const char *string, long *ts)
new_date.mm = month;
new_date.yyyy = year;
*ts = date2sec(new_date, 0, 0) + get_item_time(*ts);
+ ret |= 1;
} else if (parse_time(p, &hour, &minute) == 1) {
*ts = update_time_in_date(*ts, hour, minute);
+ ret |= 2;
} else {
return 0;
}
@@ -1139,7 +1143,7 @@ int parse_datetime(const char *string, long *ts)
}
mem_free(t);
- return 1;
+ return ret;
}
void file_close(FILE * f, const char *pos)