From 3a4d59c9ac7226432120633ad394464d37e5f497 Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Fri, 25 May 2007 16:58:56 +0000 Subject: - first version of "userdef. times" in "What's on?" --- tools.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tools.cpp') diff --git a/tools.cpp b/tools.cpp index da3956f..a75068f 100644 --- a/tools.cpp +++ b/tools.cpp @@ -144,4 +144,19 @@ std::string MD5Hash(std::string const& str) return hashStr.str(); } +#define HOURS(x) ((x)/100) +#define MINUTES(x) ((x)%100) + +time_t GetTimeT(std::string timestring) // timestring in HH:MM +{ + timestring = StringReplace(timestring, ":", ""); + int iTime = lexical_cast< int >( timestring ); + struct tm tm_r; + time_t t = time(NULL); + tm* tmnow = localtime_r(&t, &tm_r); + tmnow->tm_hour = HOURS(iTime); + tmnow->tm_min = MINUTES(iTime); + return mktime(tmnow); +} + } // namespace vdrlive -- cgit v1.2.3