line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include |
2
|
|
|
|
|
|
|
#include // strlen |
3
|
|
|
|
|
|
|
#include // getenv |
4
|
|
|
|
|
|
|
#include |
5
|
|
|
|
|
|
|
#include |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
namespace panda { namespace time { |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
|
|
|
static inline bool _from_env (char* lzname, const char* envar) { |
10
|
1
|
|
|
|
|
|
const char* val = getenv(envar); |
11
|
1
|
50
|
|
|
|
|
if (val == NULL) return false; |
12
|
0
|
|
|
|
|
|
size_t len = std::strlen(val); |
13
|
0
|
0
|
|
|
|
|
if (len < 1 || len > TZNAME_MAX) return false; |
|
|
0
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
std::strcpy(lzname, val); |
15
|
0
|
|
|
|
|
|
return true; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
static bool _tz_lzname (char* lzname); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
}} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DragonFly__) |
23
|
|
|
|
|
|
|
# include "unix.icc" |
24
|
|
|
|
|
|
|
# define __PTIME_TZDIR "/usr/share/zoneinfo" |
25
|
|
|
|
|
|
|
#elif defined __linux__ |
26
|
|
|
|
|
|
|
# include "unix.icc" |
27
|
|
|
|
|
|
|
# define __PTIME_TZDIR "/usr/share/zoneinfo" |
28
|
|
|
|
|
|
|
#elif defined __APPLE__ |
29
|
|
|
|
|
|
|
# include "unix.icc" |
30
|
|
|
|
|
|
|
# define __PTIME_TZDIR "/usr/share/zoneinfo" |
31
|
|
|
|
|
|
|
#elif defined __VMS |
32
|
|
|
|
|
|
|
# include "vms.icc" |
33
|
|
|
|
|
|
|
# define __PTIME_TZDIR "/usr/share/zoneinfo" |
34
|
|
|
|
|
|
|
#elif defined _WIN32 |
35
|
|
|
|
|
|
|
# include "win.icc" |
36
|
|
|
|
|
|
|
# define __PTIME_TZDIR "" |
37
|
|
|
|
|
|
|
#elif defined __OpenBSD__ |
38
|
|
|
|
|
|
|
# include "unix.icc" |
39
|
|
|
|
|
|
|
# define __PTIME_TZDIR "/usr/share/zoneinfo" |
40
|
|
|
|
|
|
|
#else |
41
|
|
|
|
|
|
|
#error "Current operating system is not supported" |
42
|
|
|
|
|
|
|
#endif |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#ifdef TZDIR |
45
|
|
|
|
|
|
|
# undef __PTIME_TZDIR |
46
|
|
|
|
|
|
|
# define __TMP_SHIT(name) #name |
47
|
|
|
|
|
|
|
# define __PTIME_TZDIR __TMP_SHIT(TZDIR) |
48
|
|
|
|
|
|
|
#endif |
49
|
|
|
|
|
|
|
|
50
|
26
|
|
|
|
|
|
const panda::string panda::time::ZONEDIR = __PTIME_TZDIR; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
namespace panda { namespace time { |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
|
string tz_lzname () { |
55
|
|
|
|
|
|
|
char tmp[TZNAME_MAX+1]; |
56
|
1
|
50
|
|
|
|
|
if (_from_env(tmp, "TZ") || _tz_lzname(tmp)) return string(tmp, strlen(tmp)); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
57
|
1
|
|
|
|
|
|
return string(GMT_FALLBACK); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
104
|
50
|
|
|
|
|
}} |
|
|
50
|
|
|
|
|
|