ndp.lua

changeset 6
a8bbbfdd12db
parent 5
3eee607e57e8
child 7
7f095ddcfd54
--- a/ndp.lua	Sun Jun 21 18:47:57 2009 +0100
+++ b/ndp.lua	Sun Jun 21 18:48:40 2009 +0100
@@ -86,6 +86,22 @@
 			return time;
 		end
 	end
+	return;
+end
+
+local function find_next_month_by_name(time, month_name)
+	month_name = month_name:lower():gsub("^.", string.upper); -- Normalize
+	
+	local split_time = os.date("*t", time);
+	for i=1,13 do
+		split_time.month = split_time.month + 1;
+		if split_time.month == 13 then split_time.month = 1; end
+		
+		time = os.time(split_time);
+		if os.date("%B", time) == month_name then
+			return time;
+		end
+	end
 	
 	return;
 end

mercurial