summaryrefslogtreecommitdiff
path: root/tools.cpp
diff options
context:
space:
mode:
authorSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-01-05 19:38:54 +0000
committerSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-01-05 19:38:54 +0000
commit45fe6c4b0efcd807dd67bb1bcdc5e104583332ae (patch)
tree3cc0e5741faf0c75497ca216d07def2924c4b13d /tools.cpp
parent14bb52978b82dcb82904cf42d7f33b6a7543f618 (diff)
downloadvdr-plugin-live-45fe6c4b0efcd807dd67bb1bcdc5e104583332ae.tar.gz
vdr-plugin-live-45fe6c4b0efcd807dd67bb1bcdc5e104583332ae.tar.bz2
- moved pagelib back to plugin
- incorporated all code into one shared object
Diffstat (limited to 'tools.cpp')
-rw-r--r--tools.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/tools.cpp b/tools.cpp
new file mode 100644
index 0000000..e1d9a03
--- /dev/null
+++ b/tools.cpp
@@ -0,0 +1,40 @@
+#include <sstream>
+#include <stdexcept>
+#include "live.h"
+#include "setup.h"
+#include "tools.h"
+
+namespace vdrlive {
+
+using namespace std;
+
+string FormatDateTime( char const* format, time_t time )
+{
+ struct tm tm_r;
+ if ( localtime_r( &time, &tm_r ) == 0 ) {
+ ostringstream builder;
+ builder << "cannot represent timestamp " << time << " as local time";
+ throw runtime_error( builder.str() );
+ }
+
+ char result[ 256 ];
+ if ( strftime( result, sizeof( result ), format, &tm_r ) == 0 ) {
+ ostringstream builder;
+ builder << "representation of timestamp " << time << " exceeds " << sizeof( result ) << " bytes";
+ throw runtime_error( builder.str() );
+ }
+ return result;
+}
+
+string StringReplace( string const& text, string const& substring, string const& replacement )
+{
+ string result = text;
+ string::size_type pos = 0;
+ while ( ( pos = result.find( substring, pos ) ) != string::npos ) {
+ result.replace( pos, substring.length(), replacement );
+ pos += replacement.length();
+ }
+ return result;
+}
+
+}