* libs/http: removed caching in http.protocol.date

This commit is contained in:
Jo-Philipp Wich 2008-06-27 20:48:11 +00:00
parent 289b8fc1b6
commit 3eefe8a8e2

View file

@ -15,10 +15,6 @@ $Id$
module("luci.http.protocol.date", package.seeall)
local ucache = { }
local hcache = { }
MONTHS = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec"
@ -155,7 +151,6 @@ end
-- Convert a HTTP date to unixtime
function to_unix(date)
if not ucache[date] then
local wd, day, mon, yr, hr, min, sec, tz = date:match(
"([A-Z][a-z][a-z]), ([0-9]+) " ..
"([A-Z][a-z][a-z]) ([0-9]+) " ..
@ -174,7 +169,7 @@ function to_unix(date)
end
-- convert to epoch time
ucache[date] = tz_offset(tz) + os.time( {
return tz_offset(tz) + os.time( {
year = yr,
month = month,
day = day,
@ -183,18 +178,13 @@ function to_unix(date)
sec = sec
} )
end
end
return ucache[date] or 0
return 0
end
-- Convert a unixtime to HTTP date
function to_http(time)
if not hcache[time] then
hcache[time] = os.date( "%a, %d %b %Y %H:%M:%S GMT", time )
end
return hcache[time]
return os.date( "%a, %d %b %Y %H:%M:%S GMT", time )
end
-- Compare two dates