DateType.cpp
843 Bytes
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
#include "DateType.h"
/** Constructors **/
DateType::DateType()
{
Day = 1;
Month = 1;
Year = 1;
}
DateType::DateType(int newMonth, int newDay, int newYear)
{
Day = newDay;
Month = newMonth;
Year = newYear;
}
// returns Year
int DateType::GetYear() const
{
return Year;
}
// returns Month
int DateType::GetMonth() const
{
return Month;
}
// returns Day
int DateType::GetDay() const
{
return Day;
}
RelationType DateType::ComparedTo(DateType otherDate)
{
if (Year < otherDate.Year)
return Precedes;
if (Year > otherDate.Year)
return Follows;
if (Month < otherDate.Month)
return Precedes;
if (Month > otherDate.Month)
return Follows;
if (Day < otherDate.Day)
return Precedes;
if (Day > otherDate.Day)
return Follows;
return Same;
}