Branch Coverage

datetime.c
Criterion Covered Total %
branch 110 156 70.5


line true false branch
16 498 1492 return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
28 470 return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
22 1498 return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
20 2 46 if (!looks_like_date(s, len))
21 2 0 croak("Invalid date string (expected YYYY-MM-DD): %.*s",
31 45 1 if (month < 1 || month > 12 || day < 1 || day > 31)
42 3 if (month < 1 || month > 12 || day < 1 || day > 31)
42 0 if (month < 1 || month > 12 || day < 1 || day > 31)
1 41 if (month < 1 || month > 12 || day < 1 || day > 31)
32 5 0 croak("Invalid date '%.*s': month/day out of range",
35 3 38 + (month == 2 && is_leap_year(year) ? 1 : 0);
2 1 + (month == 2 && is_leap_year(year) ? 1 : 0);
36 3 38 if (day > max_day)
37 3 0 croak("Invalid date '%.*s': day %d exceeds month %d's length (%d)",
43 441 1381 for (y = 1970; y < year; y++) days += is_leap_year(y) ? 366 : 365;
1822 38 for (y = 1970; y < year; y++) days += is_leap_year(y) ? 366 : 365;
44 34 109 for (y = year; y < 1970; y++) days -= is_leap_year(y) ? 366 : 365;
143 38 for (y = year; y < 1970; y++) days -= is_leap_year(y) ? 366 : 365;
46 145 38 for (m = 1; m < month; m++) {
48 22 123 if (m == 2 && is_leap_year(year)) days++;
15 7 if (m == 2 && is_leap_year(year)) days++;
57 0 21 if (len < 19) { *h = *mi = *se = 0; return; }
59 5 16 if ((s[10] != ' ' && s[10] != 'T') || s[13] != ':' || s[16] != ':'
5 0 if ((s[10] != ' ' && s[10] != 'T') || s[13] != ':' || s[16] != ':'
21 0 if ((s[10] != ' ' && s[10] != 'T') || s[13] != ':' || s[16] != ':'
21 0 if ((s[10] != ' ' && s[10] != 'T') || s[13] != ':' || s[16] != ':'
60 21 0 || !IS_DIGIT(s[11]) || !IS_DIGIT(s[12])
20 1 || !IS_DIGIT(s[11]) || !IS_DIGIT(s[12])
20 0 || !IS_DIGIT(s[11]) || !IS_DIGIT(s[12])
19 1 || !IS_DIGIT(s[11]) || !IS_DIGIT(s[12])
61 19 0 || !IS_DIGIT(s[14]) || !IS_DIGIT(s[15])
19 0 || !IS_DIGIT(s[14]) || !IS_DIGIT(s[15])
19 0 || !IS_DIGIT(s[14]) || !IS_DIGIT(s[15])
19 0 || !IS_DIGIT(s[14]) || !IS_DIGIT(s[15])
62 19 0 || !IS_DIGIT(s[17]) || !IS_DIGIT(s[18]))
19 0 || !IS_DIGIT(s[17]) || !IS_DIGIT(s[18]))
19 0 || !IS_DIGIT(s[17]) || !IS_DIGIT(s[18]))
1 18 || !IS_DIGIT(s[17]) || !IS_DIGIT(s[18]))
63 3 0 croak("Invalid datetime string: %.*s", (int)(len > 30 ? 30 : len), s);
71 0 5 if (pos >= len) return 0;
73 4 1 if (c == 'Z' || c == 'z') return 0;
0 4 if (c == 'Z' || c == 'z') return 0;
74 1 3 if (c != '+' && c != '-') return 0;
0 1 if (c != '+' && c != '-') return 0;
75 1 3 int sign = (c == '-') ? -1 : 1;
77 4 0 if (pos + 2 > len
78 4 0 || s[pos] < '0' || s[pos] > '9'
4 0 || s[pos] < '0' || s[pos] > '9'
79 4 0 || s[pos+1] < '0' || s[pos+1] > '9')
0 4 || s[pos+1] < '0' || s[pos+1] > '9')
80 0 0 croak("Invalid datetime timezone: %.*s",
85 4 0 if (pos < len && s[pos] == ':') pos++;
3 1 if (pos < len && s[pos] == ':') pos++;
86 4 0 if (pos + 2 <= len
87 4 0 && s[pos] >= '0' && s[pos] <= '9'
4 0 && s[pos] >= '0' && s[pos] <= '9'
88 4 0 && s[pos+1] >= '0' && s[pos+1] <= '9') {
4 0 && s[pos+1] >= '0' && s[pos+1] <= '9') {
100 4 7 if (len > 19) epoch -= parse_tz_offset(aTHX_ s, len, 19);
103 10 1 if (epoch < 0 || epoch > 0xFFFFFFFFLL)
1 9 if (epoch < 0 || epoch > 0xFFFFFFFFLL)
104 2 0 croak("DateTime out of UInt32 range "
118 5 2 if (!(isfinite(d) && d > -9.223372036854776e18 && d < 9.223372036854776e18))
5 0 if (!(isfinite(d) && d > -9.223372036854776e18 && d < 9.223372036854776e18))
0 5 if (!(isfinite(d) && d > -9.223372036854776e18 && d < 9.223372036854776e18))
132 7 0 if (len > 20 && s[19] == '.') {
7 0 if (len > 20 && s[19] == '.') {
134 30 7 for (i = 0; i < precision && (20 + i) < (int)len; i++) {
30 0 for (i = 0; i < precision && (20 + i) < (int)len; i++) {
136 30 0 if (c < '0' || c > '9') break;
30 0 if (c < '0' || c > '9') break;
139 0 7 for (; i < precision; i++) frac *= 10;
142 31 6 while (tz_pos < len && s[tz_pos] >= '0' && s[tz_pos] <= '9') tz_pos++;
30 1 while (tz_pos < len && s[tz_pos] >= '0' && s[tz_pos] <= '9') tz_pos++;
30 0 while (tz_pos < len && s[tz_pos] >= '0' && s[tz_pos] <= '9') tz_pos++;
145 1 6 if (tz_pos < len) base -= parse_tz_offset(aTHX_ s, len, tz_pos);
147 7 0 uint64_t scale = (precision >= 0 && precision <= 19) ? pow10_u64[precision] : 1;
7 0 uint64_t scale = (precision >= 0 && precision <= 19) ? pow10_u64[precision] : 1;