summaryrefslogtreecommitdiff
path: root/tools.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools.cpp')
-rw-r--r--tools.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools.cpp b/tools.cpp
index a1ed4ee..35c14e8 100644
--- a/tools.cpp
+++ b/tools.cpp
@@ -51,6 +51,17 @@ istream& operator>>( istream& is, tChannelID& ret )
namespace vdrlive {
+ string FormatDuration( char const* format, int duration )
+ {
+ char result[ 32 ];
+ if ( snprintf(result, sizeof(result), format, duration) < 0 ) {
+ ostringstream builder;
+ builder << "cannot represent duration " << duration << " as requested";
+ throw runtime_error( builder.str() );
+ }
+ return result;
+ }
+
string FormatDateTime( char const* format, time_t time )
{
struct tm tm_r;