diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/calcurse.h | 4 | ||||
-rw-r--r-- | src/ui-day.c | 6 | ||||
-rw-r--r-- | src/utils.c | 4 |
3 files changed, 9 insertions, 5 deletions
diff --git a/src/calcurse.h b/src/calcurse.h index 3810db2..a35bbcb 100644 --- a/src/calcurse.h +++ b/src/calcurse.h @@ -628,6 +628,10 @@ enum getstr { GETSTRING_RET /* return was pressed without entering any text. */ }; +/* Return codes for parse_datetime(). */ +#define PARSE_DATETIME_HAS_DATE (1 << 0) +#define PARSE_DATETIME_HAS_TIME (1 << 1) + /* Week days. */ enum wday { SUNDAY, diff --git a/src/ui-day.c b/src/ui-day.c index 2eef149..d7112af 100644 --- a/src/ui-day.c +++ b/src/ui-day.c @@ -115,7 +115,7 @@ static int day_edit_duration(int start, int dur, unsigned *new_duration) * the start time, assume that the time belongs to the * next day. */ - if (ret == 2 && end < start) + if (!(ret & PARSE_DATETIME_HAS_DATE) && end < start) end = date_sec_change(end, 0, 1); if (ret) { *new_duration = end - start; @@ -537,7 +537,7 @@ void ui_day_item_add(void) break; } ret = parse_datetime(item_time, &start); - if (!(ret & 2)) + if (!(ret & PARSE_DATETIME_HAS_TIME)) is_appointment = 0; if (ret) break; @@ -574,7 +574,7 @@ void ui_day_item_add(void) * the start time, assume that the time belongs to the * next day. */ - if (ret == 2 && end < start) + if (!(ret & PARSE_DATETIME_HAS_DATE) && end < start) end = date_sec_change(end, 0, 1); if (ret) { dur = end - start; diff --git a/src/utils.c b/src/utils.c index 9727c74..9e325d9 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1132,10 +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; + ret |= PARSE_DATETIME_HAS_DATE; } else if (parse_time(p, &hour, &minute) == 1) { *ts = update_time_in_date(*ts, hour, minute); - ret |= 2; + ret |= PARSE_DATETIME_HAS_TIME; } else { return 0; } |