diff --git a/man/remind.1 b/man/remind.1 index 3b5b5ef1..bfa0a9c5 100644 --- a/man/remind.1 +++ b/man/remind.1 @@ -1709,7 +1709,12 @@ Has several uses. These are: .PP \fBINT\fR + \fBTIME\fR or \fBTIME\fR + \fBINT\fR - returns a \fBTIME\fR obtained by adding -\fBINT\fR minutes to the original \fBTIME\fR. +\fBINT\fR minutes to the original \fBTIME\fR. The result will always +range from 00:00 through 23:59. +.PP +\fBTIME\fR + \fBTIME\fR treats the second \fBTIME\fR parameter as a +duration, converting it to an integer number of minutes past midnight, +and then performs addition as with \fBTIME\fR + \fBINT\fR. .PP \fBINT\fR + \fBDATE\fR or \fBDATE\fR + \fBINT\fR - returns a \fBDATE\fR obtained by adding \fBINT\fR days to the original \fBDATE\fR. @@ -1718,6 +1723,11 @@ obtained by adding \fBINT\fR days to the original \fBDATE\fR. \fBDATETIME\fR obtained by adding \fBINT\fR minutes to the original \fBDATETIME\fR. .PP +\fBDATETIME\fR + \fBTIME\fR or \fBTIME\fR + \fBDATETIME\fR +treats the \fBTIME\fR parameter as a +duration, converting it to an integer number of minutes past midnight, +and then performs addition as with \fBDATETIME\fR + \fBINT\fR. +.PP \fBSTRING\fR + \fBSTRING\fR - returns a \fBSTRING\fR that is the concatenation of the two original \fBSTRING\fRs. @@ -2796,6 +2806,52 @@ Similar to trigdate(), but returns a \fBDATETIME\fR if the most recent triggerable \fBREM\fR command had an \fBAT\fR clause. If there was no \fBAT\fR clause, returns a \fBDATE\fR. If no trigger could be computed, returns the integer 0. +.TP +.B trigback() +Returns the "back" amount of the last \fBREM\fR or \fBIFTRIG\fR command. +Returns a positive integer N if the "back" is of the form -N, or a negative +integer if it is of the form --N. If there is no "back", then returns 0. +.TP +.B trigdelta() +Returns the "delta" amount of the last \fBREM\fR or \fBIFTRIG\fR command. +Returns a positive integer N if the "delta" is of the form +N, or a negative +integer if it is of the form ++N. If there is no "delta", then returns 0. +.TP +.B trigtimedelta() +Similar to \fBtrigdelta()\fR, but returns the delta used in the +"AT..." clause of a timed reminder. +.TP +.B trigrep() +Returns the "repeat" amount of the last \fBREM\fR or \fBIFTRIG\fR +command. Returns a positive integer N if the "repeat" is of the form +*N. If there is no "repeat", then returns 0. +.TP +.B trigtimerep() +Similar to \fBtrigrep()\fR, but returns the repeat used in the "AT..." clause +of a timed reminder. +.TP +.B trigduration() +Returns (as a TIME type) the DURATION parameter of a timed reminder. If there +is no DURATION parameter, returns the integer -1. +.TP +.B trigpriority() +Returns the PRIORITY of the last \fBREM\fR or \fBIFTRIG\fR command. +.TP +.B triguntil() +Returns (as a DATE type) the UNTIL parameter of the last \fBREM\fR or +\fBIFTRIG\fR command. If there was no UNTIL parameter, returns the integer -1. +.TP +.B trigscanfrom() +Returns (as a DATE type) the SCANFROM parameter of the last \fBREM\fR +or \fBIFTRIG\fR command. If there was no SCANFROM parameter, returns +the integer -1. Note that FROM and SCANFROM interact; a reminder that +has a "FROM yyyy-mm-dd" parameter will act as if it has a SCANFROM parameter +whose value is the maximum of "yyyy-mm-dd" and today. +.TP +.B trigfrom() +Returns (as a DATE type) the FROM parameter of the last \fBREM\fR or +\fBIFTRIG\fR command. If there was no FROM parameter, returns the integer -1. + .TP .B trigger(d_date [,t_time [,i_utcflag]]) \fRor\fB trigger(q_datetime [,i_utcflag]) Returns a string suitable for use in a \fBREM\fR command or a SCANFROM diff --git a/src/expr.c b/src/expr.c index f87b5cfe..02e41e48 100644 --- a/src/expr.c +++ b/src/expr.c @@ -765,9 +765,9 @@ static int Add(void) return OK; } -/* If it's a datetime plus an int, add 'em */ - if ((v1.type == DATETIME_TYPE && v2.type == INT_TYPE) || - (v1.type == INT_TYPE && v2.type == DATETIME_TYPE)) { +/* If it's a datetime plus an int or a time, add 'em */ + if ((v1.type == DATETIME_TYPE && (v2.type == INT_TYPE || v2.type == TIME_TYPE)) || + ((v1.type == INT_TYPE || v1.type == TIME_TYPE) && v2.type == DATETIME_TYPE)) { v1.v.val += v2.v.val; if (v1.v.val < 0) return E_DATE_OVER; v1.type = DATETIME_TYPE; @@ -775,9 +775,11 @@ static int Add(void) return OK; } -/* If it's a time plus an int, add 'em mod MINUTES_PER_DAY */ +/* If it's a time plus an int or a time plus a time, + add 'em mod MINUTES_PER_DAY */ if ((v1.type == TIME_TYPE && v2.type == INT_TYPE) || - (v1.type == INT_TYPE && v2.type == TIME_TYPE)) { + (v1.type == INT_TYPE && v2.type == TIME_TYPE) || + (v1.type == TIME_TYPE && v2.type == TIME_TYPE)) { v1.v.val = (v1.v.val + v2.v.val) % MINUTES_PER_DAY; if (v1.v.val < 0) v1.v.val += MINUTES_PER_DAY; v1.type = TIME_TYPE; diff --git a/tests/test.cmp b/tests/test.cmp index 39819a98..cfdfe543 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -1141,6 +1141,16 @@ trigtimerep() => 0 set a125 trigduration() trigduration() => -1 +# Test adding TIME+TIME and DATETIME+TIME +set a126 11:00 + 3:00 +11:00 + 03:00 => 14:00 +set a127 23:00 + 5:30 +23:00 + 05:30 => 04:30 +set a128 '2018-02-03@10:00' + 6:45 +2018-02-03@10:00 + 06:45 => 2018-02-03@16:45 +set a129 23:30 + '2019-02-02@16:44' +23:30 + 2019-02-02@16:44 => 2019-02-03@16:14 + dump Variable Value @@ -1156,6 +1166,7 @@ dump a065 1 a084 7 a107 3 + a126 14:00 a018 1 a037 1991-02-15 a056 "SDFJHSDF KSJDFH KJSDFH KSJDFH" @@ -1167,6 +1178,7 @@ dump a066 0 a085 7 a108 14 + a127 04:30 a019 0 a038 33 a057 "SDFJHSDF KSJDFH KJSDFH KSJDFH" @@ -1178,6 +1190,7 @@ dump a067 "INT" a086 4 a109 2012-01-01 + a128 2018-02-03@16:45 a039 "February" a058 "03.01.17" a077 "1992 92 @@ -1187,6 +1200,7 @@ dump a049 21 a068 "STRING" a087 3 + a129 2019-02-03@16:14 a059 "Saturday" a078 1991-03-31 a097 -3 @@ -1272,10 +1286,10 @@ dump $aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa $aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: Name too long OMIT 2010-09-03 THROUGH 2010-09-15 OMIT December 25 MSG X -../tests/test.rem(367): Trig = Wednesday, 25 December, 1991 +../tests/test.rem(373): Trig = Wednesday, 25 December, 1991 # Next should give a parse error OMIT 26 Dec 2010 THROUGH 27 Dec 2010 MSG This is not legal -../tests/test.rem(369): Trig = Sunday, 26 December, 2010 +../tests/test.rem(375): Trig = Sunday, 26 December, 2010 OMIT DUMP Global Full OMITs (16 of maximum allowed 500): 1991-03-11 @@ -1307,7 +1321,7 @@ a => 5761 hebdate(14, "Adar", 1991-02-16, 5761) => 1991-02-28 trigger(1991-02-28) => "28 February 1991" Leaving UserFN _i() => "28 February 1991" -../tests/test.rem(372): Trig = Thursday, 28 February, 1991 +../tests/test.rem(378): Trig = Thursday, 28 February, 1991 Test 2 diff --git a/tests/test.rem b/tests/test.rem index b1294798..420ad910 100644 --- a/tests/test.rem +++ b/tests/test.rem @@ -361,6 +361,12 @@ set a123 trigtimedelta() set a124 trigtimerep() set a125 trigduration() +# Test adding TIME+TIME and DATETIME+TIME +set a126 11:00 + 3:00 +set a127 23:00 + 5:30 +set a128 '2018-02-03@10:00' + 6:45 +set a129 23:30 + '2019-02-02@16:44' + dump dump $aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa OMIT 2010-09-03 THROUGH 2010-09-15