blob: aeaba360b827c218d37c7cbc139e8477a8e03df4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#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;
}
}
|