-
Notifications
You must be signed in to change notification settings - Fork 0
/
Date.hpp
executable file
·140 lines (116 loc) · 2.91 KB
/
Date.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef DATE_H
#define DATE_H
#include <initializer_list>
#include <string>
class Date {
public:
/**
* @brief default constructor
*/
Date();
/**
* @brief constructor with arguments
*/
Date(int t_year, int t_month, int t_day, int t_hour, int t_minute);
/**
* @brief constructor with a string
*/
Date(std::string dateString);
/**
* @brief return the year of a Date
* @return a integer indicate the year of a date
*/
int getYear(void) const;
/**
* @brief set the year of a date
* @param a integer indicate the new year of a date
*/
void setYear(const int t_year);
/**
* @brief return the month of a Date
* @return a integer indicate the month of a date
*/
int getMonth(void) const;
/**
* @brief set the month of a date
* @param a integer indicate the new month of a date
*/
void setMonth(const int t_month);
/**
* @brief return the day of a Date
* @return a integer indicate the day of a date
*/
int getDay(void) const;
/**
* @brief set the day of a date
* @param a integer indicate the new day of a date
*/
void setDay(const int t_day);
/**
* @brief return the hour of a Date
* @return a integer indicate the hour of a date
*/
int getHour(void) const;
/**
* @brief set the hour of a date
* @param a integer indicate the new hour of a date
*/
void setHour(const int t_hour);
/**
* @brief return the minute of a Date
* @return a integer indicate the minute of a date
*/
int getMinute(void) const;
/**
* @brief set the minute of a date
* @param a integer indicate the new minute of a date
*/
void setMinute(const int t_minute);
/**
* @brief check whether the date is valid or not
* @return the bool indicate valid or not
*/
static bool isValid(const Date t_date);
/**
* @brief convert a string to date, if the format is not correct return
* 0000-00-00/00:00
* @return a date
*/
static Date stringToDate(const std::string t_dateString);
/**
* @brief convert a date to string, if the format is not correct return
* 0000-00-00/00:00
*/
static std::string dateToString(Date t_date);
/**
* @brief overload the assign operator
*/
Date &operator=(const Date &t_date);
/**
* @brief check whether the CurrentDate is equal to the t_date
*/
bool operator==(const Date &t_date) const;
/**
* @brief check whether the CurrentDate is greater than the t_date
*/
bool operator>(const Date &t_date) const;
/**
* @brief check whether the CurrentDate is less than the t_date
*/
bool operator<(const Date &t_date) const;
/**
* @brief check whether the CurrentDate is greater or equal than the t_date
*/
bool operator>=(const Date &t_date) const;
/**
* @brief check whether the CurrentDate is less than or equal to the t_date
*/
bool operator<=(const Date &t_date) const;
private:
int m_year;
int m_month;
int m_day;
int m_hour;
int m_minute;
};
#endif