line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
512
|
|
|
|
|
|
static inline Date _sv2date (const Sv& arg, const TimezoneSP& zone, int fmt) { |
11
|
512
|
100
|
|
|
|
|
if (!arg) return Date(0, zone); |
12
|
510
|
50
|
|
|
|
|
if (!arg.defined()) return Date("!"); // date with parsing error |
|
|
0
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
510
|
100
|
|
|
|
|
if (SvROK(arg)) { |
15
|
43
|
|
|
|
|
|
SV* v = SvRV(arg); |
16
|
43
|
100
|
|
|
|
|
if (SvOBJECT(v)) { |
17
|
80
|
50
|
|
|
|
|
Object o = v; |
18
|
40
|
50
|
|
|
|
|
if (o.stash().name() == "Date") return *xs::in(arg); |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
19
|
1
|
50
|
|
|
|
|
return Date(xs::in(arg), zone, fmt); |
|
|
50
|
|
|
|
|
|
20
|
|
|
|
|
|
|
} |
21
|
3
|
|
|
|
|
|
else throw "invalid date argument"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
467
|
100
|
|
|
|
|
SvGETMAGIC(arg); |
|
|
50
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
467
|
100
|
|
|
|
|
if (SvNIOK(arg) || arg.is_like_number()) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
27
|
56
|
100
|
|
|
|
|
if (SvNOK(arg)) return Date((double)SvNV(arg), zone); |
|
|
50
|
|
|
|
|
|
28
|
54
|
|
|
|
|
|
return Date(xs::in(arg), zone); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
509
|
|
|
|
|
|
return Date(xs::in(arg), zone, fmt); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
512
|
|
|
|
|
|
Date sv2date (const Sv& arg, const TimezoneSP& zone, int fmt) { |
35
|
512
|
|
|
|
|
|
auto ret = _sv2date(arg, zone, fmt); |
36
|
509
|
100
|
|
|
|
|
if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
37
|
499
|
|
|
|
|
|
return ret; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
565
|
|
|
|
|
|
DateRel sv2daterel (const Sv& arg) { |
41
|
565
|
100
|
|
|
|
|
if (!arg.defined()) return DateRel(); |
|
|
50
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
559
|
100
|
|
|
|
|
if (arg.is_ref()) return *xs::in(arg); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
515
|
50
|
|
|
|
|
SvGETMAGIC(arg); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
515
|
100
|
|
|
|
|
if (SvNIOK(arg) || arg.is_like_number()) return DateRel(0, 0, 0, 0, 0, xs::in(arg)); |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
1056
|
50
|
|
|
|
|
auto ret = DateRel(xs::in(arg)); |
|
|
50
|
|
|
|
|
|
50
|
501
|
100
|
|
|
|
|
if (ret.error() && is_strict_mode()) throw xs::out(ret.error()); |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
51
|
496
|
50
|
|
|
|
|
return ret; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
}} |