Branch Coverage

xs/Date.xs
Criterion Covered Total %
branch 404 838 48.2


line true false branch
29 32 0 auto tz = list2vals(args, items, vals);
30 32 0 auto ret = Date(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], tz);
31 3 29 if (ret.error() && is_strict_mode()) throw xs::out(ret.error());
3 0 if (ret.error() && is_strict_mode()) throw xs::out(ret.error());
3 0 if (ret.error() && is_strict_mode()) throw xs::out(ret.error());
32 0 if (ret.error() && is_strict_mode()) throw xs::out(ret.error());
3 29 if (ret.error() && is_strict_mode()) throw xs::out(ret.error());
3 0 if (ret.error() && is_strict_mode()) throw xs::out(ret.error());
0 0 if (ret.error() && is_strict_mode()) throw xs::out(ret.error());
39 47 0 Stash stash(__PACKAGE__);
41 47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
47 0 xs::exp::create_constants(stash, {
1034 47 xs::exp::create_constants(stash, {
0 0 xs::exp::create_constants(stash, {
65 47 0 });
67 47 0 Stash ecstash("Date::Error", GV_ADD);
68 47 0 xs::exp::create_constants(ecstash, {
47 0 xs::exp::create_constants(ecstash, {
47 0 xs::exp::create_constants(ecstash, {
94 47 xs::exp::create_constants(ecstash, {
0 0 xs::exp::create_constants(ecstash, {
69 47 0 {"parser_error", xs::out(make_error_code(errc::parser_error))},
70 47 0 {"out_of_range", xs::out(make_error_code(errc::out_of_range))},
71 47 0 });
73 47 0 stash.add_const_sub("error_category", xs::out(&error_category));
47 0 stash.add_const_sub("error_category", xs::out(&error_category));
79 16 0
80 82 0 void tzset (TimezoneSP newzone = {})
83 0 0 if (newdir) {
84 0 0 tzdir(xs::in(newdir));
0 0 tzdir(xs::in(newdir));
87 0 0 RETVAL = tzdir();
0 0 RETVAL = tzdir();
90 47 0 string tzsysdir ()
47 0 string tzsysdir ()
93 72 25 if (newdir) {
94 72 0 tzembededdir(xs::in(newdir));
72 0 tzembededdir(xs::in(newdir));
97 25 0 RETVAL = tzembededdir();
25 0 RETVAL = tzembededdir();
101 1 0 auto list = available_timezones();
102 1 0 if (list.size()) EXTEND(SP, (int)list.size());
1 0 if (list.size()) EXTEND(SP, (int)list.size());
0 1 if (list.size()) EXTEND(SP, (int)list.size());
0 1 if (list.size()) EXTEND(SP, (int)list.size());
0 0 if (list.size()) EXTEND(SP, (int)list.size());
103 1212 1 for (auto& name : list) {
104 1212 0 mPUSHs(xs::out(name).detach());
1212 0 mPUSHs(xs::out(name).detach());
115 7 0 if (epochSV) epoch = xs::in(epochSV);
7 0 if (epochSV) epoch = xs::in(epochSV);
121 2 0 case 0: success = gmtime(epoch, &date); break;
122 5 0 case 1: success = localtime(epoch, &date); break;
123 0 0 case 2: success = anytime(epoch, &date, tz ? tz : tzlocal()); break;
0 0 case 2: success = anytime(epoch, &date, tz ? tz : tzlocal()); break;
0 0 case 2: success = anytime(epoch, &date, tz ? tz : tzlocal()); break;
126 7 0 if (GIMME_V == G_ARRAY) {
0 0 if (GIMME_V == G_ARRAY) {
5 2 if (GIMME_V == G_ARRAY) {
127 0 5 if (!success) XSRETURN_EMPTY;
128 0 5 EXTEND(SP, 9);
0 0 EXTEND(SP, 9);
129 0 5 EXTEND_MORTAL(9);
0 0 EXTEND_MORTAL(9);
130 5 0 mPUSHu(date.sec);
5 0 mPUSHu(date.sec);
131 5 0 mPUSHu(date.min);
5 0 mPUSHu(date.min);
132 5 0 mPUSHu(date.hour);
5 0 mPUSHu(date.hour);
133 5 0 mPUSHu(date.mday);
5 0 mPUSHu(date.mday);
134 5 0 mPUSHu(date.mon);
5 0 mPUSHu(date.mon);
135 5 0 mPUSHi(date.year);
5 0 mPUSHi(date.year);
136 5 0 mPUSHu(date.wday);
5 0 mPUSHu(date.wday);
137 5 0 mPUSHu(date.yday);
5 0 mPUSHu(date.yday);
138 5 0 mPUSHu(date.isdst);
5 0 mPUSHu(date.isdst);
141 0 2 EXTEND(SP, 1);
0 0 EXTEND(SP, 1);
142 0 2 if (!success) XSRETURN_UNDEF;
143 2 0 mPUSHs(xs::out(strftime(LT_FORMAT, date)).detach());
2 0 mPUSHs(xs::out(strftime(LT_FORMAT, date)).detach());
2 0 mPUSHs(xs::out(strftime(LT_FORMAT, date)).detach());
151 10 0 date.min = xs::in(min);
152 10 0 date.hour = xs::in(hour);
153 10 0 date.mday = xs::in(mday);
154 10 0 date.mon = xs::in(mon);
155 10 0 date.year = xs::in(year);
156 10 0
158 4 6 else date.isdst = -1;
4 0 else date.isdst = -1;
0 0 else date.isdst = -1;
162 1 0 case 1: RETVAL = timelocall(&date); break;
163 5 0 case 2: RETVAL = timeanyl(&date, tz ? tz : tzlocal()); break;
164 0 0 case 3: RETVAL = timegm(&date); break;
0 0 case 3: RETVAL = timegm(&date); break;
0 0 case 3: RETVAL = timegm(&date); break;
165 2 0 case 4: RETVAL = timelocal(&date); break;
166 2 0 case 5: RETVAL = timeany(&date, tz ? tz : tzlocal()); break;
167 0 0 default: croak("not reached");
0 0 default: croak("not reached");
0 0 default: croak("not reached");
171 4 6 sv_setiv(sec, date.sec);
172 3 0 sv_setiv(min, date.min);
173 3 0 sv_setiv(hour, date.hour);
174 3 0 sv_setiv(mday, date.mday);
175 3 0 sv_setiv(mon, date.mon);
176 3 0 sv_setiv(year, date.year);
177 3 0 if (isdst) sv_setiv(isdst, date.isdst);
178 2 1 }
2 0 }
183 5 0 }
5 0 }
5 0 }
187 2 0 }
2 0 }
2 0 }
191 2 0 }
2 0 }
2 0 }
195 1 0 }
199 295 7 }
295 0 }
295 0 }
203 16 1 }
16 0 }
16 0 }
206 3 2 if (newval) Date::range_check(newval.defined() && newval.is_true());
3 0 if (newval) Date::range_check(newval.defined() && newval.is_true());
3 0 if (newval) Date::range_check(newval.defined() && newval.is_true());
2 1 if (newval) Date::range_check(newval.defined() && newval.is_true());
214 37 2 }
37 0 }
37 0 }
218 11 1 }
11 0 }
11 0 }
221 5 2 THIS->set(sv2date(val, tz, fmt));
5 0 THIS->set(sv2date(val, tz, fmt));
225 2 1 THIS->set(xs_date_ymd(&ST(1), items - 1));
2 0 THIS->set(xs_date_ymd(&ST(1), items - 1));
229 1 204 if (newval) {
230 1 0 if (SvNOK(newval)) THIS->epoch((double)SvNV(newval));
1 0 if (SvNOK(newval)) THIS->epoch((double)SvNV(newval));
0 0 if (SvNOK(newval)) THIS->epoch((double)SvNV(newval));
1 0 if (SvNOK(newval)) THIS->epoch((double)SvNV(newval));
231 0 0 else THIS->epoch(xs::in(newval));
0 0 else THIS->epoch(xs::in(newval));
234 204 0 dXSTARG; XSprePUSH;
0 0 dXSTARG; XSprePUSH;
235 28 176 if (THIS->mksec()) PUSHn(THIS->epoch_mks());
28 0 if (THIS->mksec()) PUSHn(THIS->epoch_mks());
0 28 if (THIS->mksec()) PUSHn(THIS->epoch_mks());
28 0 if (THIS->mksec()) PUSHn(THIS->epoch_mks());
236 176 0 else PUSHi(THIS->epoch());
8 168 else PUSHi(THIS->epoch());
168 0 else PUSHi(THIS->epoch());
241 0 0 }
244 7 15 if (newval) THIS->year(xs::in(newval));
7 0 if (newval) THIS->year(xs::in(newval));
7 0 if (newval) THIS->year(xs::in(newval));
245 22 0 RETVAL = THIS->year();
250 0 3 if (newval) THIS->c_year(xs::in(newval));
0 0 if (newval) THIS->c_year(xs::in(newval));
0 0 if (newval) THIS->c_year(xs::in(newval));
251 3 0 RETVAL = THIS->c_year();
255 0 3 if (newval) THIS->yr(xs::in(newval));
0 0 if (newval) THIS->yr(xs::in(newval));
0 0 if (newval) THIS->yr(xs::in(newval));
256 3 0 RETVAL = THIS->yr();
261 0 16 if (newval) THIS->month(xs::in(newval));
0 0 if (newval) THIS->month(xs::in(newval));
0 0 if (newval) THIS->month(xs::in(newval));
262 16 0 RETVAL = THIS->month();
267 0 2 if (newval) THIS->c_month(xs::in(newval));
0 0 if (newval) THIS->c_month(xs::in(newval));
0 0 if (newval) THIS->c_month(xs::in(newval));
268 2 0 RETVAL = THIS->c_month();
273 10 16 if (newval) THIS->day(xs::in(newval));
10 0 if (newval) THIS->day(xs::in(newval));
10 0 if (newval) THIS->day(xs::in(newval));
274 26 0 RETVAL = THIS->day();
278 0 7 if (newval) THIS->hour(xs::in(newval));
0 0 if (newval) THIS->hour(xs::in(newval));
0 0 if (newval) THIS->hour(xs::in(newval));
279 7 0 RETVAL = THIS->hour();
284 0 8 if (newval) THIS->min(xs::in(newval));
0 0 if (newval) THIS->min(xs::in(newval));
0 0 if (newval) THIS->min(xs::in(newval));
285 8 0 RETVAL = THIS->min();
290 0 8 if (newval) THIS->sec(xs::in(newval));
0 0 if (newval) THIS->sec(xs::in(newval));
0 0 if (newval) THIS->sec(xs::in(newval));
291 8 0 RETVAL = THIS->sec();
295 0 8 if (newval) THIS->mksec(xs::in(newval));
0 0 if (newval) THIS->mksec(xs::in(newval));
0 0 if (newval) THIS->mksec(xs::in(newval));
301 0 4 if (newval) THIS->wday(xs::in(newval));
0 0 if (newval) THIS->wday(xs::in(newval));
0 0 if (newval) THIS->wday(xs::in(newval));
302 4 0 RETVAL = THIS->wday();
307 0 2 if (newval) THIS->c_wday(xs::in(newval));
0 0 if (newval) THIS->c_wday(xs::in(newval));
0 0 if (newval) THIS->c_wday(xs::in(newval));
308 2 0 RETVAL = THIS->c_wday();
312 0 2 if (newval) THIS->ewday(xs::in(newval));
0 0 if (newval) THIS->ewday(xs::in(newval));
0 0 if (newval) THIS->ewday(xs::in(newval));
313 2 0 RETVAL = THIS->ewday();
318 0 2 if (newval) THIS->yday(xs::in(newval));
0 0 if (newval) THIS->yday(xs::in(newval));
0 0 if (newval) THIS->yday(xs::in(newval));
319 2 0 RETVAL = THIS->yday();
324 0 1 if (newval) THIS->c_yday(xs::in(newval));
0 0 if (newval) THIS->c_yday(xs::in(newval));
0 0 if (newval) THIS->c_yday(xs::in(newval));
325 1 0 RETVAL = THIS->c_yday();
330 6 0 RETVAL = THIS->isdst();
334 2 45 if (THIS->error()) XSRETURN_UNDEF;
335 45 0 RETVAL = THIS->to_string((Date::Format)format);
45 0 RETVAL = THIS->to_string((Date::Format)format);
339 0 8 if (THIS->error()) XSRETURN_UNDEF;
340 8 0 RETVAL = THIS->to_string();
8 0 RETVAL = THIS->to_string();
347 4 7 if (items == 2 && arg0.is_object_ref()) {
1 3 if (items == 2 && arg0.is_object_ref()) {
1 10 if (items == 2 && arg0.is_object_ref()) {
348 1 0 auto THIS = xs::in(arg0);
349 1 0 RETVAL = THIS->strftime(xs::in(arg1));
1 0 RETVAL = THIS->strftime(xs::in(arg1));
1 0 RETVAL = THIS->strftime(xs::in(arg1));
352 10 0 string_view format = xs::in(arg0);
358 2 0 case 9: tz = xs::in(ST(8)); // fall through
359 2 0 case 8: date.isdst = SvIV(ST(7)); // fall through
0 0 case 8: date.isdst = SvIV(ST(7)); // fall through
361 5 0 date.sec = xs::in(ST(1));
362 5 0 date.min = xs::in(ST(2));
363 5 0 date.hour = xs::in(ST(3));
364 5 0 date.mday = xs::in(ST(4));
365 5 0 date.mon = xs::in(ST(5));
366 5 0 date.year = xs::in(ST(6));
367 2 3 timeany(&date, tz ? tz : tzlocal());
3 0 timeany(&date, tz ? tz : tzlocal());
5 0 timeany(&date, tz ? tz : tzlocal());
369 2 0 case 3: tz = xs::in(ST(2)); // fall through
371 5 0 auto epoch = xs::in(arg1);
372 2 3 if (!anytime(epoch, &date, tz ? tz : tzlocal())) XSRETURN_UNDEF;
3 0 if (!anytime(epoch, &date, tz ? tz : tzlocal())) XSRETURN_UNDEF;
5 0 if (!anytime(epoch, &date, tz ? tz : tzlocal())) XSRETURN_UNDEF;
0 5 if (!anytime(epoch, &date, tz ? tz : tzlocal())) XSRETURN_UNDEF;
378 10 0 RETVAL = strftime(format, date);
10 0 RETVAL = strftime(format, date);
10 0 RETVAL = strftime(format, date);
383 3 0 RETVAL = THIS->error() ? false : true;
388 2 5 }
5 0 }
392 0 0 RETVAL = THIS->month_name();
395 0 0 string_view Date::month_sname ()
399 0 0 RETVAL = THIS->wday_name();
402 0 0 string_view Date::wday_sname ()
404 3 0 int Date::gmtoff ()
406 101 0 string_view Date::tzabbr ()
411 26 5 auto& zone = date ? date->timezone() : tzlocal();
26 0 auto& zone = date ? date->timezone() : tzlocal();
5 0 auto& zone = date ? date->timezone() : tzlocal();
412 31 0 RETVAL = zone->name;
416 15 0 RETVAL = THIS->timezone()->is_local;
420 15 2 if (newzone) {
421 2 15 THIS->timezone(newzone);
422 2 0 XSRETURN_UNDEF;
425 15 0 PERL_UNUSED_VAR(ix);
15 0 PERL_UNUSED_VAR(ix);
429 3 0 THIS->to_timezone(newzone);
434 0 2 auto cnt = THIS->mksec() ? 7 : 6;
435 2 0 EXTEND(SP, cnt);
0 2 EXTEND(SP, cnt);
0 0 EXTEND(SP, cnt);
436 2 0 mPUSHi(THIS->year());
2 0 mPUSHi(THIS->year());
2 0 mPUSHi(THIS->year());
437 2 0 mPUSHu(THIS->month());
2 0 mPUSHu(THIS->month());
2 0 mPUSHu(THIS->month());
438 2 0 mPUSHu(THIS->day());
2 0 mPUSHu(THIS->day());
2 0 mPUSHu(THIS->day());
439 2 0 mPUSHu(THIS->hour());
2 0 mPUSHu(THIS->hour());
2 0 mPUSHu(THIS->hour());
440 2 0 mPUSHu(THIS->min());
2 0 mPUSHu(THIS->min());
2 0 mPUSHu(THIS->min());
441 2 0 mPUSHu(THIS->sec());
2 0 mPUSHu(THIS->sec());
2 0 mPUSHu(THIS->sec());
442 0 2 if (THIS->mksec()) mPUSHu(THIS->mksec());
0 0 if (THIS->mksec()) mPUSHu(THIS->mksec());
0 0 if (THIS->mksec()) mPUSHu(THIS->mksec());
447 0 1 EXTEND(SP, 9);
456 0 1 mPUSHu(THIS->isdst() ? 1 : 0);
462 12 6 ptime_t vals[] = {-1, -1, -1, -1, -1, -1, -1, -1};
464 12 0 RETVAL = new Date(THIS->clone(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], tz));
465 12 0 }
12 0 }
12 0 }
467 6 0
6 0
469 1 17 auto err = RETVAL->error();
1 0 auto err = RETVAL->error();
1 0 auto err = RETVAL->error();
18 0 auto err = RETVAL->error();
1 17 auto err = RETVAL->error();
0 0 auto err = RETVAL->error();
471 1 0 throw xs::out(err);
472 1 0 }
475 17 0 }
17 0 }
484 4 0 PROTO = Object(ST(0)).stash();
4 0 PROTO = Object(ST(0)).stash();
4 0 PROTO = Object(ST(0)).stash();
485 4 0 }
4 0 }
494 4 0 PROTO = Object(ST(0)).stash();
4 0 PROTO = Object(ST(0)).stash();
4 0 PROTO = Object(ST(0)).stash();
495 4 0 }
4 0 }
498 4 0 RETVAL = THIS->days_in_month();
501 11 0 uint8_t Date::week_of_month ()
503 8 0 uint8_t Date::weeks_in_year ()
506 16 0 auto info = THIS->week_of_year();
508 16 0 if (GIMME_V == G_ARRAY) {
0 0 if (GIMME_V == G_ARRAY) {
8 8 if (GIMME_V == G_ARRAY) {
509 0 8 mXPUSHi(info.year);
0 0 mXPUSHi(info.year);
8 0 mXPUSHi(info.year);
8 0 mXPUSHi(info.year);
512 0 16 mXPUSHu(info.week);
0 0 mXPUSHu(info.week);
16 0 mXPUSHu(info.week);
16 0 mXPUSHu(info.week);
525 1 0 PROTO = Object(ST(0)).stash();
1 0 PROTO = Object(ST(0)).stash();
1 0 PROTO = Object(ST(0)).stash();
526 1 0 }
1 0 }
529 33 111 if (arg.is_ref() && !arg.is_object_ref()) XSRETURN_IV(-1); // avoid exception in typemap for wrong types
2 31 if (arg.is_ref() && !arg.is_object_ref()) XSRETURN_IV(-1); // avoid exception in typemap for wrong types
2 142 if (arg.is_ref() && !arg.is_object_ref()) XSRETURN_IV(-1); // avoid exception in typemap for wrong types
2 0 if (arg.is_ref() && !arg.is_object_ref()) XSRETURN_IV(-1); // avoid exception in typemap for wrong types
2 0 if (arg.is_ref() && !arg.is_object_ref()) XSRETURN_IV(-1); // avoid exception in typemap for wrong types
530 142 0 RETVAL = THIS->compare(sv2date(arg, THIS->timezone()));
140 2 RETVAL = THIS->compare(sv2date(arg, THIS->timezone()));
140 0 RETVAL = THIS->compare(sv2date(arg, THIS->timezone()));
531 14 126 if (reverse) RETVAL = -RETVAL;
532 20 120 if (RETVAL < 0) RETVAL = -1;
533 22 98 else if (RETVAL > 0) RETVAL = 1;
538 13 2 PROTO = Object(ST(0)).stash();
13 0 PROTO = Object(ST(0)).stash();
13 0 PROTO = Object(ST(0)).stash();
13 0 PROTO = Object(ST(0)).stash();
539 13 0 }
13 0 }
542 5 1 *THIS += sv2daterel(arg);
5 0 *THIS += sv2daterel(arg);
543 0 5 XSRETURN(1);
547 2 3 bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date";
2 0 bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date";
2 0 bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date";
2 0 bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date";
1 1 bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date";
2 3 bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date";
2 3 bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date";
0 0 bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date";
0 0 bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date";
548 1 4 if (is_date) RETVAL = xs::out(new DateRel(*xs::in(arg), *THIS));
1 0 if (is_date) RETVAL = xs::out(new DateRel(*xs::in(arg), *THIS));
1 0 if (is_date) RETVAL = xs::out(new DateRel(*xs::in(arg), *THIS));
1 0 if (is_date) RETVAL = xs::out(new DateRel(*xs::in(arg), *THIS));
1 0 if (is_date) RETVAL = xs::out(new DateRel(*xs::in(arg), *THIS));
549 0 4 else if (reverse) throw "wrong date operation";
550 4 0 else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash());
4 0 else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash());
3 1 else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash());
3 0 else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash());
3 0 else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash());
3 0 else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash());
3 0 else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash());
554 2 1 *THIS -= sv2daterel(arg);
2 0 *THIS -= sv2daterel(arg);
555 0 2 XSRETURN(1);
559 0 48 if (!items) throw "should not happen";