]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/analyze/analyze-timespan.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
4 #include "analyze-timespan.h"
5 #include "calendarspec.h"
6 #include "format-table.h"
7 #include "glyph-util.h"
9 #include "terminal-util.h"
11 int verb_timespan(int argc
, char *argv
[], void *userdata
) {
12 STRV_FOREACH(input_timespan
, strv_skip(argv
, 1)) {
13 _cleanup_(table_unrefp
) Table
*table
= NULL
;
18 r
= parse_time(*input_timespan
, &output_usecs
, USEC_PER_SEC
);
20 log_error_errno(r
, "Failed to parse time span '%s': %m", *input_timespan
);
21 time_parsing_hint(*input_timespan
, /* calendar= */ true, /* timestamp= */ true, /* timespan= */ false);
25 table
= table_new_vertical();
29 assert_se(cell
= table_get_cell(table
, 0, 0));
30 r
= table_set_ellipsize_percent(table
, cell
, 100);
34 assert_se(cell
= table_get_cell(table
, 0, 1));
35 r
= table_set_ellipsize_percent(table
, cell
, 100);
39 r
= table_add_many(table
,
40 TABLE_FIELD
, "Original",
41 TABLE_STRING
, *input_timespan
);
43 return table_log_add_error(r
);
45 r
= table_add_cell_stringf_full(table
, NULL
, TABLE_FIELD
, "%ss", special_glyph(SPECIAL_GLYPH_MU
));
47 return table_log_add_error(r
);
49 r
= table_add_many(table
,
50 TABLE_UINT64
, output_usecs
,
52 TABLE_TIMESPAN
, output_usecs
,
53 TABLE_SET_COLOR
, ansi_highlight());
55 return table_log_add_error(r
);
57 r
= table_print(table
, NULL
);
61 if (input_timespan
[1])