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

Function json_to_time

plugins/offers_offer.c:117–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115};
116
117static const struct time_string *json_to_time(const char *buffer,
118 const jsmntok_t *tok,
119 u32 *mul)
120{
121 static const struct time_string suffixes[] = {
122 { "second", 0, 1 },
123 { "seconds", 0, 1 },
124 { "minute", 0, 60 },
125 { "minutes", 0, 60 },
126 { "hour", 0, 60*60 },
127 { "hours", 0, 60*60 },
128 { "day", 1, 1 },
129 { "days", 1, 1 },
130 { "week", 1, 7 },
131 { "weeks", 1, 7 },
132 { "month", 2, 1 },
133 { "months", 2, 1 },
134 { "year", 3, 1 },
135 { "years", 3, 1 },
136 };
137
138 for (size_t i = 0; i < ARRAY_SIZE(suffixes); i++) {
139 if (json_tok_endswith(buffer, tok, suffixes[i].suffix)) {
140 jsmntok_t t = *tok;
141 t.end -= strlen(suffixes[i].suffix);
142 if (!json_to_u32(buffer, &t, mul))
143 return NULL;
144 return suffixes + i;
145 }
146 }
147 return NULL;
148}
149
150static struct command_result *param_recurrence(struct command *cmd,
151 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