bpp-popgen  3.0.0
Date.h
Go to the documentation of this file.
1 //
2 // File Date.h
3 // Author : Sylvain Gaillard
4 // Last modification : Thursday July 29 2004
5 //
6 
7 
8 /*
9  Copyright or © or Copr. CNRS, (November 17, 2004)
10 
11  This software is a computer program whose purpose is to provide classes
12  for population genetics analysis.
13 
14  This software is governed by the CeCILL license under French law and
15  abiding by the rules of distribution of free software. You can use,
16  modify and/ or redistribute the software under the terms of the CeCILL
17  license as circulated by CEA, CNRS and INRIA at the following URL
18  "http://www.cecill.info".
19 
20  As a counterpart to the access to the source code and rights to copy,
21  modify and redistribute granted by the license, users are provided only
22  with a limited warranty and the software's author, the holder of the
23  economic rights, and the successive licensors have only limited
24  liability.
25 
26  In this respect, the user's attention is drawn to the risks associated
27  with loading, using, modifying and/or developing or reproducing the
28  software by the user in light of its specific status of free software,
29  that may mean that it is complicated to manipulate, and that also
30  therefore means that it is reserved for developers and experienced
31  professionals having in-depth computer knowledge. Users are therefore
32  encouraged to load and test the software's suitability as regards their
33  requirements in conditions enabling the security of their systems and/or
34  data to be ensured and, more generally, to use and operate it in the
35  same conditions as regards security.
36 
37  The fact that you are presently reading this means that you have had
38  knowledge of the CeCILL license and that you accept its terms.
39  */
40 
41 #ifndef _DATE_H_
42 #define _DATE_H_
43 
44 #include <Bpp/Exceptions.h>
45 #include <Bpp/Clonable.h>
46 
47 namespace bpp
48 {
56 class Date : public Clonable
57 {
58 private:
59  int day_;
60  int month_;
61  int year_;
62 
63 public:
64  // Constructors and destructor
75  Date(const int day = 1, const int month = 1, const int year = 2000);
76 
80  Date(const Date& date);
81 
85  ~Date();
86 
87 public:
88  // Methodes
94  Date& operator=(const Date& date);
95 
103  void setDate(const int day, const int month, const int year);
104 
110  void setYear(const int year);
111 
117  void setMonth(const int month);
118 
124  void setDay(const int day);
125 
131  std::string getDateStr() const;
132 
136  int getYear() const { return year_; }
137 
141  int getMonth() const { return month_; }
142 
146  int getDay() const { return day_; }
147 
153  bool operator==(const Date& date) const;
154 
160  bool operator<(const Date& date) const;
161 
165  bool operator!=(const Date& date) const { return !(*this == date); }
166 
170  bool operator>(const Date& date) const { return date < *this; }
171 
175  bool operator<=(const Date& date) const { return !(date < *this); }
176 
180  bool operator>=(const Date& date) const { return !(*this < date); }
181 
186 #ifdef NO_VIRTUAL_COV
187  Clonable*
188 #else
189  Date*
190 #endif
191  clone() const { return new Date(*this); }
192 };
193 } // end of namespace bpp;
194 
195 #endif // _DATE_H_
196 
The Date class.
Definition: Date.h:57
std::string getDateStr() const
Get the Date as a string.
Definition: Date.cpp:112
int getMonth() const
Get the month as an int.
Definition: Date.h:141
void setYear(const int year)
Set the year.
Definition: Date.cpp:91
int getYear() const
Get the Year as an int.
Definition: Date.h:136
Date * clone() const
Definition: Date.h:191
bool operator==(const Date &date) const
The == operator.
Definition: Date.cpp:123
void setDay(const int day)
Set the day.
Definition: Date.cpp:104
bool operator!=(const Date &date) const
The != operator.
Definition: Date.h:165
int year_
Definition: Date.h:61
Date(const int day=1, const int month=1, const int year=2000)
Build a new Date from three values.
Definition: Date.cpp:50
bool operator<=(const Date &date) const
The <= operator.
Definition: Date.h:175
void setMonth(const int month)
Set the month.
Definition: Date.cpp:96
bool operator>(const Date &date) const
The > operator.
Definition: Date.h:170
bool operator>=(const Date &date) const
The >= operator.
Definition: Date.h:180
bool operator<(const Date &date) const
The < operator.
Definition: Date.cpp:131
Date & operator=(const Date &date)
The Date copy operator.
Definition: Date.cpp:70
~Date()
Destroy the Date object.
Definition: Date.cpp:66
void setDate(const int day, const int month, const int year)
Set the Date.
Definition: Date.cpp:78
int day_
Definition: Date.h:59
int getDay() const
Get the day as an int.
Definition: Date.h:146
int month_
Definition: Date.h:60