From adf29c8ee9a5fd4f224dd52f4399bf4550a3039a Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sun, 9 Oct 2016 20:19:15 +0200 Subject: 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 --- src/utils.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/utils.c') 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) -- cgit v1.2.3-54-g00ecf