-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfbTime.h
More file actions
76 lines (62 loc) · 1.92 KB
/
fbTime.h
File metadata and controls
76 lines (62 loc) · 1.92 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
#ifndef fbTIME_H
#define fbTIME_H
#include "global.h"
#include <ctime>
/**
* fbTime
* Time manager
* counts the secounds from midnight
* @author Byron Heads
* @date March 15, 2008
*/
class fbTime
{
public:
fbTime();
fbTime(int h, int m, int s);
fbTime(long _ticks);
fbTime(tm& time);
fbTime(fbTime& time);
~fbTime(){};
//get and set mostly used for saving..
long getTicks() const {return ticks;};
void setTicks(long _ticks) {ticks = _ticks;};
// set the tick value
void setTicks(tm& time){setTicks(time.tm_hour, time.tm_min, time.tm_sec);};
void setTicks(int h, int m, int s);
void setTicksLocal();
//get the time
int getHour() const {return hour;};
int getMin() const {return min;};
int getSec() const {return sec;};
//comparision operators
bool operator==(fbTime& rhs) {return ticks == rhs.ticks;};
bool operator>=(fbTime& rhs) {return ticks >= rhs.ticks;};
bool operator<=(fbTime& rhs) {return ticks <= rhs.ticks;};
bool operator>(fbTime& rhs) {return ticks > rhs.ticks;};
bool operator<(fbTime& rhs) {return ticks < rhs.ticks;};
//simple add secounds
fbTime& operator+(const int s){ticks+= s; update(); return *this;};
fbTime& operator+=(const int s){ticks+= s; update(); return *this;};
fbTime& operator++(){++ticks; update(); return *this;};
fbTime& operator++(const int s){++ticks; update(); return *this;};
//remove secs
fbTime& operator-(const int s){ticks-= s; update(); return *this;};
fbTime& operator-=(const int s){ticks-= s; update(); return *this;};
fbTime& operator--(){--ticks; update(); return *this;};
fbTime& operator--(const int s){--ticks; update(); return *this;};
void addSec(const int s = 1){*this += s;};
void addMin(const int m = 1){*this += (m*60);};
void addHour(const int h = 1){*this += (h*3600);};
//output
void hms(string& t);
void hm(string& t);
private:
long ticks;
int hour;
int min;
int sec;
void update();
void ltostr(long val, string& str);
};
#endif