File Coverage

xs/Timezone.xsi
Criterion Covered Total %
statement 19 41 46.3
branch 39 158 24.6
condition n/a
subroutine n/a
pod n/a
total 58 199 29.1


line stmt bran cond sub pod time code
1             MODE: INLINE
2              
3             static inline Hash export_transition (const Timezone::Transition& trans, bool is_past) {
4             auto hash = Hash::create();
5             hash.store("offset", Simple(trans.offset));
6             hash.store("abbrev", Simple(trans.abbrev));
7             if (!is_past) {
8             hash.store("start", Simple(trans.start));
9             hash.store("isdst", Simple(trans.isdst));
10             hash.store("gmt_offset", Simple(trans.gmt_offset));
11             hash.store("leap_corr", Simple(trans.leap_corr));
12             hash.store("leap_delta", Simple(trans.leap_delta));
13             }
14             return hash;
15             }
16              
17             MODULE = Date PACKAGE = Date::Timezone
18             PROTOTYPES: DISABLE
19              
20             string Timezone::name () : const {
21 14 50         RETVAL = THIS->name;
22             }
23              
24             bool Timezone::is_local () : const {
25 12           RETVAL = THIS->is_local;
26             }
27              
28             Hash Timezone::export () : const {
29 2 50         RETVAL = Hash::create();
30            
31 2 50         RETVAL.store("name", Simple(string_view(THIS->name.data(), THIS->name.length())));
    50          
32 2 50         RETVAL.store("is_local", Simple(THIS->is_local ? 1 : 0));
    50          
    50          
33            
34 4 50         auto future = Hash::create();
    50          
35 2 50         future.store("hasdst", Simple(THIS->future.hasdst ? 1 : 0));
    50          
    50          
36            
37 4 50         auto outer = Hash::create();
    50          
38 2 50         outer.store("abbrev", Simple(string_view(THIS->future.outer.abbrev, strlen(THIS->future.outer.abbrev))));
    50          
39 2 50         outer.store("offset", Simple(THIS->future.outer.offset));
    50          
40 2 50         outer.store("gmt_offset", Simple(THIS->future.outer.gmt_offset));
    50          
41 2 50         outer.store("isdst", Simple(THIS->future.outer.isdst));
    50          
42 2 50         future.store("outer", Ref::create(outer));
    50          
43            
44 2 50         if (THIS->future.hasdst) {
45 0 0         auto outer_end = Hash::create();
46 0 0         outer_end.store("mon", Simple(THIS->future.outer.end.mon));
    0          
47 0 0         outer_end.store("week", Simple(THIS->future.outer.end.yday));
    0          
48 0 0         outer_end.store("day", Simple(THIS->future.outer.end.wday));
    0          
49 0 0         outer_end.store("hour", Simple(THIS->future.outer.end.hour));
    0          
50 0 0         outer_end.store("min", Simple(THIS->future.outer.end.min));
    0          
51 0 0         outer_end.store("sec", Simple(THIS->future.outer.end.sec));
    0          
52 0 0         outer.store("end", Ref::create(outer_end));
    0          
53            
54 0 0         auto inner = Hash::create();
55 0 0         inner.store("abbrev", Simple(string_view(THIS->future.inner.abbrev, strlen(THIS->future.inner.abbrev))));
    0          
56 0 0         inner.store("offset", Simple(THIS->future.inner.offset));
    0          
57 0 0         inner.store("gmt_offset", Simple(THIS->future.inner.gmt_offset));
    0          
58 0 0         inner.store("isdst", Simple(THIS->future.inner.isdst));
    0          
59            
60 0 0         auto inner_end = Hash::create();
61 0 0         inner_end.store("mon", Simple(THIS->future.inner.end.mon));
    0          
62 0 0         inner_end.store("week", Simple(THIS->future.inner.end.yday));
    0          
63 0 0         inner_end.store("day", Simple(THIS->future.inner.end.wday));
    0          
64 0 0         inner_end.store("hour", Simple(THIS->future.inner.end.hour));
    0          
65 0 0         inner_end.store("min", Simple(THIS->future.inner.end.min));
    0          
66 0 0         inner_end.store("sec", Simple(THIS->future.inner.end.sec));
    0          
67 0 0         inner.store("end", Ref::create(inner_end));
    0          
68            
69 0 0         future.store("inner", Ref::create(inner));
    0          
70             }
71 2 50         RETVAL.store("future", Ref::create(future));
    50          
72            
73 4 50         auto trans = Array::create();
    50          
74 162 100         for (uint32_t i = 0; i < THIS->trans_cnt; ++i) trans.push(Ref::create(export_transition(THIS->trans[i], false)));
    50          
    50          
    50          
75 2 50         RETVAL.store("transitions", Ref::create(trans));
    50          
76            
77 2 50         RETVAL.store("past", Ref::create(export_transition(THIS->trans[0], true)));
    50          
    50          
78             }