aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/include/qlop.optdesc.yaml4
-rw-r--r--man/qlop.14
-rw-r--r--qlop.c13
3 files changed, 19 insertions, 2 deletions
diff --git a/man/include/qlop.optdesc.yaml b/man/include/qlop.optdesc.yaml
index fad1670..3ff62c3 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.
diff --git a/man/qlop.1 b/man/qlop.1
index 9c449a9..18c05fb 100644
--- a/man/qlop.1
+++ b/man/qlop.1
@@ -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.
diff --git a/qlop.c b/qlop.c
index 1d4e0d9..7bac8c2 100644
--- a/qlop.c
+++ b/qlop.c
@@ -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;