| 1 |
|
| #include <xs/date.h> |
| 2 |
|
| #include <xs/export.h> |
| 3 |
|
| #include "private.h" |
| 4 |
|
| |
| 5 |
|
| using namespace xs; |
| 6 |
|
| using namespace xs::date; |
| 7 |
|
| using panda::string; |
| 8 |
|
| using panda::string_view; |
| 9 |
|
| |
| 10 |
|
| #ifdef _WIN32 |
| 11 |
|
| const auto LT_FORMAT = string_view("%a %b %d %H:%M:%S %Y"); |
| 12 |
|
| #else |
| 13 |
|
| const auto LT_FORMAT = string_view("%a %b %e %H:%M:%S %Y"); |
| 14 |
|
| #endif |
| 15 |
|
| |
| 16 |
|
| // arguments overloading for new_ymd(), date_ymd(), ->set_ymd() |
| 17 |
32 |
| static inline Date xs_date_ymd (SV** args, I32 items) { |
| 18 |
32 |
| ptime_t vals[8] = {1970, 1, 1, 0, 0, 0, 0, -1}; |
| 19 |
32 |
▶ | auto tz = list2vals(args, items, vals); |
Branch: 1 branch
| Branch | True | False | Total |
| auto tz = list2vals(args, items, vals); |
32 |
0 |
32 |
|
| 20 |
32 |
▶ | auto ret = Date(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], tz); |
Branch: 1 branch
| Branch | True | False | Total |
| auto ret = Date(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], tz); |
32 |
0 |
32 |
|
| 21 |
32 |
▶ | if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
Branch: 5 branches
| Branch | True | False | Total |
| if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
3 |
29 |
32 |
| if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
3 |
0 |
3 |
| if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
3 |
0 |
3 |
| if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
3 |
29 |
32 |
| if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
3 |
0 |
3 |
|
| 22 |
58 |
| return ret; |
| 23 |
35 |
| } |
| 24 |
|
| |
| 25 |
|
| MODULE = Date::Date PACKAGE = Date |
| 26 |
|
| PROTOTYPES: DISABLE |
| 27 |
|
| |
| 28 |
|
| BOOT { |
| 29 |
48 |
▶ | Stash stash(__PACKAGE__); |
Branch: 1 branch
| Branch | True | False | Total |
| Stash stash(__PACKAGE__); |
48 |
0 |
48 |
|
| 30 |
|
| |
| 31 |
1200 |
▶ | xs::exp::create_constants(stash, { |
Branch: 4 branches
| Branch | True | False | Total |
| xs::exp::create_constants(stash, { |
48 |
0 |
48 |
| xs::exp::create_constants(stash, { |
48 |
0 |
48 |
| xs::exp::create_constants(stash, { |
1056 |
48 |
1104 |
| xs::exp::create_constants(stash, { |
0 |
0 |
0 |
|
| 32 |
|
| {"FORMAT_ISO", (int)Date::Format::iso}, |
| 33 |
|
| {"FORMAT_ISO_TZ", (int)Date::Format::iso_tz}, |
| 34 |
|
| {"FORMAT_ISO_DATE", (int)Date::Format::iso_date}, |
| 35 |
|
| {"FORMAT_ISO8601", (int)Date::Format::iso8601}, |
| 36 |
|
| {"FORMAT_ISO8601_NOTZ", (int)Date::Format::iso8601_notz}, |
| 37 |
|
| {"FORMAT_RFC1123", (int)Date::Format::rfc1123}, |
| 38 |
|
| {"FORMAT_COOKIE", (int)Date::Format::cookie}, |
| 39 |
|
| {"FORMAT_RFC850", (int)Date::Format::rfc850}, |
| 40 |
|
| {"FORMAT_ANSI_C", (int)Date::Format::ansi_c}, |
| 41 |
|
| {"FORMAT_YMD", (int)Date::Format::ymd}, |
| 42 |
|
| {"FORMAT_DOT", (int)Date::Format::dot}, |
| 43 |
|
| {"FORMAT_HMS", (int)Date::Format::hms}, |
| 44 |
|
| {"FORMAT_CLF", (int)Date::Format::clf}, |
| 45 |
|
| {"FORMAT_CLF_BRACKETS", (int)Date::Format::clfb}, |
| 46 |
|
| |
| 47 |
|
| {"INPUT_FORMAT_ALL", Date::InputFormat::all}, |
| 48 |
|
| {"INPUT_FORMAT_ISO", Date::InputFormat::iso}, |
| 49 |
|
| {"INPUT_FORMAT_ISO8601", Date::InputFormat::iso8601}, |
| 50 |
|
| {"INPUT_FORMAT_RFC1123", Date::InputFormat::rfc1123}, |
| 51 |
|
| {"INPUT_FORMAT_RFC850", Date::InputFormat::rfc850}, |
| 52 |
|
| {"INPUT_FORMAT_ANSI_C", Date::InputFormat::ansi_c}, |
| 53 |
|
| {"INPUT_FORMAT_DOT", Date::InputFormat::dot}, |
| 54 |
|
| {"INPUT_FORMAT_CLF", Date::InputFormat::clf}, |
| 55 |
|
| }); |
| 56 |
|
| |
| 57 |
48 |
▶ | Stash ecstash("Date::Error", GV_ADD); |
Branch: 1 branch
| Branch | True | False | Total |
| Stash ecstash("Date::Error", GV_ADD); |
48 |
0 |
48 |
|
| 58 |
144 |
▶ | xs::exp::create_constants(ecstash, { |
Branch: 4 branches
| Branch | True | False | Total |
| xs::exp::create_constants(ecstash, { |
48 |
0 |
48 |
| xs::exp::create_constants(ecstash, { |
48 |
0 |
48 |
| xs::exp::create_constants(ecstash, { |
96 |
48 |
144 |
| xs::exp::create_constants(ecstash, { |
0 |
0 |
0 |
|
| 59 |
96 |
▶ | {"parser_error", xs::out(make_error_code(errc::parser_error))}, |
Branch: 1 branch
| Branch | True | False | Total |
| {"parser_error", xs::out(make_error_code(errc::parser_error))}, |
48 |
0 |
48 |
|
| 60 |
96 |
▶ | {"out_of_range", xs::out(make_error_code(errc::out_of_range))}, |
Branch: 1 branch
| Branch | True | False | Total |
| {"out_of_range", xs::out(make_error_code(errc::out_of_range))}, |
48 |
0 |
48 |
|
| 61 |
|
| }); |
| 62 |
|
| |
| 63 |
48 |
▶ | stash.add_const_sub("error_category", xs::out<const std::error_category*>(&error_category)); |
Branch: 2 branches
| Branch | True | False | Total |
| stash.add_const_sub("error_category", xs::out<const std::error_category*>(&error_category)); |
48 |
0 |
48 |
| stash.add_const_sub("error_category", xs::out<const std::error_category*>(&error_category)); |
48 |
0 |
48 |
|
| 64 |
48 |
| } |
| 65 |
|
| |
| 66 |
|
| #///////////////////////////// STATIC FUNCTIONS /////////////////////////////////// |
| 67 |
|
| |
| 68 |
16 |
| const Timezone* tzget (string_view zonename = {}) |
| 69 |
16 |
▶ | |
Branch: 2 branches
| Branch | True | False | Total |
|
16 |
0 |
16 |
|
16 |
0 |
16 |
|
| 70 |
84 |
▶ | void tzset (TimezoneSP newzone = {}) |
Branch: 1 branch
| Branch | True | False | Total |
| void tzset (TimezoneSP newzone = {}) |
84 |
0 |
84 |
|
| 71 |
|
| |
| 72 |
|
| string tzdir (SV* newdir = NULL) { |
| 73 |
0 |
▶ | if (newdir) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (newdir) { |
0 |
0 |
0 |
|
| 74 |
0 |
▶ | tzdir(xs::in<string>(newdir)); |
Branch: 2 branches
| Branch | True | False | Total |
| tzdir(xs::in<string>(newdir)); |
0 |
0 |
0 |
| tzdir(xs::in<string>(newdir)); |
0 |
0 |
0 |
|
| 75 |
0 |
| XSRETURN_UNDEF; |
| 76 |
|
| } |
| 77 |
0 |
▶ | RETVAL = tzdir(); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = tzdir(); |
0 |
0 |
0 |
| RETVAL = tzdir(); |
0 |
0 |
0 |
|
| 78 |
|
| } |
| 79 |
|
| |
| 80 |
48 |
▶ | string tzsysdir () |
Branch: 2 branches
| Branch | True | False | Total |
| string tzsysdir () |
48 |
0 |
48 |
| string tzsysdir () |
48 |
0 |
48 |
|
| 81 |
|
| |
| 82 |
|
| string tzembededdir(SV* newdir = NULL) { |
| 83 |
102 |
▶ | if (newdir) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (newdir) { |
75 |
27 |
102 |
|
| 84 |
75 |
▶ | tzembededdir(xs::in<string>(newdir)); |
Branch: 2 branches
| Branch | True | False | Total |
| tzembededdir(xs::in<string>(newdir)); |
75 |
0 |
75 |
| tzembededdir(xs::in<string>(newdir)); |
75 |
0 |
75 |
|
| 85 |
75 |
| XSRETURN_UNDEF; |
| 86 |
|
| } |
| 87 |
27 |
▶ | RETVAL = tzembededdir(); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = tzembededdir(); |
27 |
0 |
27 |
| RETVAL = tzembededdir(); |
27 |
0 |
27 |
|
| 88 |
|
| } |
| 89 |
|
| |
| 90 |
|
| void available_timezones () { |
| 91 |
1 |
▶ | auto list = available_timezones(); |
Branch: 1 branch
| Branch | True | False | Total |
| auto list = available_timezones(); |
1 |
0 |
1 |
|
| 92 |
1 |
▶ | if (list.size()) EXTEND(SP, (int)list.size()); |
Branch: 5 branches
| Branch | True | False | Total |
| if (list.size()) EXTEND(SP, (int)list.size()); |
1 |
0 |
1 |
| if (list.size()) EXTEND(SP, (int)list.size()); |
1 |
0 |
1 |
| if (list.size()) EXTEND(SP, (int)list.size()); |
0 |
1 |
1 |
| if (list.size()) EXTEND(SP, (int)list.size()); |
0 |
1 |
1 |
| if (list.size()) EXTEND(SP, (int)list.size()); |
0 |
0 |
0 |
|
| 93 |
1213 |
▶ | for (auto& name : list) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (auto& name : list) { |
1212 |
1 |
1213 |
|
| 94 |
1212 |
▶ | mPUSHs(xs::out(name).detach()); |
Branch: 2 branches
| Branch | True | False | Total |
| mPUSHs(xs::out(name).detach()); |
1212 |
0 |
1212 |
| mPUSHs(xs::out(name).detach()); |
1212 |
0 |
1212 |
|
| 95 |
|
| } |
| 96 |
1 |
| XSRETURN(list.size()); |
| 97 |
|
| } |
| 98 |
|
| |
| 99 |
0 |
| void use_system_timezones () |
| 100 |
|
| |
| 101 |
75 |
| void use_embed_timezones () |
| 102 |
|
| |
| 103 |
|
| void gmtime (SV* epochSV = {}, TimezoneSP tz = {}) : ALIAS(localtime=1, anytime=2) { |
| 104 |
|
| ptime_t epoch; |
| 105 |
7 |
▶ | if (epochSV) epoch = xs::in<ptime_t>(epochSV); |
Branch: 2 branches
| Branch | True | False | Total |
| if (epochSV) epoch = xs::in<ptime_t>(epochSV); |
7 |
0 |
7 |
| if (epochSV) epoch = xs::in<ptime_t>(epochSV); |
7 |
0 |
7 |
|
| 106 |
0 |
| else epoch = (ptime_t) ::time(NULL); |
| 107 |
|
| |
| 108 |
|
| datetime date; |
| 109 |
7 |
| bool success = false; |
| 110 |
7 |
| switch (ix) { |
| 111 |
2 |
▶ | case 0: success = gmtime(epoch, &date); break; |
Branch: 1 branch
| Branch | True | False | Total |
| case 0: success = gmtime(epoch, &date); break; |
2 |
0 |
2 |
|
| 112 |
5 |
▶ | case 1: success = localtime(epoch, &date); break; |
Branch: 1 branch
| Branch | True | False | Total |
| case 1: success = localtime(epoch, &date); break; |
5 |
0 |
5 |
|
| 113 |
0 |
▶ | case 2: success = anytime(epoch, &date, tz ? tz : tzlocal()); break; |
Branch: 3 branches
| Branch | True | False | Total |
| case 2: success = anytime(epoch, &date, tz ? tz : tzlocal()); break; |
0 |
0 |
0 |
| case 2: success = anytime(epoch, &date, tz ? tz : tzlocal()); break; |
0 |
0 |
0 |
| case 2: success = anytime(epoch, &date, tz ? tz : tzlocal()); break; |
0 |
0 |
0 |
|
| 114 |
|
| } |
| 115 |
|
| |
| 116 |
7 |
▶ | if (GIMME_V == G_ARRAY) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (GIMME_V == G_ARRAY) { |
5 |
2 |
7 |
|
| 117 |
5 |
▶ | if (!success) XSRETURN_EMPTY; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!success) XSRETURN_EMPTY; |
0 |
5 |
5 |
|
| 118 |
5 |
▶ | EXTEND(SP, 9); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(SP, 9); |
0 |
5 |
5 |
| EXTEND(SP, 9); |
0 |
0 |
0 |
|
| 119 |
5 |
▶ | EXTEND_MORTAL(9); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND_MORTAL(9); |
0 |
5 |
5 |
| EXTEND_MORTAL(9); |
0 |
0 |
0 |
|
| 120 |
5 |
▶ | mPUSHu(date.sec); |
Branch: 2 branches
| Branch | True | False | Total |
| mPUSHu(date.sec); |
5 |
0 |
5 |
| mPUSHu(date.sec); |
5 |
0 |
5 |
|
| 121 |
5 |
▶ | mPUSHu(date.min); |
Branch: 2 branches
| Branch | True | False | Total |
| mPUSHu(date.min); |
5 |
0 |
5 |
| mPUSHu(date.min); |
5 |
0 |
5 |
|
| 122 |
5 |
▶ | mPUSHu(date.hour); |
Branch: 2 branches
| Branch | True | False | Total |
| mPUSHu(date.hour); |
5 |
0 |
5 |
| mPUSHu(date.hour); |
5 |
0 |
5 |
|
| 123 |
5 |
▶ | mPUSHu(date.mday); |
Branch: 2 branches
| Branch | True | False | Total |
| mPUSHu(date.mday); |
5 |
0 |
5 |
| mPUSHu(date.mday); |
5 |
0 |
5 |
|
| 124 |
5 |
▶ | mPUSHu(date.mon); |
Branch: 2 branches
| Branch | True | False | Total |
| mPUSHu(date.mon); |
5 |
0 |
5 |
| mPUSHu(date.mon); |
5 |
0 |
5 |
|
| 125 |
5 |
▶ | mPUSHi(date.year); |
Branch: 2 branches
| Branch | True | False | Total |
| mPUSHi(date.year); |
5 |
0 |
5 |
| mPUSHi(date.year); |
5 |
0 |
5 |
|
| 126 |
5 |
▶ | mPUSHu(date.wday); |
Branch: 2 branches
| Branch | True | False | Total |
| mPUSHu(date.wday); |
5 |
0 |
5 |
| mPUSHu(date.wday); |
5 |
0 |
5 |
|
| 127 |
5 |
▶ | mPUSHu(date.yday); |
Branch: 2 branches
| Branch | True | False | Total |
| mPUSHu(date.yday); |
5 |
0 |
5 |
| mPUSHu(date.yday); |
5 |
0 |
5 |
|
| 128 |
5 |
▶ | mPUSHu(date.isdst); |
Branch: 2 branches
| Branch | True | False | Total |
| mPUSHu(date.isdst); |
5 |
0 |
5 |
| mPUSHu(date.isdst); |
5 |
0 |
5 |
|
| 129 |
5 |
| XSRETURN(9); |
| 130 |
|
| } else { |
| 131 |
2 |
▶ | EXTEND(SP, 1); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(SP, 1); |
0 |
2 |
2 |
| EXTEND(SP, 1); |
0 |
0 |
0 |
|
| 132 |
2 |
▶ | if (!success) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!success) XSRETURN_UNDEF; |
0 |
2 |
2 |
|
| 133 |
2 |
▶ | mPUSHs(xs::out(strftime(LT_FORMAT, date)).detach()); |
Branch: 3 branches
| Branch | True | False | Total |
| mPUSHs(xs::out(strftime(LT_FORMAT, date)).detach()); |
2 |
0 |
2 |
| mPUSHs(xs::out(strftime(LT_FORMAT, date)).detach()); |
2 |
0 |
2 |
| mPUSHs(xs::out(strftime(LT_FORMAT, date)).detach()); |
2 |
0 |
2 |
|
| 134 |
2 |
| XSRETURN(1); |
| 135 |
|
| } |
| 136 |
|
| } |
| 137 |
|
| |
| 138 |
|
| ptime_t timegm (SV* sec, SV* min, SV* hour, SV* mday, SV* mon, SV* year, SV* isdst = {}, TimezoneSP tz = {}) : ALIAS(timelocal=1, timeany=2, timegmn=3, timelocaln=4, timeanyn=5) { |
| 139 |
10 |
| datetime date; |
| 140 |
|
| date.sec = xs::in<ptime_t>(sec); |
| 141 |
10 |
▶ | date.min = xs::in<ptime_t>(min); |
Branch: 1 branch
| Branch | True | False | Total |
| date.min = xs::in<ptime_t>(min); |
10 |
0 |
10 |
|
| 142 |
10 |
▶ | date.hour = xs::in<ptime_t>(hour); |
Branch: 1 branch
| Branch | True | False | Total |
| date.hour = xs::in<ptime_t>(hour); |
10 |
0 |
10 |
|
| 143 |
10 |
▶ | date.mday = xs::in<ptime_t>(mday); |
Branch: 1 branch
| Branch | True | False | Total |
| date.mday = xs::in<ptime_t>(mday); |
10 |
0 |
10 |
|
| 144 |
10 |
▶ | date.mon = xs::in<ptime_t>(mon); |
Branch: 1 branch
| Branch | True | False | Total |
| date.mon = xs::in<ptime_t>(mon); |
10 |
0 |
10 |
|
| 145 |
10 |
▶ | date.year = xs::in<ptime_t>(year); |
Branch: 1 branch
| Branch | True | False | Total |
| date.year = xs::in<ptime_t>(year); |
10 |
0 |
10 |
|
| 146 |
10 |
▶ | |
Branch: 1 branch
| Branch | True | False | Total |
|
10 |
0 |
10 |
|
| 147 |
|
| if (isdst) date.isdst = SvIV(isdst); |
| 148 |
10 |
▶ | else date.isdst = -1; |
Branch: 2 branches
| Branch | True | False | Total |
| else date.isdst = -1; |
4 |
6 |
10 |
| else date.isdst = -1; |
4 |
0 |
4 |
|
| 149 |
6 |
| |
| 150 |
|
| switch (ix) { |
| 151 |
10 |
| case 0: RETVAL = timegml(&date); break; |
| 152 |
1 |
▶ | case 1: RETVAL = timelocall(&date); break; |
Branch: 1 branch
| Branch | True | False | Total |
| case 1: RETVAL = timelocall(&date); break; |
1 |
0 |
1 |
|
| 153 |
5 |
▶ | case 2: RETVAL = timeanyl(&date, tz ? tz : tzlocal()); break; |
Branch: 1 branch
| Branch | True | False | Total |
| case 2: RETVAL = timeanyl(&date, tz ? tz : tzlocal()); break; |
5 |
0 |
5 |
|
| 154 |
0 |
▶ | case 3: RETVAL = timegm(&date); break; |
Branch: 3 branches
| Branch | True | False | Total |
| case 3: RETVAL = timegm(&date); break; |
0 |
0 |
0 |
| case 3: RETVAL = timegm(&date); break; |
0 |
0 |
0 |
| case 3: RETVAL = timegm(&date); break; |
0 |
0 |
0 |
|
| 155 |
2 |
▶ | case 4: RETVAL = timelocal(&date); break; |
Branch: 1 branch
| Branch | True | False | Total |
| case 4: RETVAL = timelocal(&date); break; |
2 |
0 |
2 |
|
| 156 |
2 |
▶ | case 5: RETVAL = timeany(&date, tz ? tz : tzlocal()); break; |
Branch: 1 branch
| Branch | True | False | Total |
| case 5: RETVAL = timeany(&date, tz ? tz : tzlocal()); break; |
2 |
0 |
2 |
|
| 157 |
0 |
▶ | default: croak("not reached"); |
Branch: 3 branches
| Branch | True | False | Total |
| default: croak("not reached"); |
0 |
0 |
0 |
| default: croak("not reached"); |
0 |
0 |
0 |
| default: croak("not reached"); |
0 |
0 |
0 |
|
| 158 |
0 |
| } |
| 159 |
|
| |
| 160 |
|
| if (ix >= 3) { |
| 161 |
10 |
▶ | sv_setiv(sec, date.sec); |
Branch: 1 branch
| Branch | True | False | Total |
| sv_setiv(sec, date.sec); |
4 |
6 |
10 |
|
| 162 |
4 |
▶ | sv_setiv(min, date.min); |
Branch: 1 branch
| Branch | True | False | Total |
| sv_setiv(min, date.min); |
3 |
0 |
3 |
|
| 163 |
3 |
▶ | sv_setiv(hour, date.hour); |
Branch: 1 branch
| Branch | True | False | Total |
| sv_setiv(hour, date.hour); |
3 |
0 |
3 |
|
| 164 |
3 |
▶ | sv_setiv(mday, date.mday); |
Branch: 1 branch
| Branch | True | False | Total |
| sv_setiv(mday, date.mday); |
3 |
0 |
3 |
|
| 165 |
3 |
▶ | sv_setiv(mon, date.mon); |
Branch: 1 branch
| Branch | True | False | Total |
| sv_setiv(mon, date.mon); |
3 |
0 |
3 |
|
| 166 |
3 |
▶ | sv_setiv(year, date.year); |
Branch: 1 branch
| Branch | True | False | Total |
| sv_setiv(year, date.year); |
3 |
0 |
3 |
|
| 167 |
3 |
▶ | if (isdst) sv_setiv(isdst, date.isdst); |
Branch: 1 branch
| Branch | True | False | Total |
| if (isdst) sv_setiv(isdst, date.isdst); |
3 |
0 |
3 |
|
| 168 |
3 |
▶ | } |
Branch: 2 branches
| Branch | True | False | Total |
| } |
2 |
1 |
3 |
| } |
2 |
0 |
2 |
|
| 169 |
|
| } |
| 170 |
|
| |
| 171 |
|
| Date* now () { |
| 172 |
5 |
| RETVAL = new Date(Date::now()); |
| 173 |
5 |
▶ | } |
Branch: 4 branches
| Branch | True | False | Total |
| } |
5 |
0 |
5 |
| } |
5 |
0 |
5 |
| } |
5 |
0 |
5 |
| } |
0 |
0 |
0 |
|
| 174 |
|
| |
| 175 |
|
| Date* now_hires () { |
| 176 |
2 |
| RETVAL = new Date(Date::now_hires()); |
| 177 |
2 |
▶ | } |
Branch: 4 branches
| Branch | True | False | Total |
| } |
2 |
0 |
2 |
| } |
2 |
0 |
2 |
| } |
2 |
0 |
2 |
| } |
0 |
0 |
0 |
|
| 178 |
|
| |
| 179 |
|
| Date* today () { |
| 180 |
2 |
| RETVAL = new Date(Date::today()); |
| 181 |
2 |
▶ | } |
Branch: 4 branches
| Branch | True | False | Total |
| } |
2 |
0 |
2 |
| } |
2 |
0 |
2 |
| } |
2 |
0 |
2 |
| } |
0 |
0 |
0 |
|
| 182 |
|
| |
| 183 |
|
| ptime_t today_epoch () { |
| 184 |
1 |
| RETVAL = Date::today_epoch(); |
| 185 |
1 |
▶ | } |
Branch: 2 branches
| Branch | True | False | Total |
| } |
1 |
0 |
1 |
| } |
1 |
0 |
1 |
|
| 186 |
|
| |
| 187 |
|
| Date* date (SV* val = {}, TimezoneSP tz = {}, int fmt = Date::InputFormat::all) { |
| 188 |
302 |
| RETVAL = new Date(sv2date(val, tz, fmt)); |
| 189 |
309 |
▶ | } |
Branch: 4 branches
| Branch | True | False | Total |
| } |
302 |
0 |
302 |
| } |
295 |
7 |
302 |
| } |
295 |
0 |
295 |
| } |
7 |
0 |
7 |
|
| 190 |
|
| |
| 191 |
|
| Date* date_ymd (...) { |
| 192 |
17 |
| RETVAL = new Date(xs_date_ymd(&ST(0), items)); |
| 193 |
17 |
▶ | } |
Branch: 4 branches
| Branch | True | False | Total |
| } |
17 |
0 |
17 |
| } |
16 |
1 |
17 |
| } |
16 |
0 |
16 |
| } |
1 |
0 |
1 |
|
| 194 |
|
| |
| 195 |
|
| bool range_check (Sv newval = {}) { |
| 196 |
5 |
▶ | if (newval) Date::range_check(newval.is_true()); |
Branch: 2 branches
| Branch | True | False | Total |
| if (newval) Date::range_check(newval.is_true()); |
3 |
2 |
5 |
| if (newval) Date::range_check(newval.is_true()); |
3 |
0 |
3 |
|
| 197 |
5 |
| RETVAL = Date::range_check(); |
| 198 |
|
| } |
| 199 |
|
| |
| 200 |
|
| #///////////////////////////// OBJECT METHODS /////////////////////////////////// |
| 201 |
|
| |
| 202 |
|
| Date* new (SV*, SV* val = {}, TimezoneSP tz = {}, int fmt = Date::InputFormat::all) { |
| 203 |
40 |
| RETVAL = new Date(sv2date(val, tz, fmt)); |
| 204 |
42 |
▶ | } |
Branch: 4 branches
| Branch | True | False | Total |
| } |
40 |
0 |
40 |
| } |
38 |
2 |
40 |
| } |
38 |
0 |
38 |
| } |
2 |
0 |
2 |
|
| 205 |
|
| |
| 206 |
|
| Date* new_ymd (...) { |
| 207 |
12 |
| RETVAL = new Date(xs_date_ymd(&ST(1), items - 1)); |
| 208 |
12 |
▶ | } |
Branch: 4 branches
| Branch | True | False | Total |
| } |
12 |
0 |
12 |
| } |
11 |
1 |
12 |
| } |
11 |
0 |
11 |
| } |
1 |
0 |
1 |
|
| 209 |
|
| |
| 210 |
|
| Date* strptime (string date, string format) { |
| 211 |
1 |
| RETVAL = new Date(Date::strptime(date, format)); |
| 212 |
1 |
▶ | } |
Branch: 4 branches
| Branch | True | False | Total |
| } |
1 |
0 |
1 |
| } |
1 |
0 |
1 |
| } |
1 |
0 |
1 |
| } |
0 |
0 |
0 |
|
| 213 |
|
| |
| 214 |
|
| void Date::set (SV* val = {}, TimezoneSP tz = {}, int fmt = Date::InputFormat::all) { |
| 215 |
11 |
▶ | THIS->set(sv2date(val, tz, fmt)); |
Branch: 2 branches
| Branch | True | False | Total |
| THIS->set(sv2date(val, tz, fmt)); |
5 |
2 |
7 |
| THIS->set(sv2date(val, tz, fmt)); |
5 |
0 |
5 |
|
| 216 |
|
| } |
| 217 |
|
| |
| 218 |
|
| void Date::set_ymd (...) { |
| 219 |
3 |
▶ | THIS->set(xs_date_ymd(&ST(1), items - 1)); |
Branch: 2 branches
| Branch | True | False | Total |
| THIS->set(xs_date_ymd(&ST(1), items - 1)); |
2 |
1 |
3 |
| THIS->set(xs_date_ymd(&ST(1), items - 1)); |
2 |
0 |
2 |
|
| 220 |
|
| } |
| 221 |
|
| |
| 222 |
|
| void Date::epoch (SV* newval = NULL) { |
| 223 |
207 |
▶ | if (newval) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) { |
1 |
206 |
207 |
|
| 224 |
1 |
▶ | if (SvNOK(newval)) THIS->epoch((double)SvNV(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvNOK(newval)) THIS->epoch((double)SvNV(newval)); |
1 |
0 |
1 |
|
| 225 |
0 |
| else THIS->epoch(xs::in<ptime_t>(newval)); |
| 226 |
1 |
| XSRETURN(1); |
| 227 |
|
| } |
| 228 |
206 |
▶ | dXSTARG; XSprePUSH; |
Branch: 1 branch
| Branch | True | False | Total |
| dXSTARG; XSprePUSH; |
206 |
0 |
206 |
|
| 229 |
206 |
▶ | if (THIS->mksec()) PUSHn(THIS->epoch_mks()); |
Branch: 2 branches
| Branch | True | False | Total |
| if (THIS->mksec()) PUSHn(THIS->epoch_mks()); |
28 |
178 |
206 |
| if (THIS->mksec()) PUSHn(THIS->epoch_mks()); |
0 |
28 |
28 |
|
| 230 |
178 |
▶ | else PUSHi(THIS->epoch()); |
Branch: 1 branch
| Branch | True | False | Total |
| else PUSHi(THIS->epoch()); |
8 |
170 |
178 |
|
| 231 |
|
| } |
| 232 |
|
| |
| 233 |
|
| ptime_t Date::epoch_sec () { |
| 234 |
0 |
| RETVAL = THIS->epoch(); |
| 235 |
0 |
▶ | } |
Branch: 2 branches
| Branch | True | False | Total |
| } |
0 |
0 |
0 |
| } |
0 |
0 |
0 |
|
| 236 |
|
| |
| 237 |
|
| int32_t Date::year (SV* newval = NULL) { |
| 238 |
24 |
▶ | if (newval) THIS->year(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->year(xs::in<ptime_t>(newval)); |
7 |
17 |
24 |
|
| 239 |
24 |
▶ | RETVAL = THIS->year(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->year(); |
0 |
24 |
24 |
|
| 240 |
|
| } |
| 241 |
|
| |
| 242 |
|
| int32_t Date::c_year (SV* newval = NULL) : ALIAS(_year=1) { |
| 243 |
|
| PERL_UNUSED_VAR(ix); |
| 244 |
3 |
▶ | if (newval) THIS->c_year(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->c_year(xs::in<ptime_t>(newval)); |
0 |
3 |
3 |
|
| 245 |
3 |
▶ | RETVAL = THIS->c_year(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->c_year(); |
0 |
3 |
3 |
|
| 246 |
|
| } |
| 247 |
|
| |
| 248 |
|
| int8_t Date::yr (SV* newval = NULL) { |
| 249 |
3 |
▶ | if (newval) THIS->yr(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->yr(xs::in<ptime_t>(newval)); |
0 |
3 |
3 |
|
| 250 |
3 |
▶ | RETVAL = THIS->yr(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->yr(); |
0 |
3 |
3 |
|
| 251 |
|
| } |
| 252 |
|
| |
| 253 |
|
| uint8_t Date::month (SV* newval = NULL) : ALIAS(mon=1) { |
| 254 |
|
| PERL_UNUSED_VAR(ix); |
| 255 |
18 |
▶ | if (newval) THIS->month(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->month(xs::in<ptime_t>(newval)); |
0 |
18 |
18 |
|
| 256 |
18 |
▶ | RETVAL = THIS->month(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->month(); |
0 |
18 |
18 |
|
| 257 |
|
| } |
| 258 |
|
| |
| 259 |
|
| uint8_t Date::c_month (SV* newval = NULL) : ALIAS(c_mon=1, _mon=2, _month=3) { |
| 260 |
|
| PERL_UNUSED_VAR(ix); |
| 261 |
2 |
▶ | if (newval) THIS->c_month(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->c_month(xs::in<ptime_t>(newval)); |
0 |
2 |
2 |
|
| 262 |
2 |
▶ | RETVAL = THIS->c_month(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->c_month(); |
0 |
2 |
2 |
|
| 263 |
|
| } |
| 264 |
|
| |
| 265 |
|
| uint8_t Date::day (SV* newval = NULL) : ALIAS(mday=1, day_of_month=2) { |
| 266 |
|
| PERL_UNUSED_VAR(ix); |
| 267 |
28 |
▶ | if (newval) THIS->day(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->day(xs::in<ptime_t>(newval)); |
10 |
18 |
28 |
|
| 268 |
28 |
▶ | RETVAL = THIS->day(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->day(); |
0 |
28 |
28 |
|
| 269 |
|
| } |
| 270 |
|
| |
| 271 |
|
| uint8_t Date::hour (SV* newval = NULL) { |
| 272 |
7 |
▶ | if (newval) THIS->hour(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->hour(xs::in<ptime_t>(newval)); |
0 |
7 |
7 |
|
| 273 |
7 |
▶ | RETVAL = THIS->hour(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->hour(); |
0 |
7 |
7 |
|
| 274 |
|
| } |
| 275 |
|
| |
| 276 |
|
| uint8_t Date::min (SV* newval = NULL) : ALIAS(minute=1) { |
| 277 |
|
| PERL_UNUSED_VAR(ix); |
| 278 |
8 |
▶ | if (newval) THIS->min(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->min(xs::in<ptime_t>(newval)); |
0 |
8 |
8 |
|
| 279 |
8 |
▶ | RETVAL = THIS->min(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->min(); |
0 |
8 |
8 |
|
| 280 |
|
| } |
| 281 |
|
| |
| 282 |
|
| uint8_t Date::sec (SV* newval = NULL) : ALIAS(second=1) { |
| 283 |
|
| PERL_UNUSED_VAR(ix); |
| 284 |
8 |
▶ | if (newval) THIS->sec(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->sec(xs::in<ptime_t>(newval)); |
0 |
8 |
8 |
|
| 285 |
8 |
▶ | RETVAL = THIS->sec(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->sec(); |
0 |
8 |
8 |
|
| 286 |
|
| } |
| 287 |
|
| |
| 288 |
|
| uint32_t Date::mksec (SV* newval = NULL) { |
| 289 |
8 |
▶ | if (newval) THIS->mksec(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->mksec(xs::in<ptime_t>(newval)); |
0 |
8 |
8 |
|
| 290 |
8 |
| RETVAL = THIS->mksec(); |
| 291 |
|
| } |
| 292 |
|
| |
| 293 |
|
| uint8_t Date::wday (SV* newval = NULL) : ALIAS(day_of_week=1) { |
| 294 |
|
| PERL_UNUSED_VAR(ix); |
| 295 |
4 |
▶ | if (newval) THIS->wday(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->wday(xs::in<ptime_t>(newval)); |
0 |
4 |
4 |
|
| 296 |
4 |
▶ | RETVAL = THIS->wday(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->wday(); |
0 |
4 |
4 |
|
| 297 |
|
| } |
| 298 |
|
| |
| 299 |
|
| uint8_t Date::c_wday (SV* newval = NULL) : ALIAS(_wday=1) { |
| 300 |
|
| PERL_UNUSED_VAR(ix); |
| 301 |
2 |
▶ | if (newval) THIS->c_wday(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->c_wday(xs::in<ptime_t>(newval)); |
0 |
2 |
2 |
|
| 302 |
2 |
▶ | RETVAL = THIS->c_wday(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->c_wday(); |
0 |
2 |
2 |
|
| 303 |
|
| } |
| 304 |
|
| |
| 305 |
|
| uint8_t Date::ewday (SV* newval = NULL) { |
| 306 |
2 |
▶ | if (newval) THIS->ewday(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->ewday(xs::in<ptime_t>(newval)); |
0 |
2 |
2 |
|
| 307 |
2 |
▶ | RETVAL = THIS->ewday(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->ewday(); |
0 |
2 |
2 |
|
| 308 |
|
| } |
| 309 |
|
| |
| 310 |
|
| uint16_t Date::yday (SV* newval = NULL) : ALIAS(day_of_year=1) { |
| 311 |
|
| PERL_UNUSED_VAR(ix); |
| 312 |
2 |
▶ | if (newval) THIS->yday(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->yday(xs::in<ptime_t>(newval)); |
0 |
2 |
2 |
|
| 313 |
2 |
▶ | RETVAL = THIS->yday(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->yday(); |
0 |
2 |
2 |
|
| 314 |
|
| } |
| 315 |
|
| |
| 316 |
|
| uint16_t Date::c_yday (SV* newval = NULL) : ALIAS(_yday=1) { |
| 317 |
|
| PERL_UNUSED_VAR(ix); |
| 318 |
1 |
▶ | if (newval) THIS->c_yday(xs::in<ptime_t>(newval)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (newval) THIS->c_yday(xs::in<ptime_t>(newval)); |
0 |
1 |
1 |
|
| 319 |
1 |
▶ | RETVAL = THIS->c_yday(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->c_yday(); |
0 |
1 |
1 |
|
| 320 |
|
| } |
| 321 |
|
| |
| 322 |
|
| bool Date::isdst () : ALIAS(daylight_savings=1) { |
| 323 |
|
| PERL_UNUSED_VAR(ix); |
| 324 |
6 |
▶ | RETVAL = THIS->isdst(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->isdst(); |
2 |
4 |
6 |
|
| 325 |
|
| } |
| 326 |
|
| |
| 327 |
|
| string Date::to_string (int format = (int)Date::Format::iso) { |
| 328 |
47 |
▶ | if (THIS->error()) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (THIS->error()) XSRETURN_UNDEF; |
2 |
45 |
47 |
|
| 329 |
45 |
▶ | RETVAL = THIS->to_string((Date::Format)format); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = THIS->to_string((Date::Format)format); |
45 |
0 |
45 |
| RETVAL = THIS->to_string((Date::Format)format); |
45 |
0 |
45 |
|
| 330 |
|
| } |
| 331 |
|
| |
| 332 |
|
| string Date::_op_str (...) { |
| 333 |
8 |
▶ | if (THIS->error()) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (THIS->error()) XSRETURN_UNDEF; |
0 |
8 |
8 |
|
| 334 |
8 |
▶ | RETVAL = THIS->to_string(); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = THIS->to_string(); |
8 |
0 |
8 |
| RETVAL = THIS->to_string(); |
8 |
0 |
8 |
|
| 335 |
|
| } |
| 336 |
|
| |
| 337 |
|
| #// $date->strftime($format) |
| 338 |
|
| #// Date::strftime($format, $epoch, [$timezone]) |
| 339 |
|
| #// Date::strftime($format, $sec, $min, $hour, $mday, $mon, $year, [$isdst], [$timezone]) |
| 340 |
|
| string strftime (Sv arg0, SV* arg1, ...) { |
| 341 |
11 |
▶ | if (items == 2 && arg0.is_object_ref()) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (items == 2 && arg0.is_object_ref()) { |
4 |
7 |
11 |
| if (items == 2 && arg0.is_object_ref()) { |
1 |
3 |
4 |
| if (items == 2 && arg0.is_object_ref()) { |
1 |
10 |
11 |
|
| 342 |
1 |
▶ | auto THIS = xs::in<Date*>(arg0); |
Branch: 1 branch
| Branch | True | False | Total |
| auto THIS = xs::in<Date*>(arg0); |
1 |
0 |
1 |
|
| 343 |
1 |
▶ | RETVAL = THIS->strftime(xs::in<string_view>(arg1)); |
Branch: 3 branches
| Branch | True | False | Total |
| RETVAL = THIS->strftime(xs::in<string_view>(arg1)); |
1 |
0 |
1 |
| RETVAL = THIS->strftime(xs::in<string_view>(arg1)); |
1 |
0 |
1 |
| RETVAL = THIS->strftime(xs::in<string_view>(arg1)); |
1 |
0 |
1 |
|
| 344 |
|
| } |
| 345 |
|
| else { |
| 346 |
10 |
▶ | string_view format = xs::in<string_view>(arg0); |
Branch: 1 branch
| Branch | True | False | Total |
| string_view format = xs::in<string_view>(arg0); |
10 |
0 |
10 |
|
| 347 |
10 |
| TimezoneSP tz; |
| 348 |
|
| datetime date; |
| 349 |
10 |
| date.isdst = -1; |
| 350 |
|
| |
| 351 |
10 |
| switch (items) { |
| 352 |
2 |
▶ | case 9: tz = xs::in<TimezoneSP>(ST(8)); // fall through |
Branch: 1 branch
| Branch | True | False | Total |
| case 9: tz = xs::in<TimezoneSP>(ST(8)); // fall through |
2 |
0 |
2 |
|
| 353 |
2 |
▶ | case 8: date.isdst = SvIV(ST(7)); // fall through |
Branch: 1 branch
| Branch | True | False | Total |
| case 8: date.isdst = SvIV(ST(7)); // fall through |
2 |
0 |
2 |
|
| 354 |
5 |
| case 7: |
| 355 |
5 |
▶ | date.sec = xs::in<ptime_t>(ST(1)); |
Branch: 1 branch
| Branch | True | False | Total |
| date.sec = xs::in<ptime_t>(ST(1)); |
5 |
0 |
5 |
|
| 356 |
5 |
▶ | date.min = xs::in<ptime_t>(ST(2)); |
Branch: 1 branch
| Branch | True | False | Total |
| date.min = xs::in<ptime_t>(ST(2)); |
5 |
0 |
5 |
|
| 357 |
5 |
▶ | date.hour = xs::in<ptime_t>(ST(3)); |
Branch: 1 branch
| Branch | True | False | Total |
| date.hour = xs::in<ptime_t>(ST(3)); |
5 |
0 |
5 |
|
| 358 |
5 |
▶ | date.mday = xs::in<ptime_t>(ST(4)); |
Branch: 1 branch
| Branch | True | False | Total |
| date.mday = xs::in<ptime_t>(ST(4)); |
5 |
0 |
5 |
|
| 359 |
5 |
▶ | date.mon = xs::in<ptime_t>(ST(5)); |
Branch: 1 branch
| Branch | True | False | Total |
| date.mon = xs::in<ptime_t>(ST(5)); |
5 |
0 |
5 |
|
| 360 |
5 |
▶ | date.year = xs::in<ptime_t>(ST(6)); |
Branch: 1 branch
| Branch | True | False | Total |
| date.year = xs::in<ptime_t>(ST(6)); |
5 |
0 |
5 |
|
| 361 |
5 |
▶ | timeany(&date, tz ? tz : tzlocal()); |
Branch: 3 branches
| Branch | True | False | Total |
| timeany(&date, tz ? tz : tzlocal()); |
2 |
3 |
5 |
| timeany(&date, tz ? tz : tzlocal()); |
3 |
0 |
3 |
| timeany(&date, tz ? tz : tzlocal()); |
5 |
0 |
5 |
|
| 362 |
5 |
| break; |
| 363 |
2 |
▶ | case 3: tz = xs::in<TimezoneSP>(ST(2)); // fall through |
Branch: 1 branch
| Branch | True | False | Total |
| case 3: tz = xs::in<TimezoneSP>(ST(2)); // fall through |
2 |
0 |
2 |
|
| 364 |
5 |
| case 2: { |
| 365 |
5 |
▶ | auto epoch = xs::in<ptime_t>(arg1); |
Branch: 1 branch
| Branch | True | False | Total |
| auto epoch = xs::in<ptime_t>(arg1); |
5 |
0 |
5 |
|
| 366 |
5 |
▶ | if (!anytime(epoch, &date, tz ? tz : tzlocal())) XSRETURN_UNDEF; |
Branch: 4 branches
| Branch | True | False | Total |
| if (!anytime(epoch, &date, tz ? tz : tzlocal())) XSRETURN_UNDEF; |
2 |
3 |
5 |
| if (!anytime(epoch, &date, tz ? tz : tzlocal())) XSRETURN_UNDEF; |
3 |
0 |
3 |
| if (!anytime(epoch, &date, tz ? tz : tzlocal())) XSRETURN_UNDEF; |
5 |
0 |
5 |
| if (!anytime(epoch, &date, tz ? tz : tzlocal())) XSRETURN_UNDEF; |
0 |
5 |
5 |
|
| 367 |
5 |
| break; |
| 368 |
|
| } |
| 369 |
0 |
| default: |
| 370 |
0 |
| throw "wrong number of arguments"; |
| 371 |
|
| } |
| 372 |
10 |
▶ | RETVAL = strftime(format, date); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = strftime(format, date); |
10 |
0 |
10 |
| RETVAL = strftime(format, date); |
10 |
0 |
10 |
|
| 373 |
10 |
▶ | } |
Branch: 1 branch
| Branch | True | False | Total |
| } |
10 |
0 |
10 |
|
| 374 |
|
| } |
| 375 |
|
| |
| 376 |
|
| bool Date::to_bool (...) { |
| 377 |
3 |
▶ | RETVAL = THIS->error() ? false : true; |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = THIS->error() ? false : true; |
3 |
0 |
3 |
| RETVAL = THIS->error() ? false : true; |
0 |
3 |
3 |
|
| 378 |
|
| } |
| 379 |
|
| |
| 380 |
|
| ptime_t Date::to_number (...) { |
| 381 |
7 |
| RETVAL = THIS->error() ? 0 : THIS->epoch(); |
| 382 |
7 |
▶ | } |
Branch: 3 branches
| Branch | True | False | Total |
| } |
2 |
5 |
7 |
| } |
5 |
0 |
5 |
| } |
7 |
0 |
7 |
|
| 383 |
|
| |
| 384 |
|
| string_view Date::month_name () : ALIAS(monname=1, monthname=2) { |
| 385 |
|
| PERL_UNUSED_VAR(ix); |
| 386 |
0 |
▶ | RETVAL = THIS->month_name(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->month_name(); |
0 |
0 |
0 |
|
| 387 |
|
| } |
| 388 |
|
| |
| 389 |
0 |
▶ | string_view Date::month_sname () |
Branch: 1 branch
| Branch | True | False | Total |
| string_view Date::month_sname () |
0 |
0 |
0 |
|
| 390 |
|
| |
| 391 |
|
| string_view Date::wday_name () : ALIAS(day_of_weekname=1, wdayname=2) { |
| 392 |
|
| PERL_UNUSED_VAR(ix); |
| 393 |
0 |
▶ | RETVAL = THIS->wday_name(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->wday_name(); |
0 |
0 |
0 |
|
| 394 |
|
| } |
| 395 |
|
| |
| 396 |
0 |
▶ | string_view Date::wday_sname () |
Branch: 1 branch
| Branch | True | False | Total |
| string_view Date::wday_sname () |
0 |
0 |
0 |
|
| 397 |
|
| |
| 398 |
3 |
▶ | int Date::gmtoff () |
Branch: 1 branch
| Branch | True | False | Total |
| int Date::gmtoff () |
0 |
3 |
3 |
|
| 399 |
|
| |
| 400 |
102 |
▶ | string_view Date::tzabbr () |
Branch: 1 branch
| Branch | True | False | Total |
| string_view Date::tzabbr () |
102 |
0 |
102 |
|
| 401 |
|
| |
| 402 |
|
| #// Date::tzname() |
| 403 |
|
| #// $date->tzname() |
| 404 |
|
| string tzname (Date* date = nullptr) { |
| 405 |
31 |
▶ | auto& zone = date ? date->timezone() : tzlocal(); |
Branch: 3 branches
| Branch | True | False | Total |
| auto& zone = date ? date->timezone() : tzlocal(); |
26 |
5 |
31 |
| auto& zone = date ? date->timezone() : tzlocal(); |
26 |
0 |
26 |
| auto& zone = date ? date->timezone() : tzlocal(); |
5 |
0 |
5 |
|
| 406 |
31 |
▶ | RETVAL = zone->name; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = zone->name; |
31 |
0 |
31 |
|
| 407 |
|
| } |
| 408 |
|
| |
| 409 |
|
| bool Date::tzlocal () { |
| 410 |
15 |
▶ | RETVAL = THIS->timezone()->is_local; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->timezone()->is_local; |
10 |
5 |
15 |
|
| 411 |
|
| } |
| 412 |
|
| |
| 413 |
|
| TimezoneSP Date::timezone (TimezoneSP newzone = {}) : ALIAS(tz=1, zone=2) { |
| 414 |
17 |
| if (newzone) { |
| 415 |
17 |
▶ | THIS->timezone(newzone); |
Branch: 1 branch
| Branch | True | False | Total |
| THIS->timezone(newzone); |
2 |
15 |
17 |
|
| 416 |
2 |
▶ | XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| XSRETURN_UNDEF; |
2 |
0 |
2 |
|
| 417 |
2 |
| } |
| 418 |
|
| RETVAL = THIS->timezone(); |
| 419 |
15 |
▶ | PERL_UNUSED_VAR(ix); |
Branch: 2 branches
| Branch | True | False | Total |
| PERL_UNUSED_VAR(ix); |
15 |
0 |
15 |
| PERL_UNUSED_VAR(ix); |
15 |
0 |
15 |
|
| 420 |
|
| } |
| 421 |
|
| |
| 422 |
|
| void Date::to_timezone (TimezoneSP newzone) : ALIAS(to_tz=1, to_zone=2) { |
| 423 |
3 |
▶ | THIS->to_timezone(newzone); |
Branch: 1 branch
| Branch | True | False | Total |
| THIS->to_timezone(newzone); |
3 |
0 |
3 |
|
| 424 |
|
| PERL_UNUSED_VAR(ix); |
| 425 |
|
| } |
| 426 |
|
| |
| 427 |
|
| void Date::array () { |
| 428 |
2 |
▶ | auto cnt = THIS->mksec() ? 7 : 6; |
Branch: 1 branch
| Branch | True | False | Total |
| auto cnt = THIS->mksec() ? 7 : 6; |
0 |
2 |
2 |
|
| 429 |
2 |
▶ | EXTEND(SP, cnt); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTEND(SP, cnt); |
2 |
0 |
2 |
| EXTEND(SP, cnt); |
0 |
2 |
2 |
| EXTEND(SP, cnt); |
0 |
2 |
2 |
|
| 430 |
2 |
| mPUSHi(THIS->year()); |
| 431 |
2 |
| mPUSHu(THIS->month()); |
| 432 |
2 |
| mPUSHu(THIS->day()); |
| 433 |
2 |
| mPUSHu(THIS->hour()); |
| 434 |
2 |
| mPUSHu(THIS->min()); |
| 435 |
2 |
| mPUSHu(THIS->sec()); |
| 436 |
2 |
▶ | if (THIS->mksec()) mPUSHu(THIS->mksec()); |
Branch: 1 branch
| Branch | True | False | Total |
| if (THIS->mksec()) mPUSHu(THIS->mksec()); |
0 |
2 |
2 |
|
| 437 |
2 |
| XSRETURN(cnt); |
| 438 |
|
| } |
| 439 |
|
| |
| 440 |
|
| void Date::struct () { |
| 441 |
1 |
▶ | EXTEND(SP, 9); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 9); |
0 |
1 |
1 |
|
| 442 |
1 |
| mPUSHu(THIS->sec()); |
| 443 |
1 |
| mPUSHu(THIS->min()); |
| 444 |
1 |
| mPUSHu(THIS->hour()); |
| 445 |
1 |
| mPUSHu(THIS->day()); |
| 446 |
1 |
| mPUSHu(THIS->c_month()); |
| 447 |
1 |
| mPUSHi(THIS->c_year()); |
| 448 |
1 |
| mPUSHu(THIS->c_wday()); |
| 449 |
1 |
| mPUSHu(THIS->c_yday()); |
| 450 |
1 |
▶ | mPUSHu(THIS->isdst() ? 1 : 0); |
Branch: 1 branch
| Branch | True | False | Total |
| mPUSHu(THIS->isdst() ? 1 : 0); |
0 |
1 |
1 |
|
| 451 |
1 |
| XSRETURN(9); |
| 452 |
|
| } |
| 453 |
|
| |
| 454 |
|
| Date* Date::clone (...) { |
| 455 |
18 |
| if (items > 1) { |
| 456 |
18 |
▶ | ptime_t vals[] = {-1, -1, -1, -1, -1, -1, -1, -1}; |
Branch: 1 branch
| Branch | True | False | Total |
| ptime_t vals[] = {-1, -1, -1, -1, -1, -1, -1, -1}; |
12 |
6 |
18 |
|
| 457 |
12 |
| auto tz = list2vals(&ST(1), items - 1, vals); |
| 458 |
12 |
▶ | RETVAL = new Date(THIS->clone(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], tz)); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = new Date(THIS->clone(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], tz)); |
12 |
0 |
12 |
|
| 459 |
12 |
▶ | } |
Branch: 3 branches
| Branch | True | False | Total |
| } |
12 |
0 |
12 |
| } |
12 |
0 |
12 |
| } |
0 |
0 |
0 |
|
| 460 |
12 |
| else RETVAL = new Date(*THIS); |
| 461 |
6 |
▶ | |
Branch: 3 branches
| Branch | True | False | Total |
| |
6 |
0 |
6 |
| |
6 |
0 |
6 |
| |
0 |
0 |
0 |
|
| 462 |
|
| if (RETVAL->error() && is_strict_mode()) { |
| 463 |
18 |
▶ | auto err = RETVAL->error(); |
Branch: 4 branches
| Branch | True | False | Total |
| auto err = RETVAL->error(); |
1 |
17 |
18 |
| auto err = RETVAL->error(); |
1 |
0 |
1 |
| auto err = RETVAL->error(); |
1 |
0 |
1 |
| auto err = RETVAL->error(); |
1 |
17 |
18 |
|
| 464 |
1 |
| delete RETVAL; |
| 465 |
1 |
▶ | throw xs::out(err); |
Branch: 1 branch
| Branch | True | False | Total |
| throw xs::out(err); |
1 |
0 |
1 |
|
| 466 |
1 |
▶ | } |
Branch: 1 branch
| Branch | True | False | Total |
| } |
1 |
0 |
1 |
|
| 467 |
|
| |
| 468 |
|
| PROTO = Object(ST(0)).stash(); |
| 469 |
17 |
▶ | } |
Branch: 3 branches
| Branch | True | False | Total |
| } |
17 |
0 |
17 |
| } |
17 |
0 |
17 |
| } |
17 |
0 |
17 |
|
| 470 |
|
| |
| 471 |
|
| SV* Date::month_begin () { |
| 472 |
1 |
| THIS->month_begin(); |
| 473 |
1 |
| XSRETURN(1); |
| 474 |
|
| } |
| 475 |
|
| |
| 476 |
|
| Date* Date::month_begin_new () { |
| 477 |
4 |
| RETVAL = new Date(THIS->month_begin_new()); |
| 478 |
4 |
▶ | PROTO = Object(ST(0)).stash(); |
Branch: 3 branches
| Branch | True | False | Total |
| PROTO = Object(ST(0)).stash(); |
4 |
0 |
4 |
| PROTO = Object(ST(0)).stash(); |
4 |
0 |
4 |
| PROTO = Object(ST(0)).stash(); |
0 |
0 |
0 |
|
| 479 |
4 |
▶ | } |
Branch: 3 branches
| Branch | True | False | Total |
| } |
4 |
0 |
4 |
| } |
4 |
0 |
4 |
| } |
4 |
0 |
4 |
|
| 480 |
|
| |
| 481 |
|
| SV* Date::month_end () { |
| 482 |
1 |
| THIS->month_end(); |
| 483 |
1 |
| XSRETURN(1); |
| 484 |
|
| } |
| 485 |
|
| |
| 486 |
|
| Date* Date::month_end_new () { |
| 487 |
4 |
| RETVAL = new Date(THIS->month_end_new()); |
| 488 |
4 |
▶ | PROTO = Object(ST(0)).stash(); |
Branch: 3 branches
| Branch | True | False | Total |
| PROTO = Object(ST(0)).stash(); |
4 |
0 |
4 |
| PROTO = Object(ST(0)).stash(); |
4 |
0 |
4 |
| PROTO = Object(ST(0)).stash(); |
0 |
0 |
0 |
|
| 489 |
4 |
▶ | } |
Branch: 3 branches
| Branch | True | False | Total |
| } |
4 |
0 |
4 |
| } |
4 |
0 |
4 |
| } |
4 |
0 |
4 |
|
| 490 |
|
| |
| 491 |
|
| int Date::days_in_month () { |
| 492 |
4 |
▶ | RETVAL = THIS->days_in_month(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = THIS->days_in_month(); |
0 |
4 |
4 |
|
| 493 |
|
| } |
| 494 |
|
| |
| 495 |
11 |
▶ | uint8_t Date::week_of_month () |
Branch: 1 branch
| Branch | True | False | Total |
| uint8_t Date::week_of_month () |
0 |
11 |
11 |
|
| 496 |
|
| |
| 497 |
8 |
▶ | uint8_t Date::weeks_in_year () |
Branch: 1 branch
| Branch | True | False | Total |
| uint8_t Date::weeks_in_year () |
0 |
8 |
8 |
|
| 498 |
|
| |
| 499 |
|
| void Date::week_of_year () { |
| 500 |
16 |
▶ | auto info = THIS->week_of_year(); |
Branch: 1 branch
| Branch | True | False | Total |
| auto info = THIS->week_of_year(); |
16 |
0 |
16 |
|
| 501 |
16 |
| int rcnt = 1; |
| 502 |
16 |
▶ | if (GIMME_V == G_ARRAY) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (GIMME_V == G_ARRAY) { |
8 |
8 |
16 |
|
| 503 |
8 |
▶ | mXPUSHi(info.year); |
Branch: 4 branches
| Branch | True | False | Total |
| mXPUSHi(info.year); |
0 |
8 |
8 |
| mXPUSHi(info.year); |
0 |
0 |
0 |
| mXPUSHi(info.year); |
8 |
0 |
8 |
| mXPUSHi(info.year); |
8 |
0 |
8 |
|
| 504 |
8 |
| rcnt = 2; |
| 505 |
|
| } |
| 506 |
16 |
▶ | mXPUSHu(info.week); |
Branch: 4 branches
| Branch | True | False | Total |
| mXPUSHu(info.week); |
0 |
16 |
16 |
| mXPUSHu(info.week); |
0 |
0 |
0 |
| mXPUSHu(info.week); |
16 |
0 |
16 |
| mXPUSHu(info.week); |
16 |
0 |
16 |
|
| 507 |
16 |
| XSRETURN(rcnt); |
| 508 |
|
| } |
| 509 |
|
| |
| 510 |
122 |
| std::error_code Date::error () |
| 511 |
122 |
| |
| 512 |
|
| SV* Date::truncate () { |
| 513 |
1 |
| THIS->truncate(); |
| 514 |
1 |
| XSRETURN(1); |
| 515 |
|
| } |
| 516 |
|
| |
| 517 |
|
| Date* Date::truncated () { |
| 518 |
1 |
| RETVAL = new Date(THIS->truncated()); |
| 519 |
1 |
▶ | PROTO = Object(ST(0)).stash(); |
Branch: 3 branches
| Branch | True | False | Total |
| PROTO = Object(ST(0)).stash(); |
1 |
0 |
1 |
| PROTO = Object(ST(0)).stash(); |
1 |
0 |
1 |
| PROTO = Object(ST(0)).stash(); |
0 |
0 |
0 |
|
| 520 |
1 |
▶ | } |
Branch: 3 branches
| Branch | True | False | Total |
| } |
1 |
0 |
1 |
| } |
1 |
0 |
1 |
| } |
1 |
0 |
1 |
|
| 521 |
|
| |
| 522 |
|
| int Date::compare (Sv arg, bool reverse = false) { |
| 523 |
144 |
▶ | if (arg.is_ref() && !arg.is_object_ref()) XSRETURN_IV(-1); // avoid exception in typemap for wrong types |
Branch: 5 branches
| Branch | True | False | Total |
| if (arg.is_ref() && !arg.is_object_ref()) XSRETURN_IV(-1); // avoid exception in typemap for wrong types |
33 |
111 |
144 |
| if (arg.is_ref() && !arg.is_object_ref()) XSRETURN_IV(-1); // avoid exception in typemap for wrong types |
2 |
31 |
33 |
| if (arg.is_ref() && !arg.is_object_ref()) XSRETURN_IV(-1); // avoid exception in typemap for wrong types |
2 |
142 |
144 |
| if (arg.is_ref() && !arg.is_object_ref()) XSRETURN_IV(-1); // avoid exception in typemap for wrong types |
2 |
0 |
2 |
| if (arg.is_ref() && !arg.is_object_ref()) XSRETURN_IV(-1); // avoid exception in typemap for wrong types |
2 |
0 |
2 |
|
| 524 |
142 |
▶ | RETVAL = THIS->compare(sv2date(arg, THIS->timezone())); |
Branch: 3 branches
| Branch | True | False | Total |
| RETVAL = THIS->compare(sv2date(arg, THIS->timezone())); |
142 |
0 |
142 |
| RETVAL = THIS->compare(sv2date(arg, THIS->timezone())); |
140 |
2 |
142 |
| RETVAL = THIS->compare(sv2date(arg, THIS->timezone())); |
140 |
0 |
140 |
|
| 525 |
140 |
▶ | if (reverse) RETVAL = -RETVAL; |
Branch: 1 branch
| Branch | True | False | Total |
| if (reverse) RETVAL = -RETVAL; |
14 |
126 |
140 |
|
| 526 |
140 |
▶ | if (RETVAL < 0) RETVAL = -1; |
Branch: 1 branch
| Branch | True | False | Total |
| if (RETVAL < 0) RETVAL = -1; |
20 |
120 |
140 |
|
| 527 |
120 |
▶ | else if (RETVAL > 0) RETVAL = 1; |
Branch: 1 branch
| Branch | True | False | Total |
| else if (RETVAL > 0) RETVAL = 1; |
22 |
98 |
120 |
|
| 528 |
|
| } |
| 529 |
|
| |
| 530 |
|
| Date* Date::sum (Sv arg, ...) { |
| 531 |
15 |
| RETVAL = new Date(*THIS + sv2daterel(arg)); |
| 532 |
15 |
▶ | PROTO = Object(ST(0)).stash(); |
Branch: 4 branches
| Branch | True | False | Total |
| PROTO = Object(ST(0)).stash(); |
15 |
0 |
15 |
| PROTO = Object(ST(0)).stash(); |
13 |
2 |
15 |
| PROTO = Object(ST(0)).stash(); |
13 |
0 |
13 |
| PROTO = Object(ST(0)).stash(); |
2 |
0 |
2 |
|
| 533 |
13 |
▶ | } |
Branch: 3 branches
| Branch | True | False | Total |
| } |
13 |
0 |
13 |
| } |
13 |
0 |
13 |
| } |
13 |
0 |
13 |
|
| 534 |
|
| |
| 535 |
|
| SV* Date::add (Sv arg, ...) { |
| 536 |
6 |
▶ | *THIS += sv2daterel(arg); |
Branch: 2 branches
| Branch | True | False | Total |
| *THIS += sv2daterel(arg); |
5 |
1 |
6 |
| *THIS += sv2daterel(arg); |
5 |
0 |
5 |
|
| 537 |
5 |
| XSRETURN(1); |
| 538 |
|
| } |
| 539 |
|
| |
| 540 |
|
| Sv Date::difference (Sv arg, bool reverse = false) { |
| 541 |
5 |
▶ | bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date"; |
Branch: 10 branches
| Branch | True | False | Total |
| bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date"; |
2 |
3 |
5 |
| bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date"; |
2 |
0 |
2 |
| bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date"; |
2 |
0 |
2 |
| bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date"; |
2 |
0 |
2 |
| bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date"; |
2 |
0 |
2 |
| bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date"; |
1 |
1 |
2 |
| bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date"; |
2 |
3 |
5 |
| bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date"; |
2 |
3 |
5 |
| bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date"; |
0 |
0 |
0 |
| bool is_date = arg.is_object_ref() && Object(arg).stash().name() == "Date"; |
0 |
0 |
0 |
|
| 542 |
5 |
▶ | if (is_date) RETVAL = xs::out(new DateRel(*xs::in<Date*>(arg), *THIS)); |
Branch: 6 branches
| Branch | True | False | Total |
| if (is_date) RETVAL = xs::out(new DateRel(*xs::in<Date*>(arg), *THIS)); |
1 |
4 |
5 |
| if (is_date) RETVAL = xs::out(new DateRel(*xs::in<Date*>(arg), *THIS)); |
1 |
0 |
1 |
| if (is_date) RETVAL = xs::out(new DateRel(*xs::in<Date*>(arg), *THIS)); |
1 |
0 |
1 |
| if (is_date) RETVAL = xs::out(new DateRel(*xs::in<Date*>(arg), *THIS)); |
1 |
0 |
1 |
| if (is_date) RETVAL = xs::out(new DateRel(*xs::in<Date*>(arg), *THIS)); |
1 |
0 |
1 |
| if (is_date) RETVAL = xs::out(new DateRel(*xs::in<Date*>(arg), *THIS)); |
0 |
0 |
0 |
|
| 543 |
4 |
▶ | else if (reverse) throw "wrong date operation"; |
Branch: 1 branch
| Branch | True | False | Total |
| else if (reverse) throw "wrong date operation"; |
0 |
4 |
4 |
|
| 544 |
7 |
▶ | else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash()); |
Branch: 7 branches
| Branch | True | False | Total |
| else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash()); |
4 |
0 |
4 |
| else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash()); |
4 |
0 |
4 |
| else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash()); |
4 |
0 |
4 |
| else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash()); |
3 |
1 |
4 |
| else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash()); |
3 |
0 |
3 |
| else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash()); |
3 |
0 |
3 |
| else RETVAL = xs::out(new Date(*THIS - sv2daterel(arg)), Object(ST(0)).stash()); |
1 |
0 |
1 |
|
| 545 |
|
| } |
| 546 |
|
| |
| 547 |
|
| SV* Date::subtract (Sv arg, ...) { |
| 548 |
3 |
▶ | *THIS -= sv2daterel(arg); |
Branch: 2 branches
| Branch | True | False | Total |
| *THIS -= sv2daterel(arg); |
2 |
1 |
3 |
| *THIS -= sv2daterel(arg); |
2 |
0 |
2 |
|
| 549 |
2 |
| XSRETURN(1); |
| 550 |
|
| } |
| 551 |
|
| |
| 552 |
|
| void __assign_stub (...) { |
| 553 |
8 |
▶ | if (!items) throw "should not happen"; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!items) throw "should not happen"; |
0 |
8 |
8 |
|
| 554 |
8 |
| XSRETURN(1); |
| 555 |
|
| } |