| 1 |
|
| #include "date.h" |
| 2 |
|
| |
| 3 |
|
| namespace xs { namespace date { |
| 4 |
|
| |
| 5 |
|
| using panda::string; |
| 6 |
|
| using panda::string_view; |
| 7 |
|
| |
| 8 |
|
| panda::string_view strict_hint_name = "Date::strict"; |
| 9 |
|
| |
| 10 |
513 |
| static inline Date _sv2date (const Sv& arg, const TimezoneSP& zone, int fmt) { |
| 11 |
513 |
▶ | if (!arg) return Date(0, zone); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!arg) return Date(0, zone); |
2 |
511 |
513 |
|
| 12 |
511 |
| SvGETMAGIC(arg); |
| 13 |
511 |
▶ | if (!arg.defined()) return Date("!"); // date with parsing error |
Branch: 2 branches
| Branch | True | False | Total |
| if (!arg.defined()) return Date("!"); // date with parsing error |
0 |
511 |
511 |
| if (!arg.defined()) return Date("!"); // date with parsing error |
0 |
0 |
0 |
|
| 14 |
|
| |
| 15 |
511 |
▶ | if (SvROK(arg)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvROK(arg)) { |
43 |
468 |
511 |
|
| 16 |
43 |
| SV* v = SvRV(arg); |
| 17 |
43 |
▶ | if (SvOBJECT(v)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOBJECT(v)) { |
40 |
3 |
43 |
|
| 18 |
40 |
▶ | Object o = v; |
Branch: 1 branch
| Branch | True | False | Total |
| Object o = v; |
40 |
0 |
40 |
|
| 19 |
40 |
▶ | if (o.stash().name() == "Date") return *xs::in<Date*>(arg); |
Branch: 6 branches
| Branch | True | False | Total |
| if (o.stash().name() == "Date") return *xs::in<Date*>(arg); |
40 |
0 |
40 |
| if (o.stash().name() == "Date") return *xs::in<Date*>(arg); |
40 |
0 |
40 |
| if (o.stash().name() == "Date") return *xs::in<Date*>(arg); |
40 |
0 |
40 |
| if (o.stash().name() == "Date") return *xs::in<Date*>(arg); |
39 |
1 |
40 |
| if (o.stash().name() == "Date") return *xs::in<Date*>(arg); |
39 |
0 |
39 |
| if (o.stash().name() == "Date") return *xs::in<Date*>(arg); |
39 |
0 |
39 |
|
| 20 |
1 |
▶ | return Date(xs::in<string_view>(arg), zone, fmt); |
Branch: 2 branches
| Branch | True | False | Total |
| return Date(xs::in<string_view>(arg), zone, fmt); |
1 |
0 |
1 |
| return Date(xs::in<string_view>(arg), zone, fmt); |
1 |
0 |
1 |
|
| 21 |
40 |
| } |
| 22 |
3 |
| else throw "invalid date argument"; |
| 23 |
|
| } |
| 24 |
|
| |
| 25 |
468 |
▶ | if (SvNIOK(arg) || arg.is_like_number()) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (SvNIOK(arg) || arg.is_like_number()) { |
412 |
56 |
468 |
| if (SvNIOK(arg) || arg.is_like_number()) { |
0 |
412 |
412 |
| if (SvNIOK(arg) || arg.is_like_number()) { |
56 |
412 |
468 |
|
| 26 |
56 |
▶ | if (SvNOK(arg)) return Date((double)SvNV(arg), zone); |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvNOK(arg)) return Date((double)SvNV(arg), zone); |
2 |
54 |
56 |
|
| 27 |
54 |
| return Date(xs::in<ptime_t>(arg), zone); |
| 28 |
|
| } |
| 29 |
|
| |
| 30 |
412 |
| return Date(xs::in<string_view>(arg), zone, fmt); |
| 31 |
|
| } |
| 32 |
|
| |
| 33 |
513 |
| Date sv2date (const Sv& arg, const TimezoneSP& zone, int fmt) { |
| 34 |
513 |
| auto ret = _sv2date(arg, zone, fmt); |
| 35 |
510 |
▶ | 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()); |
47 |
463 |
510 |
| if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
47 |
0 |
47 |
| if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
10 |
37 |
47 |
| if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
10 |
500 |
510 |
| if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
10 |
0 |
10 |
|
| 36 |
500 |
| return ret; |
| 37 |
10 |
| } |
| 38 |
|
| |
| 39 |
572 |
| DateRel sv2daterel (const Sv& arg) { |
| 40 |
572 |
▶ | if (arg) SvGETMAGIC(arg); |
Branch: 2 branches
| Branch | True | False | Total |
| if (arg) SvGETMAGIC(arg); |
566 |
6 |
572 |
| if (arg) SvGETMAGIC(arg); |
566 |
0 |
566 |
|
| 41 |
572 |
▶ | if (!arg.defined()) return DateRel(); |
Branch: 3 branches
| Branch | True | False | Total |
| if (!arg.defined()) return DateRel(); |
572 |
0 |
572 |
| if (!arg.defined()) return DateRel(); |
6 |
566 |
572 |
| if (!arg.defined()) return DateRel(); |
6 |
0 |
6 |
|
| 42 |
|
| |
| 43 |
566 |
▶ | if (arg.is_ref()) return *xs::in<const DateRel*>(arg); |
Branch: 3 branches
| Branch | True | False | Total |
| if (arg.is_ref()) return *xs::in<const DateRel*>(arg); |
44 |
522 |
566 |
| if (arg.is_ref()) return *xs::in<const DateRel*>(arg); |
34 |
10 |
44 |
| if (arg.is_ref()) return *xs::in<const DateRel*>(arg); |
34 |
0 |
34 |
|
| 44 |
|
| |
| 45 |
522 |
▶ | if (SvNIOK(arg) || arg.is_like_number()) return DateRel(0, 0, 0, 0, 0, xs::in<ptime_t>(arg)); |
Branch: 6 branches
| Branch | True | False | Total |
| if (SvNIOK(arg) || arg.is_like_number()) return DateRel(0, 0, 0, 0, 0, xs::in<ptime_t>(arg)); |
510 |
12 |
522 |
| if (SvNIOK(arg) || arg.is_like_number()) return DateRel(0, 0, 0, 0, 0, xs::in<ptime_t>(arg)); |
510 |
0 |
510 |
| if (SvNIOK(arg) || arg.is_like_number()) return DateRel(0, 0, 0, 0, 0, xs::in<ptime_t>(arg)); |
2 |
508 |
510 |
| if (SvNIOK(arg) || arg.is_like_number()) return DateRel(0, 0, 0, 0, 0, xs::in<ptime_t>(arg)); |
14 |
508 |
522 |
| if (SvNIOK(arg) || arg.is_like_number()) return DateRel(0, 0, 0, 0, 0, xs::in<ptime_t>(arg)); |
14 |
0 |
14 |
| if (SvNIOK(arg) || arg.is_like_number()) return DateRel(0, 0, 0, 0, 0, xs::in<ptime_t>(arg)); |
14 |
0 |
14 |
|
| 46 |
|
| |
| 47 |
508 |
▶ | auto ret = DateRel(xs::in<string_view>(arg)); |
Branch: 2 branches
| Branch | True | False | Total |
| auto ret = DateRel(xs::in<string_view>(arg)); |
508 |
0 |
508 |
| auto ret = DateRel(xs::in<string_view>(arg)); |
508 |
0 |
508 |
|
| 48 |
508 |
▶ | 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()); |
11 |
497 |
508 |
| if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
11 |
0 |
11 |
| if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
5 |
6 |
11 |
| if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
5 |
503 |
508 |
| if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
5 |
0 |
5 |
|
| 49 |
503 |
▶ | return ret; |
Branch: 1 branch
| Branch | True | False | Total |
| return ret; |
503 |
0 |
503 |
|
| 50 |
508 |
| } |
| 51 |
|
| |
| 52 |
|
| }} |