StdAir Logo  0.45.1
C++ Standard Airline IT Object Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SegmentDate.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
13 
14 namespace stdair {
15 
16  // ////////////////////////////////////////////////////////////////////
17  SegmentDate::SegmentDate()
18  : _key (DEFAULT_ORIGIN, DEFAULT_DESTINATION), _parent (NULL),
19  _operatingSegmentDate (NULL) {
20  assert (false);
21  }
22 
23  // ////////////////////////////////////////////////////////////////////
24  SegmentDate::SegmentDate (const SegmentDate&)
25  : _key (DEFAULT_ORIGIN, DEFAULT_DESTINATION), _parent (NULL),
26  _operatingSegmentDate (NULL) {
27  assert (false);
28  }
29 
30  // ////////////////////////////////////////////////////////////////////
31  SegmentDate::SegmentDate (const Key_T& iKey)
32  : _key (iKey), _parent (NULL) ,
33  _operatingSegmentDate (NULL) {
34  }
35 
36  // ////////////////////////////////////////////////////////////////////
38  }
39 
40  // ////////////////////////////////////////////////////////////////////
41  std::string SegmentDate::toString() const {
42  std::ostringstream oStr;
43  oStr << describeKey();
44  return oStr.str();
45  }
46 
47  // ////////////////////////////////////////////////////////////////////
49  // TimeOffset = (OffTime - BoardingTime) + (OffDate - BoardingDate) * 24
50  // - ElapsedTime
51  Duration_T oTimeOffset = (_offTime - _boardingTime);
52  const DateOffset_T& lDateOffset = getDateOffset();
53  const Duration_T lDateOffsetInHours (lDateOffset.days() * 24, 0, 0);
54  oTimeOffset += lDateOffsetInHours - _elapsedTime;
55  return oTimeOffset;
56  }
57 }
58