# HG changeset patch # User Kim Alvefur # Date 1511033910 -3600 # Node ID 52a7c0f6aea15f0dd6eec48b37f5f648ce22c552 # Parent b69ef062806e9abd01216e5c20956ac561afe0dd mod_http_muc_log: Add a function for rounding timestamps down to midnight diff -r b69ef062806e -r 52a7c0f6aea1 mod_http_muc_log/mod_http_muc_log.lua --- a/mod_http_muc_log/mod_http_muc_log.lua Sat Nov 18 13:55:47 2017 +0100 +++ b/mod_http_muc_log/mod_http_muc_log.lua Sat Nov 18 20:38:30 2017 +0100 @@ -65,6 +65,9 @@ local function time(t) return os_time(t) + t_diff; end +local function date_floor(t) + return t - t % 86400; +end -- Fetch one item local function find_once(room, query, retval) @@ -113,7 +116,7 @@ if not when then break; end local t = os_date("!*t", when); dates:set(t.year, t.month, t.day, when ); - next_day = when + (86400 - (when % 86400)); + next_day = date_floor(when) + 86400; until not next_day; end