From 9ffb94a275c285bb70d9e21037c882956bb6001e Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Fri, 11 Feb 2011 22:31:46 +0200 Subject: Unified date formatting and added recording duration format into translations. --- tools.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tools.cpp') 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; -- cgit v1.2.3