blob: e0c20cc9977fc47bf2bd325b4eb8ca2589c0e5fc (
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
|
#include "DateTime.h"
/* Private */
bool DateTime::isLeapYear() {
return year % 400 == 0 || (year % 100 != 0 && year % 4 == 0);
}
/* Public */
DateTime::DateTime(unsigned short hour, unsigned short minute, unsigned short day, unsigned short month, unsigned short year) {
this->hour = hour;
this->minute = minute;
this->day = day;
this->month = month;
this->year = year;
}
int DateTime::compare(const DateTime& other) {
if (year < other.year || month < other.month || day < other.day || hour < other.hour || minute < other.minute)
return -1;
return year > other.year || month > other.month || day > other.day || hour > other.hour || minute > other.minute;
}
unsigned short DateTime::get_hour() {
return hour;
}
bool DateTime::set_hour(unsigned short newHour) {
if (newHour > 23)
return false;
hour = newHour;
return true;
}
unsigned short DateTime::get_minute() {
return minute;
}
bool DateTime::set_minute(unsigned short newMinute) {
if (newMinute > 59)
return false;
minute = newMinute;
return true;
}
unsigned short DateTime::get_day() {
return day;
}
bool DateTime::set_day(unsigned short newDay) {
}
unsigned short get_month();
bool set_month(unsigned short newMonth);
unsigned short DateTime::get_year() {
return year;
}
bool DateTime::set_year(unsigned short newYear) {
year = newYear;
return true;
}
|