line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODE: INLINE |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#include "private.h" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
static inline DateRel xs_daterel_ctor (SV* arg, SV* till) { |
6
|
|
|
|
|
|
|
return till ? DateRel(sv2date(arg), sv2date(till)) : sv2daterel(arg); |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
static inline DateRel xs_daterel_ymd (SV** args, I32 items) { |
10
|
|
|
|
|
|
|
ptime_t vals[8] = {0, 0, 0, 0, 0, 0, 0, 0}; |
11
|
|
|
|
|
|
|
list2vals(args, items, vals); |
12
|
|
|
|
|
|
|
return DateRel(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5]); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
MODULE = Date PACKAGE = Date |
16
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
BOOT { |
19
|
94
|
50
|
|
|
|
|
Stash stash("Date::Rel", GV_ADD); |
20
|
|
|
|
|
|
|
|
21
|
470
|
50
|
|
|
|
|
xs::exp::create_constants(stash, { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
22
|
|
|
|
|
|
|
{"FORMAT_SIMPLE", (int)DateRel::Format::simple}, |
23
|
|
|
|
|
|
|
{"FORMAT_ISO8601D", (int)DateRel::Format::iso8601d}, |
24
|
|
|
|
|
|
|
{"FORMAT_ISO8601I", (int)DateRel::Format::iso8601i}, |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
{"INPUT_FORMAT_ALL", DateRel::InputFormat::all}, |
27
|
|
|
|
|
|
|
{"INPUT_FORMAT_SIMPLE", DateRel::InputFormat::simple}, |
28
|
|
|
|
|
|
|
{"INPUT_FORMAT_ISO8601", DateRel::InputFormat::iso8601}, |
29
|
|
|
|
|
|
|
{"INPUT_FORMAT_ISO8601D", DateRel::InputFormat::iso8601d}, |
30
|
|
|
|
|
|
|
{"INPUT_FORMAT_ISO8601I", DateRel::InputFormat::iso8601i}, |
31
|
423
|
50
|
|
|
|
|
}); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#///////////////////////////// STATIC FUNCTIONS /////////////////////////////////// |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
DateRel* rdate (SV* from = {}, SV* till = {}) { |
37
|
72
|
|
|
|
|
|
RETVAL = new DateRel(xs_daterel_ctor(from, till)); |
38
|
36
|
100
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
DateRel* rdate_ymd (...) { |
41
|
8
|
|
|
|
|
|
RETVAL = new DateRel(xs_daterel_ymd(&ST(0), items)); |
42
|
4
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
const DateRel* rdate_const (SV* from = {}, SV* till = {}) { |
45
|
660
|
|
|
|
|
|
RETVAL = new DateRel(xs_daterel_ctor(from, till)); |
46
|
330
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
const DateRel* rdate_ymd_const (...) { |
49
|
0
|
|
|
|
|
|
RETVAL = new DateRel(xs_daterel_ymd(&ST(0), items)); |
50
|
0
|
0
|
|
|
|
|
} |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
#///////////////////////////// OBJECT METHODS /////////////////////////////////// |
53
|
|
|
|
|
|
|
MODULE = Date PACKAGE = Date::Rel |
54
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
DateRel* new (SV*, SV* from = {}, SV* till = {}) { |
57
|
50
|
|
|
|
|
|
RETVAL = new DateRel(xs_daterel_ctor(from, till)); |
58
|
25
|
100
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
DateRel* new_ymd (...) { |
61
|
8
|
|
|
|
|
|
RETVAL = new DateRel(xs_daterel_ymd(&ST(1), items - 1)); |
62
|
4
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
void DateRel::set (SV* from, SV* till = {}) { |
65
|
4
|
50
|
|
|
|
|
*THIS = xs_daterel_ctor(from, till); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
void DateRel::set_ymd (...) { |
69
|
2
|
50
|
|
|
|
|
*THIS = xs_daterel_ymd(&ST(1), items - 1); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
2
|
|
|
|
|
|
std::error_code DateRel::error () |
73
|
1
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
ptime_t DateRel::sec (SV* newval = NULL) { |
75
|
26
|
|
|
|
|
|
if (newval) { |
76
|
13
|
50
|
|
|
|
|
THIS->sec(xs::in(newval)); |
77
|
0
|
0
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
RETVAL = THIS->sec(); |
79
|
13
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
ptime_t DateRel::min (SV* newval = NULL) { |
82
|
26
|
|
|
|
|
|
if (newval) THIS->min(xs::in(newval)); |
83
|
13
|
50
|
|
|
|
|
RETVAL = THIS->min(); |
|
|
0
|
|
|
|
|
|
84
|
13
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
ptime_t DateRel::hour (SV* newval = NULL) { |
87
|
26
|
|
|
|
|
|
if (newval) { |
88
|
13
|
50
|
|
|
|
|
THIS->hour(xs::in(newval)); |
89
|
0
|
0
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
RETVAL = THIS->hour(); |
91
|
13
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
ptime_t DateRel::day (SV* newval = NULL) { |
94
|
20
|
|
|
|
|
|
if (newval) { |
95
|
10
|
50
|
|
|
|
|
THIS->day(xs::in(newval)); |
96
|
0
|
0
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
RETVAL = THIS->day(); |
98
|
10
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
ptime_t DateRel::month (SV* newval = NULL) { |
101
|
22
|
|
|
|
|
|
if (newval) { |
102
|
11
|
50
|
|
|
|
|
THIS->month(xs::in(newval)); |
103
|
0
|
0
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
RETVAL = THIS->month(); |
105
|
11
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
ptime_t DateRel::year (SV* newval = NULL) { |
108
|
24
|
|
|
|
|
|
if (newval) { |
109
|
12
|
100
|
|
|
|
|
THIS->year(xs::in(newval)); |
110
|
1
|
50
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
RETVAL = THIS->year(); |
112
|
12
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Date* DateRel::from (SV* fromSV = NULL) { |
115
|
10
|
|
|
|
|
|
if (fromSV) { |
116
|
6
|
100
|
|
|
|
|
THIS->from(sv2date(fromSV)); |
117
|
2
|
50
|
|
|
|
|
XSRETURN_UNDEF; |
|
|
50
|
|
|
|
|
|
118
|
2
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
if (!THIS->from()) XSRETURN_UNDEF; |
120
|
4
|
50
|
|
|
|
|
RETVAL = new Date(*(THIS->from())); |
121
|
4
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Date* DateRel::till () : const { |
124
|
4
|
|
|
|
|
|
auto till = THIS->till(); |
125
|
4
|
50
|
|
|
|
|
if (!till) XSRETURN_UNDEF; |
|
|
50
|
|
|
|
|
|
126
|
2
|
50
|
|
|
|
|
RETVAL = new Date(*till); |
127
|
2
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
ptime_t DateRel::to_secs () : ALIAS(duration=1) const { |
130
|
42
|
|
|
|
|
|
PERL_UNUSED_VAR(ix); |
131
|
|
|
|
|
|
|
RETVAL = THIS->to_secs(); |
132
|
21
|
50
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
4
|
50
|
|
|
|
|
double DateRel::to_mins () : const |
135
|
|
|
|
|
|
|
|
136
|
2
|
50
|
|
|
|
|
double DateRel::to_hours () : const |
137
|
|
|
|
|
|
|
|
138
|
2
|
50
|
|
|
|
|
double DateRel::to_days () : const |
139
|
|
|
|
|
|
|
|
140
|
2
|
50
|
|
|
|
|
double DateRel::to_months () : const |
141
|
|
|
|
|
|
|
|
142
|
2
|
50
|
|
|
|
|
double DateRel::to_years () : const |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
string DateRel::to_string (int format = (int)DateRel::Format::simple) : const { |
145
|
53
|
50
|
|
|
|
|
RETVAL = THIS->to_string((DateRel::Format)format); |
|
|
50
|
|
|
|
|
|
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
string DateRel::_op_str (...) : const { |
149
|
5
|
50
|
|
|
|
|
RETVAL = THIS->to_string(); |
|
|
50
|
|
|
|
|
|
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
bool DateRel::to_bool (...) : const { |
153
|
0
|
0
|
|
|
|
|
RETVAL = THIS->duration(); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
ptime_t DateRel::to_number (...) : const { |
157
|
6
|
|
|
|
|
|
RETVAL = THIS->duration(); |
158
|
3
|
50
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Sv DateRel::sum (Sv arg, ...) : const { |
161
|
20
|
100
|
|
|
|
|
if (arg.is_object_ref()) { |
162
|
28
|
50
|
|
|
|
|
Stash s = Object(arg).stash(); |
|
|
50
|
|
|
|
|
|
163
|
14
|
50
|
|
|
|
|
if (s.name() == "Date") RETVAL = xs::out(new Date(*xs::in(arg) + *THIS)); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
164
|
13
|
50
|
|
|
|
|
else RETVAL = xs::out(new DateRel(*THIS + *xs::in(arg)), Object(ST(0)).stash()); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
165
|
|
|
|
|
|
|
} |
166
|
6
|
50
|
|
|
|
|
else RETVAL = xs::out(new DateRel(*THIS + sv2daterel(arg)), Object(ST(0)).stash()); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
SV* DateRel::add (Sv arg, ...) { |
170
|
5
|
100
|
|
|
|
|
*THIS += sv2daterel(arg); |
|
|
50
|
|
|
|
|
|
171
|
4
|
50
|
|
|
|
|
XSRETURN(1); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
DateRel* DateRel::difference (Sv arg, bool reverse = false) : const { |
175
|
24
|
|
|
|
|
|
auto op = sv2daterel(arg); |
176
|
22
|
100
|
|
|
|
|
RETVAL = new DateRel(reverse ? (op - *THIS) : (*THIS - op)); |
177
|
10
|
50
|
|
|
|
|
PROTO = Object(ST(0)).stash(); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
178
|
10
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
SV* DateRel::subtract (Sv arg, ...) { |
181
|
8
|
100
|
|
|
|
|
*THIS -= sv2daterel(arg); |
|
|
50
|
|
|
|
|
|
182
|
6
|
50
|
|
|
|
|
XSRETURN(1); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
DateRel* DateRel::product (SV* arg, ...) : const { |
186
|
46
|
|
|
|
|
|
RETVAL = new DateRel(*THIS * SvNV(arg)); |
187
|
23
|
100
|
|
|
|
|
PROTO = Object(ST(0)).stash(); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
188
|
23
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
SV* DateRel::multiply (SV* arg, ...) { |
191
|
2
|
100
|
|
|
|
|
*THIS *= SvNV(arg); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
192
|
2
|
|
|
|
|
|
XSRETURN(1); |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
DateRel* DateRel::quotient (SV* arg, bool reverse = false) : const { |
196
|
30
|
|
|
|
|
|
if (reverse) throw "Date: illegal divison $num/$reldate"; |
197
|
15
|
100
|
|
|
|
|
RETVAL = new DateRel(*THIS / SvNV(arg)); |
198
|
9
|
50
|
|
|
|
|
PROTO = Object(ST(0)).stash(); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
199
|
9
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
SV* DateRel::divide (SV* arg, bool reverse = false) { |
202
|
2
|
50
|
|
|
|
|
if (reverse) throw "Date: illegal divison $num/$reldate"; |
203
|
2
|
100
|
|
|
|
|
*THIS /= SvNV(arg); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
204
|
2
|
|
|
|
|
|
XSRETURN(1); |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
DateRel* DateRel::negated (...) : const { |
208
|
4
|
|
|
|
|
|
RETVAL = new DateRel(THIS->negated()); |
209
|
2
|
50
|
|
|
|
|
PROTO = Object(ST(0)).stash(); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
210
|
2
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
SV* DateRel::negate () { |
213
|
0
|
|
|
|
|
|
THIS->negate(); |
214
|
0
|
|
|
|
|
|
XSRETURN(1); |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
int DateRel::compare (Sv arg, bool reverse) : const { |
218
|
26
|
100
|
|
|
|
|
RETVAL = THIS->compare(sv2daterel(arg)); |
|
|
50
|
|
|
|
|
|
219
|
25
|
100
|
|
|
|
|
if (reverse) RETVAL = -RETVAL; |
220
|
25
|
100
|
|
|
|
|
if (RETVAL < 0) RETVAL = -1; |
221
|
20
|
100
|
|
|
|
|
else if (RETVAL > 0) RETVAL = 1; |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
bool DateRel::is_same (Sv arg, ...) : const { |
225
|
92
|
100
|
|
|
|
|
RETVAL = THIS->is_same(sv2daterel(arg)); |
|
|
50
|
|
|
|
|
|
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
int DateRel::includes (Sv arg) : const { |
229
|
6
|
50
|
|
|
|
|
RETVAL = THIS->includes(sv2date(arg)); |
|
|
50
|
|
|
|
|
|
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
DateRel* DateRel::clone () { |
233
|
4
|
|
|
|
|
|
RETVAL = new DateRel(*THIS); |
234
|
2
|
50
|
|
|
|
|
PROTO = Object(ST(0)).stash(); |
|
|
50
|
|
|
|
|
|
235
|
2
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|