-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathClockData.cpp
More file actions
105 lines (91 loc) · 2.04 KB
/
Copy pathClockData.cpp
File metadata and controls
105 lines (91 loc) · 2.04 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* ClockData.cpp
* Calculate and provide access to system date and time values.
*
* Created on: 2014.01.09.
* Author: istvan_vig
*/
#include "ClockData.h"
void ClockData::calculateDividers(void) {
this->m_hour_divider = (float)this->m_hour/(float)23;
this->m_minute_divider = (float)this->m_min/(float)60;
this->m_second_divider = (float)this->m_sec/(float)60;
}
void ClockData::getSystemLocalTime(void) {
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
this->m_year = timeinfo->tm_year;
this->m_yday = timeinfo->tm_yday;
this->m_wday = timeinfo->tm_wday;
this->m_sec = timeinfo->tm_sec;
this->m_mon = timeinfo->tm_mon;
this->m_min = timeinfo->tm_min;
this->m_mday = timeinfo->tm_mday;
this->m_isdst = timeinfo->tm_isdst;
this->m_hour = timeinfo->tm_hour;
}
void ClockData::getDateTime(void) {
switch((int)ClockData::MethodType) {
case mLocalSystem:
this->getSystemLocalTime();
break;
case mTestData:
this->m_hour = 23;
this->m_min = 59;
this->m_sec = 20;
break;
default: ;
}
this->calculateDividers();
}
ClockData::ClockData() :
m_sec(0),
m_min(0),
m_hour(0),
m_mday(0),
m_mon(0),
m_year(0),
m_wday(0),
m_yday(0),
m_isdst(0),
m_hour_divider(1),
m_minute_divider(1),
m_second_divider(1),
MethodType(mTestData){
;
}
ClockData::~ClockData() {
;
}
void ClockData::_get(void) {
this->getDateTime();
}
int ClockData::getYear(void) {
return this->m_year;
}
int ClockData::getMonth(void) {
return this->m_mon;
}
int ClockData::getDay(void) {
return this->m_mday;
}
int ClockData::getHour(void) {
return this->m_hour;
}
int ClockData::getMinute(void) {
return this->m_min;
}
int ClockData::getSecond(void) {
return this->m_sec;
}
float ClockData::getHourDivider(void) {
return this->m_hour_divider;
}
float ClockData::getMinuteDivider(void) {
return this->m_minute_divider;
}
float ClockData::getSecondDivider(void) {
return this->m_second_divider;
}