-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcTime_t.h
78 lines (50 loc) · 1.38 KB
/
cTime_t.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
//
// cTime_t.h
//
// assumption from HW & VirtualTau Forum:
// ***********************************
// 1. accumulate the time if overflow
// 2. CTOR gets only valid values
//
#ifndef _CTIME_T_H_
#define _CTIME_T_H_
class cTime_t {
public:
static int format;
cTime_t(); //Default CTOR from Current Time
cTime_t(int h, int m, int s); //CTOR from Hours, Minutes and Seconds
cTime_t(const cTime_t& t); //Copy CTOR
~cTime_t(); //DTOR
const cTime_t& operator=(const cTime_t &t);
const cTime_t& operator+(const cTime_t &t);
void setTime(int h, int m, int s);
void printTime() const; //Print time in the static format
void printTime(int f) const; //Print time. f = 1 --> hh:mm:ss (24 hour format)
// f = 2 --> h:mm:ss PM/AM
int getHours() const;
int getMinutes() const;
int getSeconds() const;
private:
int hours;
int minutes;
int seconds;
void addTime_p(int h, int m, int s); //Add h:m:s to current time
void zeroTime(); //Set time to 00:00:00
void setTime_p(int h, int m, int s); //Set current time to h:m:s
};
/********************
* Inline functions
********************/
/********************
* Getters
********************/
inline int cTime_t::getHours() const{
return this->hours;
}
inline int cTime_t::getMinutes() const{
return this->minutes;
}
inline int cTime_t::getSeconds() const{
return this->seconds;
}
#endif