fix delimiter for .
This commit is contained in:
parent
a7ddb71ac5
commit
b85e2429f5
@ -1,4 +1,5 @@
|
|||||||
local db = require("lapis.db")
|
local db = require("lapis.db")
|
||||||
|
local to_json = require("lapis.util").to_json
|
||||||
|
|
||||||
local autoload = require("lapis.util").autoload
|
local autoload = require("lapis.util").autoload
|
||||||
local models = autoload("models")
|
local models = autoload("models")
|
||||||
@ -70,17 +71,35 @@ function Splhandler(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- we have to split the `hr:min:sec` and `month/day/year` strings from SPL
|
-- we have to split the `hr:min:sec` and `month/day/year` strings from SPL
|
||||||
local function Split(s, delimiter)
|
-- and since SPL uses both "." and "-" for dates .. somehow .. we have to do more dirty tricks ..
|
||||||
local result = {}
|
local function Split(s, delimiters)
|
||||||
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
|
|
||||||
table.insert(result, match)
|
for i, delimiter in ipairs(delimiters) do
|
||||||
|
print(delimiter)
|
||||||
|
local result = {}
|
||||||
|
|
||||||
|
if delimiter == "." then
|
||||||
|
for match in string.gmatch(s, "[^%.]+") do
|
||||||
|
table.insert(result, match)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
|
||||||
|
table.insert(result, match)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if table.getn(result) == 3 then
|
||||||
|
return result
|
||||||
|
else
|
||||||
|
print("something is wrong: ".. s)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
return result
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local split_airtime = Split(airtime, ":")
|
local split_airtime = Split(airtime, {":"})
|
||||||
local airtime_hr, airtime_min, airtime_sec = split_airtime[1], split_airtime[2], split_airtime[3]
|
local airtime_hr, airtime_min, airtime_sec = split_airtime[1], split_airtime[2], split_airtime[3]
|
||||||
local split_airdate = Split(airdate, "/")
|
local split_airdate = Split(airdate, {"-", "."})
|
||||||
local airdate_month, airdate_day, airdate_year = split_airdate[1], split_airdate[2], split_airdate[3]
|
local airdate_month, airdate_day, airdate_year = split_airdate[1], split_airdate[2], split_airdate[3]
|
||||||
local airtime_stamp = os.time{year=airdate_year, month=airdate_month, day=airdate_day, hour=airtime_hr, min=airtime_min, sec=airtime_sec}
|
local airtime_stamp = os.time{year=airdate_year, month=airdate_month, day=airdate_day, hour=airtime_hr, min=airtime_min, sec=airtime_sec}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user