MCPcopy Create free account
hub / github.com/ElementsProject/lightning / json_to_time

Function json_to_time

plugins/offers_offer.c:109–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107};
108
109static const struct time_string *json_to_time(const char *buffer,
110 const jsmntok_t *tok,
111 u32 *mul)
112{
113 static const struct time_string suffixes[] = {
114 { "second", 0, 1 },
115 { "seconds", 0, 1 },
116 { "minute", 0, 60 },
117 { "minutes", 0, 60 },
118 { "hour", 0, 60*60 },
119 { "hours", 0, 60*60 },
120 { "day", 1, 1 },
121 { "days", 1, 1 },
122 { "week", 1, 7 },
123 { "weeks", 1, 7 },
124 { "month", 2, 1 },
125 { "months", 2, 1 },
126 };
127
128 for (size_t i = 0; i < ARRAY_SIZE(suffixes); i++) {
129 if (json_tok_endswith(buffer, tok, suffixes[i].suffix)) {
130 jsmntok_t t = *tok;
131 t.end -= strlen(suffixes[i].suffix);
132 if (!json_to_u32(buffer, &t, mul))
133 return NULL;
134 return suffixes + i;
135 }
136 }
137 return NULL;
138}
139
140static struct command_result *param_recurrence(struct command *cmd,
141 const char *name,

Callers 1

param_recurrenceFunction · 0.85

Calls 2

json_tok_endswithFunction · 0.85
json_to_u32Function · 0.50

Tested by

no test coverage detected