1 |
commit: c701892114d5b3eea773ff13f013f4d3a71fa571 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Mar 29 16:31:50 2019 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Mar 29 16:31:50 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c7018921 |
7 |
|
8 |
qlop: support standard date output format in parse_date |
9 |
|
10 |
This allows to cut 'n' paste dates to limit output. |
11 |
|
12 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
13 |
|
14 |
man/include/qlop.optdesc.yaml | 3 +++ |
15 |
man/qlop.1 | 5 ++++- |
16 |
qlop.c | 14 +++++++++----- |
17 |
3 files changed, 16 insertions(+), 6 deletions(-) |
18 |
|
19 |
diff --git a/man/include/qlop.optdesc.yaml b/man/include/qlop.optdesc.yaml |
20 |
index a8fae61..25143b2 100644 |
21 |
--- a/man/include/qlop.optdesc.yaml |
22 |
+++ b/man/include/qlop.optdesc.yaml |
23 |
@@ -13,6 +13,9 @@ date: | |
24 |
.IP YYYY-MM-DD |
25 |
Big-endian date, with components separated by hyphens, starting with |
26 |
year, followed by month and day of month. |
27 |
+ .IP YYYY-MM-DDThh:mm:ss |
28 |
+ As before, but hours, minutes and seconds added. This is the same |
29 |
+ format qlop prints for timestamps. |
30 |
.IP SSSSSSSSS |
31 |
Seconds since 1970-01-01 00:00:00 +0000 (UTC), the UNIX epoch. |
32 |
.IP FORMAT|DATE |
33 |
|
34 |
diff --git a/man/qlop.1 b/man/qlop.1 |
35 |
index 407c9ea..f0ef69a 100644 |
36 |
--- a/man/qlop.1 |
37 |
+++ b/man/qlop.1 |
38 |
@@ -1,5 +1,5 @@ |
39 |
.\" generated by mkman.py, please do NOT edit! |
40 |
-.TH qlop "1" "Feb 2019" "Gentoo Foundation" "qlop" |
41 |
+.TH qlop "1" "Mar 2019" "Gentoo Foundation" "qlop" |
42 |
.SH NAME |
43 |
qlop \- emerge log analyzer |
44 |
.SH SYNOPSIS |
45 |
@@ -89,6 +89,9 @@ Alias for \fI1 day ago\fR. |
46 |
.IP YYYY-MM-DD |
47 |
Big-endian date, with components separated by hyphens, starting with |
48 |
year, followed by month and day of month. |
49 |
+.IP YYYY-MM-DDThh:mm:ss |
50 |
+As before, but hours, minutes and seconds added. This is the same |
51 |
+format qlop prints for timestamps. |
52 |
.IP SSSSSSSSS |
53 |
Seconds since 1970-01-01 00:00:00 +0000 (UTC), the UNIX epoch. |
54 |
.IP FORMAT|DATE |
55 |
|
56 |
diff --git a/qlop.c b/qlop.c |
57 |
index b6970d0..a87cc5c 100644 |
58 |
--- a/qlop.c |
59 |
+++ b/qlop.c |
60 |
@@ -103,17 +103,21 @@ parse_date(const char *sdate, time_t *t) |
61 |
return false; |
62 |
} else { |
63 |
/* Handle automatic formats: |
64 |
- * - "12315128" -> %s |
65 |
- * - "2015-12-24" -> %Y-%m-%d |
66 |
+ * - "12315128" -> %s |
67 |
+ * - "2015-12-24" -> %Y-%m-%d |
68 |
+ * - "2019-03-28T13:52:31" -> %Y-%m-%dT%H:%M:%s" |
69 |
* - human readable format (see below) |
70 |
*/ |
71 |
- size_t len = strspn(sdate, "0123456789-"); |
72 |
+ size_t len = strspn(sdate, "0123456789-:T"); |
73 |
if (sdate[len] == '\0') { |
74 |
const char *fmt; |
75 |
- if (strchr(sdate, '-') == NULL) |
76 |
+ if (strchr(sdate, '-') == NULL) { |
77 |
fmt = "%s"; |
78 |
- else |
79 |
+ } else if ((s = strchr(sdate, 'T')) == NULL) { |
80 |
fmt = "%Y-%m-%d"; |
81 |
+ } else { |
82 |
+ fmt = "%Y-%m-%dT%H:%M:%S"; |
83 |
+ } |
84 |
|
85 |
s = strptime(sdate, fmt, &tm); |
86 |
if (s == NULL || s[0] != '\0') |