diff options
-rw-r--r-- | man/include/qlop.optdesc.yaml | 4 | ||||
-rw-r--r-- | man/qlop.1 | 4 | ||||
-rw-r--r-- | qlop.c | 13 |
3 files changed, 19 insertions, 2 deletions
diff --git a/man/include/qlop.optdesc.yaml b/man/include/qlop.optdesc.yaml index fad1670d..3ff62c31 100644 --- a/man/include/qlop.optdesc.yaml +++ b/man/include/qlop.optdesc.yaml @@ -6,6 +6,10 @@ date: | .IP "NUMBER <day|week|month|year>[s] [ago]" Relative time, specifying \fINUMBER\fR \fIdays\fR, \fIweeks\fR, \fImonths\fR or \fIyears\fR, for example \fI3 days ago\fR. + .IP today + Alias for \fI0 days ago\fR. + .IP yesterday + Alias for \fI1 day ago\fR. .IP YYYY-MM-DD Big-endian date, with components separated by hyphens, starting with year, followed by month and day of month. @@ -46,6 +46,10 @@ can take a few forms. .IP "NUMBER <day|week|month|year>[s] [ago]" Relative time, specifying \fINUMBER\fR \fIdays\fR, \fIweeks\fR, \fImonths\fR or \fIyears\fR, for example \fI3 days ago\fR. +.IP today +Alias for \fI0 days ago\fR. +.IP yesterday +Alias for \fI1 day ago\fR. .IP YYYY-MM-DD Big-endian date, with components separated by hyphens, starting with year, followed by month and day of month. @@ -758,8 +758,17 @@ parse_date(const char *sdate, time_t *t) char ago[len]; int ret = sscanf(sdate, "%lu %s %s", &num, dur, ago); - if (ret < 2) - return false; + if (ret < 2) { + if (strcmp(sdate, "today") == 0) { + num = 0; + snprintf(dur, len, "%s", "day"); + } else if (strcmp(sdate, "yesterday") == 0) { + num = 1; + snprintf(dur, len, "%s", "day"); + } else { + return false; + } + } if (ret == 3 && strcmp(ago, "ago") != 0) return false; |