]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/analyze/analyze-timespan.c
8d7cd2ddd5924632952c023cc5f6d13c90cb045e
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 char **input_timespan
;
14 STRV_FOREACH(input_timespan
, strv_skip(argv
, 1)) {
15 _cleanup_(table_unrefp
) Table
*table
= NULL
;
20 r
= parse_time(*input_timespan
, &output_usecs
, USEC_PER_SEC
);
22 log_error_errno(r
, "Failed to parse time span '%s': %m", *input_timespan
);
23 time_parsing_hint(*input_timespan
, /* calendar= */ true, /* timestamp= */ true, /* timespan= */ false);
27 table
= table_new("name", "value");
31 table_set_header(table
, false);
33 assert_se(cell
= table_get_cell(table
, 0, 0));
34 r
= table_set_ellipsize_percent(table
, cell
, 100);
38 r
= table_set_align_percent(table
, cell
, 100);
42 assert_se(cell
= table_get_cell(table
, 0, 1));
43 r
= table_set_ellipsize_percent(table
, cell
, 100);
47 r
= table_add_many(table
,
48 TABLE_STRING
, "Original:",
49 TABLE_STRING
, *input_timespan
);
51 return table_log_add_error(r
);
53 r
= table_add_cell_stringf(table
, NULL
, "%ss:", special_glyph(SPECIAL_GLYPH_MU
));
55 return table_log_add_error(r
);
57 r
= table_add_many(table
,
58 TABLE_UINT64
, output_usecs
,
59 TABLE_STRING
, "Human:",
60 TABLE_TIMESPAN
, output_usecs
,
61 TABLE_SET_COLOR
, ansi_highlight());
63 return table_log_add_error(r
);
65 r
= table_print(table
, NULL
);
69 if (input_timespan
[1])