summaryrefslogtreecommitdiffhomepage
path: root/libs/http/luasrc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-06-27 20:48:11 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-06-27 20:48:11 +0000
commit3eefe8a8e2f9270ffc7b83744f692ee34852e4a1 (patch)
treeab3273134644881374d890ea2618f5f06fb13ddd /libs/http/luasrc
parent289b8fc1b6b41829c6077893f9dd1d7181551332 (diff)
* libs/http: removed caching in http.protocol.date
Diffstat (limited to 'libs/http/luasrc')
-rw-r--r--libs/http/luasrc/http/protocol/date.lua62
1 files changed, 26 insertions, 36 deletions
diff --git a/libs/http/luasrc/http/protocol/date.lua b/libs/http/luasrc/http/protocol/date.lua
index a7edcfd025..d403604945 100644
--- a/libs/http/luasrc/http/protocol/date.lua
+++ b/libs/http/luasrc/http/protocol/date.lua
@@ -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,46 +151,40 @@ 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]+) " ..
- "([0-9]+):([0-9]+):([0-9]+) " ..
- "([A-Z0-9%+%-]+)"
- )
-
- if day and mon and yr and hr and min and sec then
- -- find month
- local month = 1
- for i = 1, 12 do
- if MONTHS[i] == mon then
- month = i
- break
- end
+ 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]+) " ..
+ "([0-9]+):([0-9]+):([0-9]+) " ..
+ "([A-Z0-9%+%-]+)"
+ )
+
+ if day and mon and yr and hr and min and sec then
+ -- find month
+ local month = 1
+ for i = 1, 12 do
+ if MONTHS[i] == mon then
+ month = i
+ break
end
-
- -- convert to epoch time
- ucache[date] = tz_offset(tz) + os.time( {
- year = yr,
- month = month,
- day = day,
- hour = hr,
- min = min,
- sec = sec
- } )
end
+
+ -- convert to epoch time
+ return tz_offset(tz) + os.time( {
+ year = yr,
+ month = month,
+ day = day,
+ hour = hr,
+ min = min,
+ sec = sec
+ } )
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