public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Fabian Groffen" <grobian@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage-utils:master commit in: man/include/, /, man/
Date: Thu, 12 Apr 2018 19:33:54 +0000 (UTC)	[thread overview]
Message-ID: <1523561557.b5cc7d87b7adf46c2444c68537d8fcfb73ae0060.grobian@gentoo> (raw)

commit:     b5cc7d87b7adf46c2444c68537d8fcfb73ae0060
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 12 19:32:37 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr 12 19:32:37 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b5cc7d87

qlop: accept "today" and "yesterday" for parse_date

Bug: https://bugs.gentoo.org/652312

 man/include/qlop.optdesc.yaml |  4 ++++
 man/qlop.1                    |  4 ++++
 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 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;
 


             reply	other threads:[~2018-04-12 19:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-12 19:33 Fabian Groffen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-02-20 12:23 [gentoo-commits] proj/portage-utils:master commit in: man/include/, /, man/ Fabian Groffen
2019-12-27 16:57 Fabian Groffen
2019-06-19  7:31 Fabian Groffen
2019-04-12 18:50 Fabian Groffen
2018-04-03 15:21 Fabian Groffen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1523561557.b5cc7d87b7adf46c2444c68537d8fcfb73ae0060.grobian@gentoo \
    --to=grobian@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox