summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Wieninger <cwieninger (at) gmx (dot) de>2007-05-26 21:27:35 +0000
committerChristian Wieninger <cwieninger (at) gmx (dot) de>2007-05-26 21:27:35 +0000
commit7be7e55411a9556ed08107ff5605bfb5f75435d5 (patch)
treee5ff7fd8fdbf7d5ada173e687e2096bb6bcdeef1
parent1a52bd058120e511f8b64c7651938c424d60c86b (diff)
downloadvdr-plugin-live-7be7e55411a9556ed08107ff5605bfb5f75435d5.tar.gz
vdr-plugin-live-7be7e55411a9556ed08107ff5605bfb5f75435d5.tar.bz2
- allows now smarter input for time, e.g. "1:5" -> "01:05"
-rw-r--r--pages/whats_on.ecpp7
-rw-r--r--tools.cpp21
-rw-r--r--tools.h1
3 files changed, 26 insertions, 3 deletions
diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp
index 5015f67..a28b381 100644
--- a/pages/whats_on.ecpp
+++ b/pages/whats_on.ecpp
@@ -36,6 +36,7 @@ if (type == "now") {
} else if (type == "next") {
head = tr("What's on next?");
} else if (type == "at") {
+ attime = ExpandTimeString(attime);
seektime = GetTimeT(attime);
if (seektime - time(0) + 3600 < 0) // if wanted time is past more then 1h, then use tomorrow
seektime += SECSINDAY;
@@ -51,6 +52,10 @@ if (type == "now") {
<& tooltip.javascript var=("domTT_styleClass") value=("domTTepg") &>
<& pageelems.ajax_js &>
<script type="text/javascript"><!--
+ function init()
+ {
+ document.getElementById("spectime").value = "<$ attime $>";
+ }
function showtime(selection)
{
if (selection.options[selection.selectedIndex].value != "")
@@ -63,7 +68,7 @@ if (type == "now") {
}
//--></script>
</head>
- <body onload="<& pageelems.infobox_start_update &>">
+ <body onload="<& pageelems.infobox_start_update &>; init()">
<& pageelems.logo &>
<& menu active=("whats_on") component=("whats_on.whats_on_actions")>
<div class="inhalt">
diff --git a/tools.cpp b/tools.cpp
index 8dca6df..b47d40a 100644
--- a/tools.cpp
+++ b/tools.cpp
@@ -147,11 +147,28 @@ std::string MD5Hash(std::string const& str)
#define HOURS(x) ((x)/100)
#define MINUTES(x) ((x)%100)
+std::string ExpandTimeString(std::string timestring)
+{
+ string::size_type colonpos = timestring.find(":");
+ if (colonpos == string::npos)
+ {
+ timestring += string(std::max(0,(int)(4 - timestring.size())), '0');
+ timestring = string(timestring.begin(), timestring.begin() + 2) + ":" + string(timestring.begin() + 2, timestring.end());
+ }
+ else
+ {
+ string hours = string(timestring.begin(), timestring.begin() + colonpos);
+ string mins = string(timestring.begin() + colonpos + 1, timestring.end());
+ hours = string(std::max(0,(int)(2 - hours.size())), '0') + hours;
+ mins = string(std::max(0,(int)(2 - mins.size())), '0') + mins;
+ timestring = hours + ":" + mins;
+ }
+ return timestring;
+}
+
time_t GetTimeT(std::string timestring) // timestring in HH:MM
{
timestring = StringReplace(timestring, ":", "");
- if (timestring.size() < 4)
- timestring += string(4 - timestring.size(), '0');
int iTime = lexical_cast< int >( timestring );
struct tm tm_r;
time_t t = time(NULL);
diff --git a/tools.h b/tools.h
index 525df7d..3343b24 100644
--- a/tools.h
+++ b/tools.h
@@ -33,6 +33,7 @@ std::string StringTrim(const std::string& str);
std::string ZeroPad(int number);
std::string MD5Hash(std::string const& str);
time_t GetTimeT(std::string timestring);
+std::string ExpandTimeString(std::string timestring);
struct bad_lexical_cast: std::runtime_error
{