summaryrefslogtreecommitdiffstats
path: root/src/save/Date.cpp
blob: ca75bb5e98c4f4b84b31ce253fd84bdbe8ac4799 (plain) (blame)
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
#include "common.h"
#include "Date.h"

CDate::CDate()
{
	m_nYear = 0;
	m_nSecond = 0;
	m_nMinute = 0;
	m_nHour = 0;
	m_nDay = 0;
	m_nMonth = 0;
}

bool
CDate::operator>(const CDate &right)
{
	if (m_nYear > right.m_nYear)
		return true;
	if (m_nYear != right.m_nYear)
		return false;

	if (m_nMonth > right.m_nMonth)
		return true;
	if (m_nMonth != right.m_nMonth)
		return false;

	if (m_nDay > right.m_nDay)
		return true;
	if (m_nDay != right.m_nDay)
		return false;

	if (m_nHour > right.m_nHour)
		return true;
	if (m_nHour != right.m_nHour)
		return false;

	if (m_nMinute > right.m_nMinute)
		return true;
	if (m_nMinute != right.m_nMinute)
		return false;
	return m_nSecond > right.m_nSecond;
}

bool
CDate::operator<(const CDate &right)
{
	if (m_nYear < right.m_nYear)
		return true;
	if (m_nYear != right.m_nYear)
		return false;

	if (m_nMonth < right.m_nMonth)
		return true;
	if (m_nMonth != right.m_nMonth)
		return false;

	if (m_nDay < right.m_nDay)
		return true;
	if (m_nDay != right.m_nDay)
		return false;

	if (m_nHour < right.m_nHour)
		return true;
	if (m_nHour != right.m_nHour)
		return false;

	if (m_nMinute < right.m_nMinute)
		return true;
	if (m_nMinute != right.m_nMinute)
		return false;
	return m_nSecond < right.m_nSecond;
}

bool
CDate::operator==(const CDate &right)
{
	if (m_nYear != right.m_nYear || m_nMonth != right.m_nMonth || m_nDay != right.m_nDay || m_nHour != right.m_nHour || m_nMinute != right.m_nMinute)
		return false;
	return m_nSecond == right.m_nSecond;
}

void
CDate::PopulateDateFields(int8 &second, int8 &minute, int8 &hour, int8 &day, int8 &month, int16 year)
{
	m_nSecond = second;
	m_nMinute = minute;
	m_nHour = hour;
	m_nDay = day;
	m_nMonth = month;
	m_nYear = year;
}