bpp-popgen3  3.0.0
Date.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef _DATE_H_
6 #define _DATE_H_
7 
8 #include <Bpp/Exceptions.h>
9 #include <Bpp/Clonable.h>
10 
11 namespace bpp
12 {
20 class Date : public Clonable
21 {
22 private:
23  int day_;
24  int month_;
25  int year_;
26 
27 public:
28  // Constructors and destructor
39  Date(const int day = 1, const int month = 1, const int year = 2000);
40 
44  Date(const Date& date);
45 
49  ~Date();
50 
51 public:
52  // Methodes
58  Date& operator=(const Date& date);
59 
67  void setDate(const int day, const int month, const int year);
68 
74  void setYear(const int year);
75 
81  void setMonth(const int month);
82 
88  void setDay(const int day);
89 
95  std::string getDateStr() const;
96 
100  int getYear() const { return year_; }
101 
105  int getMonth() const { return month_; }
106 
110  int getDay() const { return day_; }
111 
117  bool operator==(const Date& date) const;
118 
124  bool operator<(const Date& date) const;
125 
129  bool operator!=(const Date& date) const { return !(*this == date); }
130 
134  bool operator>(const Date& date) const { return date < *this; }
135 
139  bool operator<=(const Date& date) const { return !(date < *this); }
140 
144  bool operator>=(const Date& date) const { return !(*this < date); }
145 
150 #ifdef NO_VIRTUAL_COV
151  Clonable*
152 #else
153  Date*
154 #endif
155  clone() const { return new Date(*this); }
156 };
157 } // end of namespace bpp;
158 
159 #endif // _DATE_H_
The Date class.
Definition: Date.h:21
std::string getDateStr() const
Get the Date as a string.
Definition: Date.cpp:77
int getMonth() const
Get the month as an int.
Definition: Date.h:105
void setYear(const int year)
Set the year.
Definition: Date.cpp:56
int getYear() const
Get the Year as an int.
Definition: Date.h:100
Date * clone() const
Definition: Date.h:155
bool operator==(const Date &date) const
The == operator.
Definition: Date.cpp:88
void setDay(const int day)
Set the day.
Definition: Date.cpp:69
bool operator!=(const Date &date) const
The != operator.
Definition: Date.h:129
int year_
Definition: Date.h:25
Date(const int day=1, const int month=1, const int year=2000)
Build a new Date from three values.
Definition: Date.cpp:15
bool operator<=(const Date &date) const
The <= operator.
Definition: Date.h:139
void setMonth(const int month)
Set the month.
Definition: Date.cpp:61
bool operator>(const Date &date) const
The > operator.
Definition: Date.h:134
bool operator>=(const Date &date) const
The >= operator.
Definition: Date.h:144
bool operator<(const Date &date) const
The < operator.
Definition: Date.cpp:96
Date & operator=(const Date &date)
The Date copy operator.
Definition: Date.cpp:35
~Date()
Destroy the Date object.
Definition: Date.cpp:31
void setDate(const int day, const int month, const int year)
Set the Date.
Definition: Date.cpp:43
int day_
Definition: Date.h:23
int getDay() const
Get the day as an int.
Definition: Date.h:110
int month_
Definition: Date.h:24