acpi:QEMU0002: 6ˆl–Ü4ý( ©¨‰P@ ª7 À8¦-ÿ�þ](Y¶ÈÝoùÍ „dBmÿÌËÊ?÷--------------------------------------------------------------------------------------- -- Module for date and time calculations -- -- Version 2.1.1 -- Copyright (C) 2006, by Jas Latrix (jastejada@yahoo.com) -- Copyright (C) 2013-2014, by Thijs Schreijer -- Licensed under MIT, http://opensource.org/licenses/MIT --[[ CONSTANTS ]]-- local HOURPERDAY = 24 local MINPERHOUR = 60 local MINPERDAY = 1440 -- 24*60 local SECPERMIN = 60 local SECPERHOUR = 3600 -- 60*60 local SECPERDAY = 86400 -- 24*60*60 local TICKSPERSEC = 1000000 local TICKSPERDAY = 86400000000 local TICKSPERHOUR = 3600000000 local TICKSPERMIN = 60000000 local DAYNUM_MAX = 365242500 -- Sat Jan 01 1000000 00:00:00 local DAYNUM_MIN = -365242500 -- Mon Jan 01 1000000 BCE 00:00:00 local DAYNUM_DEF = 0 -- Mon Jan 01 0001 00:00:00 local _; --[[ LOCAL ARE FASTER ]]-- local type = type local pairs = pairs local error = error local assert = assert local tonumber = tonumber local tostring = tostring local string = string local math = math local os = os local unpack = unpack or table.unpack local pack = table.pack or function(...) return { n = select('#', ...), ... } end local setmetatable = setmetatable local getmetatable = getmetatable --[[ EXTRA FUNCTIONS ]]-- local fmt = string.format local lwr = string.lower local upr = string.upper local rep = string.rep local len = string.len local sub = string.sub local gsub = string.gsub local gmatch = string.gmatch or string.gfind local find = string.find local ostime = os.time local osdate = os.date local floor = math.floor local ceil = math.ceil local abs = math.abs -- removes the decimal part of a number local function fix(n) n = tonumber(n) return n and ((n > 0 and floor or ceil)(n)) end -- returns the modulo n % d; local function mod(n,d) return n - d*floor(n/d) end -- rounds a number; local function round(n, d) d=d^10 return floor((n*d)+.5)/d end -- rounds a number to whole; local function whole(n)return floor(n+.5)end -- is `str` in string list `tbl`, `ml` is the minimun len local function inlist(str, tbl, ml, tn) local sl = len(str) if sl < (ml or 0) then return nil end str = lwr(str) for k, v in pairs(tbl) do if str == lwr(sub(v, 1, sl)) then if tn then tn[0] = k end return k end end end local function fnil() end local function fret(x)return x;end --[[ DATE FUNCTIONS ]]-- local DATE_EPOCH -- to be set later local sl_weekdays = { [0]="Sunday",[1]="Monday",[2]="Tuesday",[3]="Wednesday",[4]="Thursday",[5]="Friday",[6]="Saturday", [7]="Sun",[8]="Mon",[9]="Tue",[10]="Wed",[11]="Thu",[12]="Fri",[13]="Sat", } local sl_meridian = {[-1]="AM", [1]="PM"} local sl_months = { [00]="January", [01]="February", [02]="March", [03]="April", [04]="May", [05]="June", [06]="July", [07]="August", [08]="September", [09]="October", [10]="November", [11]="December", [12]="Jan", [13]="Feb", [14]="Mar", [15]="Apr", [16]="May", [17]="Jun", [18]="Jul", [19]="Aug", [20]="Sep", [21]="Oct", [22]="Nov", [23]="Dec", } -- added the '.2' to avoid collision, use `fix` to remove local sl_timezone = { [000]="utc", [0.2]="gmt", [300]="est", [240]="edt", [360]="cst", [300.2]="cdt", [420]="mst", [360.2]="mdt", [480]="pst", [420.2]="pdt", } -- set the day fraction resolution local function setticks(t) TICKSPERSEC = t; TICKSPERDAY = SECPERDAY*TICKSPERSEC TICKSPERHOUR= SECPERHOUR*TICKSPERSEC TICKSPERMIN = SECPERMIN*TICKSPERSEC end -- is year y leap year? local function isleapyear(y) -- y must be int! return (mod(y, 4) == 0 and (mod(y, 100) ~= 0 or mod(y, 400) == 0)) end -- day since year 0 local function dayfromyear(y) -- y must be int! return 365*y + floor(y/4) - floor(y/100) + floor(y/400) end -- day number from date, month is zero