8 |
|
#define _TimeZones_hpp_ |
9 |
|
|
10 |
|
#include <iostream> |
11 |
+ |
#include <fstream> |
12 |
|
#include <string> |
13 |
+ |
#include <list> |
14 |
|
#include <cstdlib> |
15 |
|
#include <cstdio> |
16 |
|
#include <ctime> |
17 |
|
|
18 |
|
using namespace std; |
19 |
|
|
18 |
– |
inline string sgetenv(const string& name) |
19 |
– |
{ |
20 |
– |
char* value = getenv(name.c_str()); |
21 |
– |
|
22 |
– |
return value != NULL ? value : ""; |
23 |
– |
} |
24 |
– |
|
20 |
|
inline int sputenv(const string& name) |
21 |
|
{ |
22 |
|
char* value = new char[name.size() + 1]; |
30 |
|
return code; |
31 |
|
} |
32 |
|
|
38 |
– |
inline void sunsetenv(const string& name) { unsetenv(name.c_str()); } |
39 |
– |
|
40 |
– |
#ifdef __CYGWIN__ |
41 |
– |
|
42 |
– |
inline time_t timegm(struct tm* time) |
43 |
– |
{ |
44 |
– |
string zone = sgetenv("TZ"); |
45 |
– |
|
46 |
– |
sputenv("TZ="); |
47 |
– |
tzset(); |
48 |
– |
|
49 |
– |
time_t when = mktime(time); |
50 |
– |
|
51 |
– |
sputenv("TZ=" + zone); |
52 |
– |
tzset(); |
53 |
– |
|
54 |
– |
return when; |
55 |
– |
} |
56 |
– |
|
57 |
– |
#endif |
58 |
– |
|
33 |
|
class TimeZones |
34 |
|
{ |
35 |
|
private: |
36 |
< |
// |
36 |
> |
time_t now; |
37 |
> |
void display(); |
38 |
> |
void display(const string& location, const string& zone); |
39 |
|
public: |
40 |
|
TimeZones(); |
41 |
|
~TimeZones() {} |