Comparison

util/datetime.lua @ 12633:5d8b0e0b9d48

util.datetime: Remove a line No idea why the locals were declared on a line by itself. Perhaps line length considerations? But saving 6 characters in width by adding a whole line with 47 characters seems excessive. This is still within the 150 character limit set by .luacheckrc
author Kim Alvefur <zash@zash.se>
date Wed, 17 Aug 2022 18:07:31 +0200
parent 12629:4c1d3f817063
comparison
equal deleted inserted replaced
12632:70ae68bb0aa5 12633:5d8b0e0b9d48
44 return os_date("!%Y%m%dT%H:%M:%S", t and floor(t) or nil); 44 return os_date("!%Y%m%dT%H:%M:%S", t and floor(t) or nil);
45 end 45 end
46 46
47 local function parse(s) 47 local function parse(s)
48 if s then 48 if s then
49 local year, month, day, hour, min, sec, tzd; 49 local year, month, day, hour, min, sec, tzd = s:match("^(%d%d%d%d)%-?(%d%d)%-?(%d%d)T(%d%d):(%d%d):(%d%d%.?%d*)([Z+%-]?.*)$");
50 year, month, day, hour, min, sec, tzd = s:match("^(%d%d%d%d)%-?(%d%d)%-?(%d%d)T(%d%d):(%d%d):(%d%d%.?%d*)([Z+%-]?.*)$");
51 if year then 50 if year then
52 local now = os_time(); 51 local now = os_time();
53 local time_offset = os_difftime(os_time(os_date("*t", now)), os_time(os_date("!*t", now))); -- to deal with local timezone 52 local time_offset = os_difftime(os_time(os_date("*t", now)), os_time(os_date("!*t", now))); -- to deal with local timezone
54 local tzd_offset = 0; 53 local tzd_offset = 0;
55 if tzd ~= "" and tzd ~= "Z" then 54 if tzd ~= "" and tzd ~= "Z" then