mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
rpc: adds json_add_timeiso helper
This commit is contained in:
committed by
neil saitug
parent
67f4970eb1
commit
4d765003dd
@@ -827,6 +827,22 @@ void json_add_time(struct json_stream *result, const char *fieldname,
|
||||
json_add_string(result, fieldname, timebuf);
|
||||
}
|
||||
|
||||
void json_add_timeiso(struct json_stream *result,
|
||||
const char *fieldname,
|
||||
struct timeabs *time)
|
||||
{
|
||||
char iso8601_msec_fmt[sizeof("YYYY-mm-ddTHH:MM:SS.%03dZ")];
|
||||
char iso8601_s[sizeof("YYYY-mm-ddTHH:MM:SS.nnnZ")];
|
||||
|
||||
strftime(iso8601_msec_fmt, sizeof(iso8601_msec_fmt),
|
||||
"%FT%T.%%03dZ", gmtime(&time->ts.tv_sec));
|
||||
snprintf(iso8601_s, sizeof(iso8601_s),
|
||||
iso8601_msec_fmt, (int) time->ts.tv_nsec / 1000000);
|
||||
|
||||
json_add_string(result, fieldname, iso8601_s);
|
||||
}
|
||||
|
||||
|
||||
void json_add_tok(struct json_stream *result, const char *fieldname,
|
||||
const jsmntok_t *tok, const char *buffer)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user