-- vim:set ft=lua: dofile(mg.script_name:gsub('[^\\/]*$','')..'epg.lua') date=GetVarInt(mg.request_info.query_string,'date',-10000,1000) or GetVarDate(mg.request_info.query_string,'date') or 0 hour=GetVarInt(mg.request_info.query_string,'hour',-1,27) or 4 --hour=-1で現在時刻-MARGIN_HOUR時間を基準 interval=GetVarInt(mg.request_info.query_string,'interval',0,25) or DEF_INTERVAL onid,tsid,sid=GetVarServiceID(mg.request_info.query_string,'id') baseDate=math.floor((utc9Now-4*3600)/24/3600) if date>1000 then date=math.floor(date/24/3600)-baseDate end baseDate=baseDate+date Hour=hour<0 and math.floor(((utc9Now%(24*3600))/3600)-MARGIN_HOUR)%24 or hour if Hour<4-(hour==0 and MARGIN_HOUR or 0) then Hour=Hour+24 end Hour=Hour+interval>29 and 29-interval or Hour baseTime=(baseDate*24+Hour)*3600 NOW=baseTime'..st.service_name..'' or ''), css=EpgCssTemplate(), menu=EpgMenuTemplate(), searchlinks=not SIDE_PANEL } ct.subheader='
\n' ..'\n
\n' ct.side='\n' ..'\n' ..'\n
\n' ctt={} op={service_name=st.service_name} for i=0,6 do table.insert(ctt, '
\n') lastPx=0 total=0 b=edcb.EnumEventInfo({{onid=st.onid, tsid=st.tsid, sid=st.sid}}, {startTime=os.date('!*t',baseTime+(i*24-6)*3600), durationSecond=(interval+6)*3600}) or {} for j,w in ipairs(edcb.EnumEventInfoArchive and edcb.EnumEventInfoArchive({{onid=st.onid, tsid=st.tsid, sid=st.sid}}, {startTime=os.date('!*t',baseTime+(i*24-6)*3600), durationSecond=(interval+6)*3600}) or {}) do w.past=true table.insert(b, w) end table.sort(b, function(a,b) return os.time(a.startTime)0 then table.insert(ctt, '
\n') total=total+startPx-lastPx lastPx=startPx end if endPx-lastPx>0 then op.url='epginfo.html?id='..w.onid..'-'..w.tsid..'-'..w.sid..'-'..(w.past and startTime or w.eid)..'&week='..hrefGene table.insert(ctt, CellTemplate(w, op)) total=total+endPx-lastPx lastPx=endPx end end if total
\n') end table.insert(ctt, '
\n') end table.insert(main, '
\n' .. SidePanelTemplate() ..'
' ..'
\n
\n') for i=0,6 do d=os.date('!*t', ((i+baseDate)*24)*3600) d=d.month..'/'..d.day..'('..({'日','月','火','水','木','金','土'})[d.wday]..')' table.insert(main, ''..d..'\n') end table.insert(main, '
\n' ..'
\n' ..'
\n') for i=Hour,Hour+interval-1 do j=i%24 table.insert(main, '
'..(j<4 and j+24 or j)..'時
') end ct.main=table.concat(main)..(NOW and '
' or '') ..'
\n' ..table.concat(ctt) ..'
\n
\n' ..'
\n' ..'\n' ..'\n' ..'\n' ..'
\n' ..EpgJsTemplate(Hour,NOW) ct=Template(ct) mg.write(ct:Pop(Response(200,'text/html','utf-8',ct.len,ct.gzip)..'\r\n'))