From ff85325886a9441fd77f1a78e05d11cd3838fe24 Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Wed, 1 Jan 2020 18:00:22 -0500 Subject: [PATCH] Support DATETIME - TIME --- man/remind.1 | 8 +++++--- src/expr.c | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/man/remind.1 b/man/remind.1 index f764d6f1..482e6633 100644 --- a/man/remind.1 +++ b/man/remind.1 @@ -1761,9 +1761,11 @@ the original \fBDATE\fR. earlier than the original \fBTIME\fR. .PP -\fBDATETIME\fR - \fBINT\fR - returns a \fBDATETIME\fR that is \fBINT\fR minutes -earlier -than the original \fBDATETIME\fR. +\fBDATETIME\fR - \fBINT\fR - returns a \fBDATETIME\fR that is +\fBINT\fR minutes earlier than the original \fBDATETIME\fR. +.PP +\fBDATETIME\fR - \fBTIME\fR - coerces the \fBTIME\fR to an \fBINT\fR +and then performs subtraction as above. .RE .TP .B <, <=, >, and >= diff --git a/src/expr.c b/src/expr.c index 4d57051e..595324e3 100644 --- a/src/expr.c +++ b/src/expr.c @@ -854,8 +854,9 @@ static int Subtract(void) return OK; } - /* If it's a datetime minus an int, do subtraction, checking for underflow */ - if (v1.type == DATETIME_TYPE && v2.type == INT_TYPE) { + /* If it's a datetime minus an int or a time, do subtraction, + * checking for underflow */ + if (v1.type == DATETIME_TYPE && (v2.type == INT_TYPE || v2.type == TIME_TYPE)) { v1.v.val -= v2.v.val; if (v1.v.val < 0) return E_DATE_OVER; PushValStack(v1);