| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#pragma once |
|
2
|
|
|
|
|
|
|
#include |
|
3
|
|
|
|
|
|
|
#include |
|
4
|
|
|
|
|
|
|
#include |
|
5
|
|
|
|
|
|
|
#include |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
namespace panda { namespace time { |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
struct Timezone : panda::Refcnt { |
|
10
|
|
|
|
|
|
|
struct Transition { |
|
11
|
|
|
|
|
|
|
ptime_t start; // time of transition |
|
12
|
|
|
|
|
|
|
ptime_t local_start; // local time of transition (epoch+offset). |
|
13
|
|
|
|
|
|
|
ptime_t local_end; // local time of transition's end (next transition epoch + MY offset). |
|
14
|
|
|
|
|
|
|
ptime_t local_lower; // local_start or prev transition's local_end |
|
15
|
|
|
|
|
|
|
ptime_t local_upper; // local_start or prev transition's local_end |
|
16
|
|
|
|
|
|
|
int32_t offset; // offset from non-leap GMT |
|
17
|
|
|
|
|
|
|
int32_t gmt_offset; // offset from leap GMT |
|
18
|
|
|
|
|
|
|
int32_t delta; // offset minus previous transition's offset |
|
19
|
|
|
|
|
|
|
int32_t isdst; // is DST in effect after this transition |
|
20
|
|
|
|
|
|
|
int32_t leap_corr; // summary leap seconds correction at the moment |
|
21
|
|
|
|
|
|
|
int32_t leap_delta; // delta leap seconds correction (0 if it's just a transition, != 0 if it's a leap correction) |
|
22
|
|
|
|
|
|
|
ptime_t leap_end; // end of leap period (not including last second) = start + leap_delta |
|
23
|
|
|
|
|
|
|
ptime_t leap_lend; // local_start + 2*leap_delta |
|
24
|
|
|
|
|
|
|
union { |
|
25
|
|
|
|
|
|
|
char abbrev[ZONE_ABBR_MAX+1]; // transition (zone) abbreviation |
|
26
|
|
|
|
|
|
|
int64_t n_abbrev; // abbrev as int64_t |
|
27
|
|
|
|
|
|
|
}; |
|
28
|
|
|
|
|
|
|
}; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
struct Rule { |
|
31
|
|
|
|
|
|
|
// rule for future (beyond transition list) dates and for abstract timezones |
|
32
|
|
|
|
|
|
|
// http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html |
|
33
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------- |
|
34
|
|
|
|
|
|
|
// 1 Jan OUTER ZONE OUTER END INNER ZONE INNER END OUTER ZONE 31 Dec |
|
35
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------- |
|
36
|
|
|
|
|
|
|
struct Zone { |
|
37
|
|
|
|
|
|
|
enum class Switch { DATE, JDAY, DAY }; |
|
38
|
|
|
|
|
|
|
union { |
|
39
|
|
|
|
|
|
|
char abbrev[ZONE_ABBR_MAX+1]; // zone abbreviation |
|
40
|
|
|
|
|
|
|
int64_t n_abbrev; // abbrev as int64_t |
|
41
|
|
|
|
|
|
|
}; |
|
42
|
|
|
|
|
|
|
int32_t offset; // offset from non-leap GMT |
|
43
|
|
|
|
|
|
|
int32_t gmt_offset; // offset from leap GMT |
|
44
|
|
|
|
|
|
|
int32_t isdst; // true if zone represents DST time |
|
45
|
|
|
|
|
|
|
Switch type; // type of 'end' field |
|
46
|
|
|
|
|
|
|
datetime end; // dynamic date when this zone ends (only if hasdst=1) |
|
47
|
|
|
|
|
|
|
}; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
uint32_t hasdst; // does this rule have DST switching |
|
50
|
|
|
|
|
|
|
Zone outer; // always present |
|
51
|
|
|
|
|
|
|
Zone inner; // only present if hasdst=1 |
|
52
|
|
|
|
|
|
|
int32_t max_offset; // max(outer.offset, inner.offset) |
|
53
|
|
|
|
|
|
|
int32_t delta; // inner.offset - outer.offset |
|
54
|
|
|
|
|
|
|
}; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
struct Leap { |
|
57
|
|
|
|
|
|
|
ptime_t time; |
|
58
|
|
|
|
|
|
|
uint32_t correction; |
|
59
|
|
|
|
|
|
|
}; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
string name; |
|
62
|
|
|
|
|
|
|
Transition* trans; |
|
63
|
|
|
|
|
|
|
uint32_t trans_cnt; |
|
64
|
|
|
|
|
|
|
Transition ltrans; // trans[trans_cnt-1] |
|
65
|
|
|
|
|
|
|
Leap* leaps; |
|
66
|
|
|
|
|
|
|
uint32_t leaps_cnt; |
|
67
|
|
|
|
|
|
|
Rule future; |
|
68
|
|
|
|
|
|
|
mutable bool is_local; // if timezone is set as local at the moment |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Timezone () {} |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
void clear () { |
|
73
|
0
|
0
|
|
|
|
|
delete[] this->trans; |
|
74
|
0
|
0
|
|
|
|
|
if (this->leaps_cnt > 0) delete[] this->leaps; |
|
|
|
0
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
~Timezone () { clear(); } |
|
78
|
|
|
|
|
|
|
}; |
|
79
|
|
|
|
|
|
|
using TimezoneSP = panda::iptr; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
void tzset (const string_view& zonename); |
|
82
|
|
|
|
|
|
|
void tzset (const TimezoneSP& = TimezoneSP()); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
TimezoneSP tzget (const string_view& zonename); |
|
85
|
|
|
|
|
|
|
TimezoneSP tzlocal (); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
const string& tzdir (); |
|
88
|
|
|
|
|
|
|
bool tzdir (const string&); |
|
89
|
|
|
|
|
|
|
const string& tzsysdir (); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
}} |