-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcTimeDate_t.cpp
61 lines (37 loc) · 1 KB
/
cTimeDate_t.cpp
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
#include "cTimeDate_t.h"
#include "cTime_t.h"
#include "cDate_t.h"
using namespace std;
cTimeDate_t::cTimeDate_t(){
}
cTimeDate_t::cTimeDate_t(int day, int month, int year, int hour, int minute, int second){
time_p.setTime(hour, minute, second);
date_p.setDate(day, month, year);
}
cTimeDate_t::cTimeDate_t(const cTime_t &t, const cDate_t &d){
time_p = t;
date_p = d;
}
cTimeDate_t::cTimeDate_t(const cTimeDate_t &t): time_p(t.time_p), date_p(t.date_p){
}
cTimeDate_t::~cTimeDate_t(){
}
const cTimeDate_t &cTimeDate_t::operator+(const cTime_t &t){
//If time addition overflows 24 hours --> add 1 date to date_p
if (time_p.getHours() + t.getHours() >= 24){
date_p.setDate(date_p.getDay() + 1, date_p.getMonth(), date_p.getYear());
}
time_p = time_p + t;
return *this;
}
const cTimeDate_t &cTimeDate_t::operator=(const cTimeDate_t &t){
if (this != &t){
time_p = t.time_p;
date_p = t.date_p;
}
return *this;
}
void cTimeDate_t::print() const{
time_p.printTime();
date_p.printDate();
}