util.datetime: Fixes for more liberal timezone parsing - colon and minutes are both (independantly) optional (thanks Zash)

Sat, 27 Nov 2010 01:22:43 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 27 Nov 2010 01:22:43 +0000
changeset 3642
ed80c4c56b9c
parent 3641
3603aeb325de
child 3643
2dc342a13f35

util.datetime: Fixes for more liberal timezone parsing - colon and minutes are both (independantly) optional (thanks Zash)

util/datetime.lua file | annotate | diff | comparison | revisions
--- a/util/datetime.lua	Thu Nov 25 21:47:12 2010 +0100
+++ b/util/datetime.lua	Sat Nov 27 01:22:43 2010 +0000
@@ -41,8 +41,9 @@
 			local time_offset = os_difftime(os_time(os_date("*t")), os_time(os_date("!*t"))); -- to deal with local timezone
 			local tzd_offset = 0;
 			if tzd ~= "" and tzd ~= "Z" then
-				local sign, h, m = tzd:match("([+%-])(%d%d):(%d%d)");
+				local sign, h, m = tzd:match("([+%-])(%d%d):?(%d*)");
 				if not sign then return; end
+				if #m ~= 2 then m = "0"; end
 				h, m = tonumber(h), tonumber(m);
 				tzd_offset = h * 60 * 60 + m * 60;
 				if sign == "-" then tzd_offset = -tzd_offset; end

mercurial