Changeset

392:369e665ae471

mod_muc_log_http: Show proper time period in the headline.
author Waqas Hussain <waqas20@gmail.com>
date Mon, 25 Jul 2011 02:21:40 +0500
parents 391:99e7ef4fc7d2
children 393:20ef4a289d7d
files mod_muc_log_http/muc_log_http/mod_muc_log_http.lua
diffstat 1 files changed, 7 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_log_http/muc_log_http/mod_muc_log_http.lua	Mon Jul 25 02:21:40 2011 +0500
+++ b/mod_muc_log_http/muc_log_http/mod_muc_log_http.lua	Mon Jul 25 02:21:40 2011 +0500
@@ -291,9 +291,7 @@
 		end
 	end
 	if attributes ~= nil and room ~= nil then
-		local first = 1;
 		local alreadyDoneYears = {};
-		local temptime = {day=0, month=0, year=0};
 		topic = room._data.subject or "(no subject)"
 		if topic:len() > 135 then
 			topic = topic:sub(1, topic:find(" ", 120)) .. " ..."
@@ -303,19 +301,14 @@
 		table.sort(folders);
 		for _, folder in ipairs(folders) do
 			local year, month, day = folder:match("^(%d%d)(%d%d)(%d%d)");
-			if year ~= nil and alreadyDoneYears[year] == nil then
-				temptime.day = tonumber(day)
-				temptime.month = tonumber(month)
-				temptime.year = 2000 + tonumber(year)
-				if first == 1 then
-					to = tostring(os_date("%B %Y", os_time(temptime)))
-					first = 0
+			if year then
+				to = tostring(os_date("%B %Y", os_time({ day=tonumber(day), month=tonumber(month), year=2000+tonumber(year) })));
+				if since == "" then since = to; end
+				if not alreadyDoneYears[year] then
+					module:log("debug", "creating overview for: %s", to);
+					days = createYear(year, {callback=perDayCallback, path=path, room=node}) .. days;
+					alreadyDoneYears[year] = true;
 				end
-
-				since = tostring(os_date("%B %Y", os_time(temptime)))
-				module:log("debug", "creating overview for: " .. tostring(since))
-				days = createYear(year, {callback=perDayCallback, path=path, room=node}) .. days;
-				alreadyDoneYears[year] = true;
 			end
 		end
 	end