Loading...
Searching...
No Matches
DatePeriod.h
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.h
22
23 \brief A class to represent date period.
24*/
25
26#ifndef __TERRALIB_DATATYPE_INTERNAL_DATEPERIOD_H
27#define __TERRALIB_DATATYPE_INTERNAL_DATEPERIOD_H
28
29// TerraLib
30#include "DateTimePeriod.h"
31
32// Boost
33#include <boost/date_time/gregorian/gregorian_types.hpp>
34
35namespace te
36{
37 namespace dt
38 {
39 /*!
40 \class DatePeriod
41
42 \brief A class to represent date period based on the Gregorian Calendar.
43
44 A class to represent date period based on the Gregorian Calendar.
45 A date period represents a range between two dates. Internally,
46 it uses the datetime boost library to represent gregorian date period,
47 by using the data type boost::gregorian::date_period.
48
49 \sa DateTime, Date, DateDuration, TimeDuration, TimeInstant, TimeInstantTZ, TimePeriod, TimePeriodTZ
50 */
52 {
53 public:
54
55 /*! \brief Constructor. */
57
58 /*!
59 \brief Constructor.
60
61 \param initialDate An initial gregorian date.
62 \param finalDate An final gregorian date.
63 */
64 DatePeriod(const Date& initialDate, const Date& finalDate);
65
66 /*!
67 \brief Constructor.
68
69 \param dp A date period based on the Gregorian Calendar.
70 */
71 DatePeriod(const boost::gregorian::date_period& dp);
72
73 /*!
74 \brief It creates a period as [begin, end).
75
76 \param begin The initial date.
77 \param begin The final date.
78 */
79 DatePeriod(const boost::gregorian::date& begin, const boost::gregorian::date& end);
80
81 /*!
82 \brief It returns the boost date period type.
83
84 \return The boost date period type.
85 */
86 const boost::gregorian::date_period& getDatePeriod() const { return m_datePeriod; }
87
88 /*!
89 \brief It returns the boost date period type.
90
91 \return The boost date period type.
92 */
93 boost::gregorian::date_period& getDatePeriod() { return m_datePeriod; }
94
95 /*!
96 \brief It gets the initial date.
97
98 \return The initial date
99 */
101
102 /*!
103 \brief It gets the final date.
104
105 \return The final date
106 */
108
109 /*!
110 \brief It gets the initial date time instant.
111
112 \return The initial time instant
113
114 \note The caller will take the ownership of the returned pointer.
115 */
117
118 /*!
119 \brief It gets the final date time instant.
120
121 \return The final time instant
122
123 \note The caller will take the ownership of the returned pointer.
124 */
126
127 /*!
128 \brief Operator ==
129
130 \param rhs The date period to be compared.
131
132 \return It returns true if the two date periods are equal. Otherwise, it returns false.
133 */
134 bool operator==(const DateTime& rhs) const;
135
136 /*!
137 \brief Operator !=
138
139 \param rhs The date period to be compared.
140
141 \return It returns true if the two date periods are not equal. Otherwise, it returns false.
142 */
143 bool operator!=(const DateTime& rhs) const;
144
145 /*!
146 \brief Operator <
147
148 \param rhs The right side date period to be compared.
149
150 \return It returns true if the right side date period is greater than the lefth side one. Otherwise, it returns false.
151 */
152 bool operator<(const DateTime& rhs) const;
153
154 /*!
155 \brief Operator >
156
157 \param rhs The right side date period to be compared.
158
159 \return It returns true if the right side date period is less than the lefth side one. Otherwise, it returns false.
160 */
161 bool operator>(const DateTime& rhs) const;
162
163 /*!
164 \brief It returns a clone of this object.
165
166 \return A clone of this object.
167 */
169
170 /*!
171 \brief It returns the date period in the ISO textual format (YYYYMMDDTYYYYMMDD).
172
173 \return The date period in the ISO textual format (YYYYMMDDTYYYYMMDD).
174 */
175 std::string toString() const;
176
177 /*!
178 \brief It returns the subtype of the date and time type.
179
180 \return The subtype of the date and time type.
181 */
183
184 /*!
185 \brief Destructor.
186 */
187 virtual ~DatePeriod();
188
189 protected:
190
191 boost::gregorian::date_period m_datePeriod; //!< The internal date period information.
192 };
193 } // end namespace dt
194} // end namespace te
195
196#endif // __TERRALIB_DATATYPE_INTERNAL_DATEPERIOD_H
197
An abstract class to represent a period of date and time.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:56
A class to represent date period based on the Gregorian Calendar.
Definition: DatePeriod.h:52
DatePeriod(const boost::gregorian::date_period &dp)
Constructor.
DatePeriod(const boost::gregorian::date &begin, const boost::gregorian::date &end)
It creates a period as [begin, end).
bool operator!=(const DateTime &rhs) const
Operator !=.
DatePeriod()
Constructor.
DateTimeInstant * getInitialInstant() const
It gets the initial date time instant.
AbstractData * clone() const
It returns a clone of this object.
bool operator==(const DateTime &rhs) const
Operator ==.
const boost::gregorian::date_period & getDatePeriod() const
It returns the boost date period type.
Definition: DatePeriod.h:86
std::string toString() const
It returns the date period in the ISO textual format (YYYYMMDDTYYYYMMDD).
bool operator<(const DateTime &rhs) const
Operator <.
virtual ~DatePeriod()
Destructor.
Date getFinalDate() const
It gets the final date.
bool operator>(const DateTime &rhs) const
Operator >
boost::gregorian::date_period m_datePeriod
The internal date period information.
Definition: DatePeriod.h:191
DateTimeInstant * getFinalInstant() const
It gets the final date time instant.
DateTimeType getDateTimeType() const
It returns the subtype of the date and time type.
Definition: DatePeriod.h:182
boost::gregorian::date_period & getDatePeriod()
It returns the boost date period type.
Definition: DatePeriod.h:93
Date getInitialDate() const
It gets the initial date.
DatePeriod(const Date &initialDate, const Date &finalDate)
Constructor.
An abstract class to represent an instant of date and time.
An abstract class to represent a period of date and time.
A base class for date data types.
Definition: Date.h:66
DateTimeType
The subtype of date and time type, based on ISO 8621.
Definition: Enums.h:46
@ DATE_PERIOD
Definition: Enums.h:48
TerraLib.
#define TEDATATYPEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61