mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-20 13:34:26 +01:00
json: Add timestampt primitives to print timestamps in results
The timestamps are UNIX-Timestamps with 3 decimal places, even though we have the timestamp with nanosecond granularity. This is deliberate choice not to over overload the users :-) Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
fcf133cd0a
commit
06f090c6a5
@@ -368,3 +368,10 @@ void json_add_amount_sat(struct json_stream *result,
|
||||
json_add_member(result, msatfieldname, "\"%s\"",
|
||||
type_to_string(tmpctx, struct amount_msat, &msat));
|
||||
}
|
||||
|
||||
void json_add_timeabs(struct json_stream *result, const char *fieldname,
|
||||
struct timeabs t)
|
||||
{
|
||||
json_add_member(result, fieldname, "%" PRIu64 ".%03" PRIu64,
|
||||
(u64)t.ts.tv_sec, (u64)t.ts.tv_nsec / 1000000);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "config.h"
|
||||
#include <ccan/short_types/short_types.h>
|
||||
#include <ccan/tal/tal.h>
|
||||
#include <ccan/time/time.h>
|
||||
#include <common/amount.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
@@ -170,4 +171,8 @@ enum address_parse_result json_tok_address_scriptpubkey(const tal_t *ctx,
|
||||
const struct chainparams *chainparams,
|
||||
const char *buffer,
|
||||
const jsmntok_t *tok, const u8 **scriptpubkey);
|
||||
|
||||
void json_add_timeabs(struct json_stream *result, const char *fieldname,
|
||||
struct timeabs t);
|
||||
|
||||
#endif /* LIGHTNING_LIGHTNINGD_JSON_H */
|
||||
|
||||
Reference in New Issue
Block a user