From 78bf26e22bb4d921d0270e64974daceb78130019 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 31 Dec 2010 13:34:36 +0100 Subject: - add ability to select start time --- pages/multischedule.ecpp | 76 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 11 deletions(-) diff --git a/pages/multischedule.ecpp b/pages/multischedule.ecpp index bf2a968..bf05fa6 100644 --- a/pages/multischedule.ecpp +++ b/pages/multischedule.ecpp @@ -32,15 +32,19 @@ struct SchedEntry { }; std::vector channel_groups_names; + std::vector times_names; + std::vector times_start; <%args> - int channel = 1; + unsigned int channel = 0; + unsigned int time_para = 0; <%session scope="global"> bool logged_in(false); <%request scope="page"> - int channel_group=0; + unsigned int channel_group=0; + unsigned int time_selected=0; <%include>page_init.eh <%cpp> @@ -52,6 +56,8 @@ pageTitle = trVDR("Schedule"); throw HtmlError( tr("Couldn't aquire access to channels, please try again later.") ); #define MAX_CHANNELS 5 +#define MAX_DAYS 3 +#define MAX_HOURS 8 #define MINUTES_PER_ROW 5 #define CHARACTERS_PER_ROW 30 @@ -83,7 +89,45 @@ pageTitle = trVDR("Schedule"); if ( channel >= channel_groups_numbers.size() ) channel = channel_groups_numbers.size()-1; channel_group = channel; +{ + // build time list + times_names.clear(); + times_start.clear(); + + // calculate time of midnight (localtime) and convert back to GMT + time_t now = time(NULL); + time_t now_local = time(NULL); + struct tm tm_r; + if ( localtime_r( &now_local, &tm_r ) == 0 ) { + ostringstream builder; + builder << "cannot represent timestamp " << now_local << " as local time"; + throw runtime_error( builder.str() ); + } + tm_r.tm_hour=0; + tm_r.tm_min=0; + tm_r.tm_sec=0; + time_t midnight = mktime( &tm_r ); + // default is now rounded to full hour + times_names.push_back( tr("Now") ); + times_start.push_back( 3600 * ( now /3600 ) ); + + int i =0; + // skip allready passed times + while ( now>midnight+MAX_HOURS*3600*i) + i++; + + for (; i<4*MAX_DAYS ; i++ ) + { + times_names.push_back(FormatDateTime( tr("%A, %x"), midnight + MAX_HOURS*3600*i) + +std::string(" ")+ FormatDateTime( tr("%I:%M %p"), midnight + MAX_HOURS*3600*i) ); + //times_names.push_back("today 0:00"); + times_start.push_back( midnight + MAX_HOURS*3600*i ); + } + if ( time_para >= times_names.size() ) + time_para = times_names.size()-1; + time_selected=time_para; +} <& pageelems.doc_type &> @@ -99,14 +143,12 @@ pageTitle = trVDR("Schedule"); <%cpp> cSchedulesLock schedulesLock; cSchedules const* schedules = cSchedules::Schedules( schedulesLock ); -#if 0 - ReadLock channelsLock( Channels ); - if ( !channelsLock ) - throw HtmlError( tr("Couldn't aquire access to channels, please try again later.") ); -#endif - time_t now = time(NULL) - ::Setup.EPGLinger * 60; - time_t sched_start = 3600 * (now / 3600); // start at a full hour - time_t sched_end = sched_start + 60 * 60 * 24; // 12 hr + + time_t now = time(NULL); + if ( time_para >= times_start.size() ) + time_para = times_start.size()-1; + time_t sched_start = times_start[ time_para ]; + time_t sched_end = sched_start + 60 * 60 * MAX_HOURS; int sched_end_row = ( sched_end - sched_start ) / 60 / MINUTES_PER_ROW; std::list table[MAX_CHANNELS]; string channel_names[ MAX_CHANNELS]; @@ -338,7 +380,7 @@ pageTitle = trVDR("Schedule"); + + % // <& pageelems.ajax_action_href action="switch_channel" tip=(tr("Switch to this channel.")) param=(Channel->GetChannelID()) image="zap.png" alt="" &> -- cgit v1.2.3