-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDate.h
93 lines (82 loc) · 1.59 KB
/
Date.h
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
#ifndef DATE_H_
#define DATE_H_
#include "includes.h"
#include <cmath>
#include <ctime>
using namespace std;
long stol(string txt);
/**
* @brief Date class
*
* A date object consists of basically 6 integers, which hold the year, month, day, hour, minute and second.\n
* It has the necessary member functions for handling those variables, compare dates, and misc functions.
*/
class Date
{
private:
int year;
int month;
int day;
int hour;
int minute;
int second;
public:
/** @name Constructors
*/
///@{
Date();
Date(string cfg_str);
Date(int year, int month, int day, int hour, int minute, int second);
///@}
/** @name Getters
*/
///@{
int getYear() const;
int getMonth() const;
int getDay() const;
int getHour() const;
int getMinute() const;
int getSecond() const;
///@}
/** @name Setters
*/
///@{
void setYear(int year);
void setMonth(int month);
void setDay(int day);
void setHour(int hour);
void setMinute(int minute);
void setSecond(int second);
///@}
/** @name Operator overloads
*/
///@{
bool operator<(Date date2) const;
bool operator>(Date date2) const;
bool operator==(Date date2) const;
friend ostream& operator<<(ostream& os, const Date& d);
friend istream& operator>>(istream &is, Date& date);
///@}
string str() const;
string cfg_str() const;
/** @name Static functions
*/
///@{
static int daysInMonth(int month, int year);
static bool isLeapYear(int year);
static Date curDate();
static int numDays(Date d1, Date d2);
///@}
/** @name Exceptions
*/
///@{
class InvalidDate
{
public:
InvalidDate()
{
}
};
///@}
};
#endif //_DATE_H_