All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DatePeriod.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/DatePeriod.cpp
22 
23  \brief A class to represent date period.
24 */
25 
26 // TerraLib
27 #include "Date.h"
28 #include "DatePeriod.h"
29 
31  : m_datePeriod(boost::gregorian::date(), boost::gregorian::date())
32 {
33 }
34 
35 te::dt::DatePeriod::DatePeriod(const Date& initialDate, const Date& finalDate)
36  : m_datePeriod(initialDate.getDate(), finalDate.getDate())
37 {
38 }
39 
40 te::dt::DatePeriod::DatePeriod(const boost::gregorian::date_period& dp)
41  : m_datePeriod(dp)
42 {
43 }
44 
45 te::dt::DatePeriod::DatePeriod(const boost::gregorian::date& begin, const boost::gregorian::date& end)
46  : m_datePeriod(begin, end)
47 {
48 }
49 
51 {
52  return Date(m_datePeriod.begin());
53 }
54 
56 {
57  return Date(m_datePeriod.end());
58 }
59 
61 {
62  return new Date(m_datePeriod.begin());
63 }
64 
66 {
67  return new Date(m_datePeriod.end());
68 }
69 
71 {
72  const te::dt::DatePeriod* t = dynamic_cast<const te::dt::DatePeriod*>(&rhs);
73  return m_datePeriod == t->m_datePeriod;
74 }
75 
77 {
78  const te::dt::DatePeriod* t = dynamic_cast<const te::dt::DatePeriod*>(&rhs);
79  return m_datePeriod != t->m_datePeriod;
80 }
81 
83 {
84  const te::dt::DatePeriod* t = dynamic_cast<const te::dt::DatePeriod*>(&rhs);
85  return m_datePeriod < t->m_datePeriod;
86 }
87 
89 {
90  const te::dt::DatePeriod* t = dynamic_cast<const te::dt::DatePeriod*>(&rhs);
91  return m_datePeriod > t->m_datePeriod;
92 }
93 
95 {
96  return new te::dt::DatePeriod(*this);
97 }
98 
99 std::string te::dt::DatePeriod::toString() const
100 {
101  return boost::gregorian::to_simple_string(m_datePeriod);
102  //return boost::gregorian::to_iso_extended_string(m_datePeriod);
103  //return boost::gregorian::to_iso_string(m_datePeriod);
104 }
105 
107 {
108 }
109 
110 
111 
DateTimeInstant * getFinalInstant() const
It gets the final date time instant.
Definition: DatePeriod.cpp:65
bool operator!=(const DateTime &rhs) const
Operator !=.
Definition: DatePeriod.cpp:76
Date getInitialDate() const
It gets the initial date.
Definition: DatePeriod.cpp:50
bool operator==(const DateTime &rhs) const
Operator ==.
Definition: DatePeriod.cpp:70
DatePeriod()
Constructor.
Definition: DatePeriod.cpp:30
A class to represent date period.
AbstractData * clone() const
It returns a clone of this object.
Definition: DatePeriod.cpp:94
A base class for date data types.
Definition: Date.h:53
bool operator<(const DateTime &rhs) const
Operator <.
Definition: DatePeriod.cpp:82
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
boost::gregorian::date_period m_datePeriod
The internal date period information.
Definition: DatePeriod.h:191
DateTimeInstant * getInitialInstant() const
It gets the initial date time instant.
Definition: DatePeriod.cpp:60
bool operator>(const DateTime &rhs) const
Operator >
Definition: DatePeriod.cpp:88
virtual ~DatePeriod()
Destructor.
Definition: DatePeriod.cpp:106
A class to represent date period based on the Gregorian Calendar.
Definition: DatePeriod.h:51
Date getFinalDate() const
It gets the final date.
Definition: DatePeriod.cpp:55
std::string toString() const
It returns the date period in the ISO textual format (YYYYMMDDTYYYYMMDD).
Definition: DatePeriod.cpp:99
An abstract class to represent an instant of date and time.
A base class for date data types.