Diff

mod_http_muc_log/mod_http_muc_log.lua @ 2836:52a7c0f6aea1

mod_http_muc_log: Add a function for rounding timestamps down to midnight
author Kim Alvefur <zash@zash.se>
date Sat, 18 Nov 2017 20:38:30 +0100
parent 2826:ed26608920d4
child 2837:bd5eb429ebab
line wrap: on
line diff
--- 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