mirror of
https://github.com/systemd/systemd.git
synced 2025-03-21 02:50:18 +03:00
format-table: add new cell type TABLE_TIMESPAN_DAY
This is just like TABLE_TIMESPAN_MSEC, but shows time spans in accuracy of days.
This commit is contained in:
parent
856ad0fdb6
commit
3d46a8292f
@ -300,6 +300,7 @@ static size_t table_data_size(TableDataType type, const void *data) {
|
||||
case TABLE_TIMESTAMP_DATE:
|
||||
case TABLE_TIMESPAN:
|
||||
case TABLE_TIMESPAN_MSEC:
|
||||
case TABLE_TIMESPAN_DAY:
|
||||
return sizeof(usec_t);
|
||||
|
||||
case TABLE_SIZE:
|
||||
@ -898,6 +899,7 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
|
||||
case TABLE_TIMESTAMP_DATE:
|
||||
case TABLE_TIMESPAN:
|
||||
case TABLE_TIMESPAN_MSEC:
|
||||
case TABLE_TIMESPAN_DAY:
|
||||
buffer.usec = va_arg(ap, usec_t);
|
||||
data = &buffer.usec;
|
||||
break;
|
||||
@ -1307,6 +1309,7 @@ static int cell_data_compare(TableData *a, size_t index_a, TableData *b, size_t
|
||||
|
||||
case TABLE_TIMESPAN:
|
||||
case TABLE_TIMESPAN_MSEC:
|
||||
case TABLE_TIMESPAN_DAY:
|
||||
return CMP(a->timespan, b->timespan);
|
||||
|
||||
case TABLE_SIZE:
|
||||
@ -1558,7 +1561,8 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
|
||||
}
|
||||
|
||||
case TABLE_TIMESPAN:
|
||||
case TABLE_TIMESPAN_MSEC: {
|
||||
case TABLE_TIMESPAN_MSEC:
|
||||
case TABLE_TIMESPAN_DAY: {
|
||||
_cleanup_free_ char *p = NULL;
|
||||
|
||||
p = new(char, FORMAT_TIMESPAN_MAX);
|
||||
@ -1566,7 +1570,8 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
|
||||
return NULL;
|
||||
|
||||
if (!format_timespan(p, FORMAT_TIMESPAN_MAX, d->timespan,
|
||||
d->type == TABLE_TIMESPAN ? 0 : USEC_PER_MSEC))
|
||||
d->type == TABLE_TIMESPAN ? 0 :
|
||||
d->type == TABLE_TIMESPAN_MSEC ? USEC_PER_MSEC : USEC_PER_DAY))
|
||||
return "-";
|
||||
|
||||
d->formatted = TAKE_PTR(p);
|
||||
@ -2592,6 +2597,7 @@ static int table_data_to_json(TableData *d, JsonVariant **ret) {
|
||||
|
||||
case TABLE_TIMESPAN:
|
||||
case TABLE_TIMESPAN_MSEC:
|
||||
case TABLE_TIMESPAN_DAY:
|
||||
if (d->timespan == USEC_INFINITY)
|
||||
return json_variant_new_null(ret);
|
||||
|
||||
|
@ -26,6 +26,7 @@ typedef enum TableDataType {
|
||||
TABLE_TIMESTAMP_DATE,
|
||||
TABLE_TIMESPAN,
|
||||
TABLE_TIMESPAN_MSEC,
|
||||
TABLE_TIMESPAN_DAY,
|
||||
TABLE_SIZE,
|
||||
TABLE_BPS,
|
||||
TABLE_INT,
|
||||
|
Loading…
x
Reference in New Issue
Block a user