Statistics
| Branch: | Tag: | Revision:

dvbd / recording.cpp @ bfdb7446

History | View | Annotate | Download (1.62 KB)

1
/*
2
  Copyright 2003 John Knottenbelt
3
  
4
  This program is free software; you can redistribute it and/or modify
5
  it under the terms of the GNU General Public License as published by
6
  the Free Software Foundation; either version 2 of the License, or
7
  (at your option) any later version.
8
 
9
  This program is distributed in the hope that it will be useful,
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
  GNU General Public License for more details.
13
 
14
  You should have received a copy of the GNU General Public License
15
  along with this program; if not, write to the Free Software
16
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
17
*/
18

    
19
#include "config.h"
20
#include "utils.h"
21
#include "recording.h"
22

    
23
Recording::~Recording()
24
{
25
}
26

    
27
std::ostream& Recording::printOn(std::ostream &o) const
28
{
29
  char dateTime[128];
30

    
31
  strftime(dateTime, sizeof(dateTime), "%Y-%m-%d %H:%M:%S", 
32
           localtime(&startTime));
33

    
34
  o << job << " " << uid << " " << dateTime << " " << type << " " 
35
    << escapeWS(channel) << " " 
36
    << duration << " " << priority << " " << escapeWS(path);
37

    
38
  return o;
39
}
40

    
41
std::istream &operator >> (std::istream &i, Recording &r)
42
{
43
  std::string datePart, timePart, channel, path;
44

    
45
  i >> r.job 
46
    >> r.uid >> datePart >> timePart >> r.type >> channel
47
    >> r.duration >> r.priority >> path;
48

    
49
  r.channel = unescapeWS(channel);
50
  r.path = unescapeWS(path);
51
  
52
  std::string dateTime = datePart + " " + timePart;
53
  struct tm tm;
54
  if (strptime(dateTime.c_str(), "%Y-%m-%d %H:%M:%S", &tm) != NULL)
55
    r.startTime = mktime(&tm);
56

    
57
  return i;
58
}
59