DateDuration.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/DateDuration.h
22 
23  \brief A class to represent date duration.
24 */
25 
26 #ifndef __TERRALIB_DATATYPE_INTERNAL_DATEDURATION_H
27 #define __TERRALIB_DATATYPE_INTERNAL_DATEDURATION_H
28 
29 // TerraLib
30 #include "DateTime.h"
31 
32 // Boost
33 #include <boost/date_time/gregorian/gregorian.hpp>
34 
35 namespace te
36 {
37  namespace dt
38  {
39  /*!
40  \class DateDuration
41 
42  \brief A class to represent date duration.
43 
44  A date duration is a simple day count used for arithmetic with date,
45  based on the Gregorian Calendar. Internally, it uses the datetime boost
46  library to represent gregorian date duration,
47  by using the data type boost::gregorian::date_duration.
48 
49  \sa DateTime, Date, DatePeriod, TimeDuration, TimeInstant, TimeInstantTZ, TimePeriod, TimePeriodTZ
50  */
52  {
53  public:
54 
55  /*! \brief Empty constructor. */
56  DateDuration();
57 
58  /*!
59  \brief Constructor.
60 
61  \param dd A date duration in days.
62  */
63  DateDuration(long dd);
64 
65  /*!
66  \brief Constructor.
67 
68  \param dd A date duration.
69  */
70  DateDuration(const boost::gregorian::date_duration& dd);
71 
72  /*!
73  \brief It returns the boost date duration type.
74 
75  \return The boost date duration type.
76  */
77  const boost::gregorian::date_duration& getDateDuration() const { return m_dateDuration; }
78 
79  /*!
80  \brief It returns the boost date duration type.
81 
82  \return The boost date duration type.
83  */
84  boost::gregorian::date_duration& getDateDuration() { return m_dateDuration; }
85 
86  /*!
87  \brief Operator ==
88 
89  \param rhs The date duration to be compared.
90 
91  \return It returns true if the two date durations are equal. Otherwise, it returns false.
92  */
93  bool operator==(const DateTime& rhs) const;
94 
95  /*!
96  \brief Operator !=
97 
98  \param rhs The date duration to be compared.
99 
100  \return It returns true if the two date durations are not equal. Otherwise, it returns false.
101  */
102  bool operator!=(const DateTime& rhs) const;
103 
104  /*!
105  \brief Operator <
106 
107  \param rhs The right-hand-side date duration to be compared.
108 
109  \return It returns true if the right-hand-side date duration is greater than the lefth side one. Otherwise, it returns false.
110  */
111  bool operator<(const DateTime& rhs) const;
112 
113  /*!
114  \brief Operator >
115 
116  \param rhs The right-hand-side date duration to be compared.
117 
118  \return It returns true if the right-hand-side date duration is less than the lefth side one. Otherwise, it returns false.
119  */
120  bool operator>(const DateTime& rhs) const;
121 
122  /*!
123  \brief It returns a clone of this object.
124 
125  \return A clone of this object.
126  */
127  AbstractData* clone() const;
128 
129  /*!
130  \brief It returns the date duration in a textual format.
131 
132  \return The date duration in a textual format.
133  */
134  std::string toString() const;
135 
136  /*!
137  \brief It returns the subtype of the date and time type.
138 
139  \return The subtype of the date and time type.
140  */
142 
143  /*!
144  \brief Destructor
145  */
146  virtual ~DateDuration();
147 
148  protected:
149 
150  boost::gregorian::date_duration m_dateDuration; //!< Date duration information.
151  };
152 
153  } // end namespace dt
154 } // end namespace te
155 
156 #endif // __TERRALIB_DATATYPE_INTERNAL_DATEDURATION_H
157 
boost::gregorian::date_duration & getDateDuration()
It returns the boost date duration type.
Definition: DateDuration.h:84
TEDATAACCESSEXPORT te::da::Expression * operator<(const te::da::Expression &e1, const te::da::Expression &e2)
An abstract class for date and time types.
TEDATAACCESSEXPORT te::da::Expression * operator==(const te::da::Expression &e1, const te::da::Expression &e2)
TEDATAACCESSEXPORT te::da::Expression * operator!=(const te::da::Expression &e1, const te::da::Expression &e2)
#define TEDATATYPEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
URI C++ Library.
TEDATAACCESSEXPORT te::da::Expression * operator>(const te::da::Expression &e1, const te::da::Expression &e2)
const boost::gregorian::date_duration & getDateDuration() const
It returns the boost date duration type.
Definition: DateDuration.h:77
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
boost::gregorian::date_duration m_dateDuration
Date duration information.
Definition: DateDuration.h:150
A class to represent date duration.
Definition: DateDuration.h:51
DateTimeType getDateTimeType() const
It returns the subtype of the date and time type.
Definition: DateDuration.h:141
DateTimeType
The subtype of date and time type, based on ISO 8621.
Definition: Enums.h:45