-
Notifications
You must be signed in to change notification settings - Fork 0
/
Now.h
51 lines (40 loc) · 975 Bytes
/
Now.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
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef __NOW_H__
#define __NOW_H__
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include "Debug.h"
#define ONE_MINUTE (60)
#define TWO_MINUTES (2 * ONE_MINUTE)
#define TEN_MINUTES (10 * ONE_MINUTE)
#define ONE_HOUR (ONE_MINUTE * 60 )
#define ONE_DAY (ONE_HOUR * 24 )
class Now
{
public:
Now();
~Now();
void updateTime();
time_t unixtime();
size_t RFC2822( char *s, size_t max );
size_t RFC1123( char *s, size_t max );
size_t mySQL( char *s, size_t max );
struct timeval timeval();
float timeSinceLast( );
bool isNewMinute( );
bool isNewHour( );
bool isNewDay( );
int getMinute();
int getHour();
int getDayOfYear();
int isDST();
double getDecimalTime();
private:
struct tm currentTs;
struct tm lastTs;
struct timezone tz;
struct timeval currentTv;
struct timeval lastTv;
Debug dbg;
};
#endif // __NOW_H__