All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TimePeriodTZ.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/datatype/TimePeriodTZ.cpp
22 
23  \brief A class to represent time period with time zone.
24 */
25 
26 // TerraLib
27 #include "TimeInstantTZ.h"
28 #include "TimePeriodTZ.h"
29 
30 te::dt::TimePeriodTZ::TimePeriodTZ(const TimeInstantTZ& initialTime, const TimeInstantTZ& finalTime)
31  : m_timePeriodTZ(initialTime.getTimeInstantTZ(), finalTime.getTimeInstantTZ())
32 {
33 }
34 
35 te::dt::TimePeriodTZ::TimePeriodTZ(const boost::local_time::local_time_period& t)
36  : m_timePeriodTZ(t)
37 {
38 }
39 
41 {
42  return TimeInstantTZ(m_timePeriodTZ.begin());
43 }
44 
46 {
47  return TimeInstantTZ(m_timePeriodTZ.end());
48 }
49 
51 {
52  return new TimeInstantTZ(m_timePeriodTZ.begin());
53 }
54 
56 {
57  return new TimeInstantTZ(m_timePeriodTZ.end());
58 }
59 
61 {
62  const te::dt::TimePeriodTZ* t = dynamic_cast<const te::dt::TimePeriodTZ*>(&rhs);
63  return m_timePeriodTZ == t->m_timePeriodTZ;
64 }
65 
67 {
68  const te::dt::TimePeriodTZ* t = dynamic_cast<const te::dt::TimePeriodTZ*>(&rhs);
69  return m_timePeriodTZ != t->m_timePeriodTZ;
70 }
71 
73 {
74  const te::dt::TimePeriodTZ* t = dynamic_cast<const te::dt::TimePeriodTZ*>(&rhs);
75  return m_timePeriodTZ < t->m_timePeriodTZ;
76 }
77 
79 {
80  const te::dt::TimePeriodTZ* t = dynamic_cast<const te::dt::TimePeriodTZ*>(&rhs);
81  return m_timePeriodTZ > t->m_timePeriodTZ;
82 }
83 
85 {
86  return new te::dt::TimePeriodTZ(*this);
87 }
88 
89 std::string te::dt::TimePeriodTZ::toString() const
90 {
91  std::string begin(boost::posix_time::to_simple_string(m_timePeriodTZ.begin().utc_time()));
92  //std::string begin(boost::posix_time::to_iso_extended_string(m_timePeriodTZ.begin().utc_time()));
93  //std::string begin(boost::posix_time::to_iso_string(m_timePeriodTZ.begin().utc_time()));
94  begin += m_timePeriodTZ.begin().zone()->to_posix_string();
95 
96  std::string end(boost::posix_time::to_simple_string(m_timePeriodTZ.last().utc_time()));
97  //std::string end(boost::posix_time::to_iso_extended_string(m_timePeriodTZ.last().utc_time()));
98  //std::string end(boost::posix_time::to_iso_string(m_timePeriodTZ.last().utc_time()));
99  end += m_timePeriodTZ.begin().zone()->to_posix_string();
100 
101  return begin + "/" + end;
102 }
103 
105 {
106 }
107 
virtual ~TimePeriodTZ()
Destructor.
TimeInstantTZ getInitialTimeInstant() const
It gets the initial time instant.
bool operator>(const DateTime &rhs) const
Operator >
std::string toString() const
It returns the time period with time zone in the ISO textual format (YYYYMMDDThhmmss±hhmm/YYYYMMDDThh...
DateTimeInstant * getInitialInstant() const
It gets the initial date time instant.
bool operator==(const DateTime &rhs) const
Operator ==.
bool operator!=(const DateTime &rhs) const
Operator !=.
TimeInstantTZ getFinalTimeInstant() const
It gets the final time instant.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
TimePeriodTZ(const TimeInstantTZ &initialTime, const TimeInstantTZ &finalTime)
Constructor.
A class to represent time instant with time zone.
A class to represent time period with time zone.
Definition: TimePeriodTZ.h:54
boost::local_time::local_time_period m_timePeriodTZ
Time period with time zone information.
Definition: TimePeriodTZ.h:183
A class to represent time period with time zone.
AbstractData * clone() const
It returns a clone of this object.
bool operator<(const DateTime &rhs) const
Operator <.
A class to represent time instant with time zone.
Definition: TimeInstantTZ.h:52
DateTimeInstant * getFinalInstant() const
It gets the final date time instant.
An abstract class to represent an instant of date and time.