Software / code / prosody
Comparison
core/moduleapi.lua @ 13237:59c3d775c7fa
core.moduleapi: Parse period min/max arguments
Allows specifying them the same way as the default and in the config,
for consistency
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 22 Jul 2023 12:08:01 +0200 |
| parent | 13215:b1c2e70de470 |
| child | 13309:113ce2ac73a2 |
comparison
equal
deleted
inserted
replaced
| 13236:9c72f93b7a02 | 13237:59c3d775c7fa |
|---|---|
| 293 if ret < 0 then | 293 if ret < 0 then |
| 294 self:log("debug", "Treating negative period as infinity"); | 294 self:log("debug", "Treating negative period as infinity"); |
| 295 return math.huge; | 295 return math.huge; |
| 296 end | 296 end |
| 297 | 297 |
| 298 if type(min) == "string" then | |
| 299 min = human_io.parse_duration(min); | |
| 300 end | |
| 298 if min and ret < min then | 301 if min and ret < min then |
| 299 self:log("warn", "Config option '%s' out of bounds %g < %g", name, ret, min); | 302 self:log("warn", "Config option '%s' out of bounds %g < %g", name, ret, min); |
| 300 return min; | 303 return min; |
| 304 end | |
| 305 if type(max) == "string" then | |
| 306 max = human_io.parse_duration(max); | |
| 301 end | 307 end |
| 302 if max and ret > max then | 308 if max and ret > max then |
| 303 self:log("warn", "Config option '%s' out of bounds %g > %g", name, ret, max); | 309 self:log("warn", "Config option '%s' out of bounds %g > %g", name, ret, max); |
| 304 return max; | 310 return max; |
| 305 end | 311 end |