-
Notifications
You must be signed in to change notification settings - Fork 5
/
TimeStamp.h
executable file
·39 lines (31 loc) · 901 Bytes
/
TimeStamp.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
#ifndef TIME_STAMP_H
#define TIME_STAMP_H
#include "common.h"
class TimeStamp
{
public:
TimeStamp();
TimeStamp(int64_t microSecondsSinceEpochArg)
: microsecondsSinceEpoch(microSecondsSinceEpochArg)
{
}
std::string toString() const;
int64_t getMicrosecondsSinceEpoch() { return microsecondsSinceEpoch; }
static TimeStamp now();
static const int kMicroSecondsPerSecond = 1000 * 1000;
private:
int64_t microsecondsSinceEpoch;
};
inline bool operator<(TimeStamp lts,TimeStamp rts)
{
return lts.getMicrosecondsSinceEpoch() < rts.getMicrosecondsSinceEpoch();
}
inline bool operator>(TimeStamp lts,TimeStamp rts)
{
return lts.getMicrosecondsSinceEpoch() > rts.getMicrosecondsSinceEpoch();
}
inline bool operator==(TimeStamp lts,TimeStamp rts)
{
return lts.getMicrosecondsSinceEpoch() == rts.getMicrosecondsSinceEpoch();
}
#endif // TIME_STAMP_H