-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclockimpl.cpp
More file actions
43 lines (33 loc) · 806 Bytes
/
clockimpl.cpp
File metadata and controls
43 lines (33 loc) · 806 Bytes
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
#include "clock.h"
WatchInternals::WatchInternals(){
time_t t = time(0);
timeNow = localtime(&t);
}
int WatchInternals::getHours(){
return timeNow->tm_hour;
}
int WatchInternals::getMinutes(){
return timeNow->tm_min;
}
int WatchInternals::getSeconds(){
return timeNow->tm_sec;
}
int WatchInternals::getDay(){
return timeNow->tm_mday - 1;
}
int WatchInternals::getMonth(){
return timeNow->tm_mon;
}
int WatchInternals::getYear(){
return timeNow->tm_year+1900; //since tm_year stores years since 1900
}
bool WatchInternals::isAfterNoon(){
return getHours() >= 12;
}
void WatchInternals::tick(){
time_t t = time(0);
timeNow = localtime(&t);
}
void WatchInternals::printTime(){
cout << getHours() << ":" << getMinutes() << ":" << getSeconds() << endl;
}