X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Ftable.c;h=46281703fedc23134bd965750fac4fe4a63b1096;hb=ac60863f78e412004c5b69f5a64a49bc6f0bc46d;hp=15bcec8b579df57160afd9cdcad29129370f8bc5;hpb=d1673b006d53fdea72c0744e835362ed1917f879;p=sliver-openvswitch.git diff --git a/lib/table.c b/lib/table.c index 15bcec8b5..46281703f 100644 --- a/lib/table.c +++ b/lib/table.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc. + * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -218,21 +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(); - strftime(s, size, "%Y-%m-%d %H:%M:%S", gmtime(&now)); + 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); } } @@ -499,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();