Statistics
| Branch: | Tag: | Revision:

dvbd / src / recording.cpp @ 59be6a47

History | View | Annotate | Download (1.74 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 "stringutil.h"
22
#include "recording.h"
23

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

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

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

    
35
  o << job << " " << uid << " " << dateTime << " " << type << " " 
36
    << escapeWS(channel) << " " << ::toString(convertToPS) << " "
37
    << duration << " " << priority << " " << escapeWS(path);
38

    
39
  return o;
40
}
41

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

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

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

    
59
  return i;
60
}
61