X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=lib%2Ftable.c;h=46281703fedc23134bd965750fac4fe4a63b1096;hb=ca7e7bee86b4ee821d61b58bf15c89a9d8a3cb30;hp=266c4105e2a22ea3fe15dabb92ea0d9667f957a2;hpb=9b6937eb1f53e9901f0438b2521b98d24bc047b5;p=cascardo%2Fovs.git diff --git a/lib/table.c b/lib/table.c index 266c4105e..46281703f 100644 --- a/lib/table.c +++ b/lib/table.c @@ -218,22 +218,19 @@ table_print_table_line__(struct ds *line) ds_clear(line); } -static void -table_format_timestamp__(char *s, size_t size) +static char * +table_format_timestamp__(void) { - time_t now = time_wall(); - struct tm tm; - strftime(s, size, "%Y-%m-%d %H:%M:%S", gmtime_r(&now, &tm)); + return xastrftime_msec("%Y-%m-%d %H:%M:%S.###", time_wall_msec(), true); } static void table_print_timestamp__(const struct table *table) { if (table->timestamp) { - char s[32]; - - table_format_timestamp__(s, sizeof s); + char *s = table_format_timestamp__(); puts(s); + free(s); } } @@ -500,10 +497,9 @@ table_print_json__(const struct table *table, const struct table_style *style) json_object_put_string(json, "caption", table->caption); } if (table->timestamp) { - char s[32]; - - table_format_timestamp__(s, sizeof s); + char *s = table_format_timestamp__(); json_object_put_string(json, "time", s); + free(s); } headings = json_array_create_empty();