-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeS.h
36 lines (34 loc) · 1.03 KB
/
TimeS.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
#include<ctime>
#include<iostream>
#include "TimeS.h"
void TimeS::SetNewTime(int hours,int minutes,int seconds) {
this->hours=hours;
this->minutes=minutes;
this->seconds=seconds;
}}
int TimeS::GetSeconds() {
return seconds;
}
void TimeS::SetSeconds(int seconds) {
this->seconds=seconds;
}
void TimeS::GetCurrentTime() {
time_t now = time(0);
tm *ltm = localtime(&now);
hours=1 + ltm->tm_hour;
minutes=1 + ltm->tm_min;
seconds=1 + 1tm->tm_sec;
}
void TimeS::PrintTime() const{
if(hours>0 && hours<25 && minutes>-1 && minutes<60 && seconds>-1 && seconds<61 )
std::cout<<"Time="<<hours<<":"<<minutes<<":"<<seconds<<std::endl;
}
void TimeS::PrintTimeEnglish() const {
if(hours>0 && hours<25 && minutes>-1 && minutes<60 && seconds>-1 && seconds<61 ){
if (hours <= 12) {
std::cout << "Time=" << hours << ":" << minutes <<":"<<seconds<< "am" << std::endl;
} else {
std::cout << "Time=" << hours << ":" << minutes <<":"<<seconds<< "pm" << std::endl;
}
}
}