From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5D99A1382C5 for ; Thu, 12 Apr 2018 19:33:58 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 88B82E0971; Thu, 12 Apr 2018 19:33:57 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 64AE7E0971 for ; Thu, 12 Apr 2018 19:33:57 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 60FF1335C74 for ; Thu, 12 Apr 2018 19:33:56 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id EE114282 for ; Thu, 12 Apr 2018 19:33:54 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1523561557.b5cc7d87b7adf46c2444c68537d8fcfb73ae0060.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: man/include/, /, man/ X-VCS-Repository: proj/portage-utils X-VCS-Files: man/include/qlop.optdesc.yaml man/qlop.1 qlop.c X-VCS-Directories: man/ / man/include/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: b5cc7d87b7adf46c2444c68537d8fcfb73ae0060 X-VCS-Branch: master Date: Thu, 12 Apr 2018 19:33:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 3e6fdb03-f3e5-47d3-ae0d-938819490cbf X-Archives-Hash: 1b4715b6237d3b0f7ca982a8b44e0d8c commit: b5cc7d87b7adf46c2444c68537d8fcfb73ae0060 Author: Fabian Groffen gentoo org> AuthorDate: Thu Apr 12 19:32:37 2018 +0000 Commit: Fabian Groffen gentoo 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 [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 [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;