line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Date; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
63
|
use 5.018; |
|
2
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
42
|
|
6
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
74
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use Venus::Class 'attr', 'base', 'with'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
14
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
base 'Venus::Kind::Utility'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Venus::Role::Buildable'; |
13
|
|
|
|
|
|
|
with 'Venus::Role::Explainable'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use overload ( |
16
|
|
|
|
|
|
|
'""' => 'explain', |
17
|
1
|
|
|
1
|
|
6
|
'!=' => sub{("$_[0]" + 0) != ($_[1] + 0)}, |
18
|
2
|
|
|
2
|
|
12
|
'+' => sub{("$_[0]" + 0) + ($_[1] + 0)}, |
19
|
1
|
|
|
1
|
|
7
|
'-' => sub{("$_[0]" + 0) - ($_[1] + 0)}, |
20
|
134
|
|
|
134
|
|
11423
|
'0+' => sub{($_[0]->epoch + 0)}, |
21
|
1
|
|
|
1
|
|
6
|
'<' => sub{("$_[0]" + 0) < ($_[1] + 0)}, |
22
|
1
|
|
|
1
|
|
4
|
'<=' => sub{("$_[0]" + 0) <= ($_[1] + 0)}, |
23
|
1
|
|
|
1
|
|
5
|
'==' => sub{("$_[0]" + 0) == ($_[1] + 0)}, |
24
|
1
|
|
|
1
|
|
6
|
'>' => sub{("$_[0]" + 0) > ($_[1] + 0)}, |
25
|
1
|
|
|
1
|
|
6
|
'>=' => sub{("$_[0]" + 0) >= ($_[1] + 0)}, |
26
|
1
|
|
|
1
|
|
4
|
'eq' => sub{"$_[0]" eq "$_[1]"}, |
27
|
1
|
|
|
1
|
|
10
|
'ne' => sub{"$_[0]" ne "$_[1]"}, |
28
|
2
|
|
|
|
|
54
|
'~~' => 'explain', |
29
|
|
|
|
|
|
|
fallback => 1, |
30
|
2
|
|
|
2
|
|
13
|
); |
|
2
|
|
|
|
|
4
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# ATTRIBUTES |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
attr 'day'; |
35
|
|
|
|
|
|
|
attr 'month'; |
36
|
|
|
|
|
|
|
attr 'year'; |
37
|
|
|
|
|
|
|
attr 'hour'; |
38
|
|
|
|
|
|
|
attr 'minute'; |
39
|
|
|
|
|
|
|
attr 'second'; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# BUILDERS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub build_arg { |
44
|
93
|
|
|
93
|
0
|
307
|
my ($self, $time) = @_; |
45
|
|
|
|
|
|
|
|
46
|
93
|
|
|
|
|
245
|
my $data = {}; |
47
|
93
|
|
|
|
|
801
|
my @time = gmtime $time; |
48
|
|
|
|
|
|
|
|
49
|
93
|
|
33
|
|
|
700
|
$data->{day} //= $time[3]; |
50
|
93
|
|
66
|
|
|
535
|
$data->{hour} //= $time[2]; |
51
|
93
|
|
66
|
|
|
481
|
$data->{minute} //= $time[1]; |
52
|
93
|
|
33
|
|
|
483
|
$data->{month} //= $time[4] + 1; |
53
|
93
|
|
66
|
|
|
465
|
$data->{second} //= $time[0]; |
54
|
93
|
|
33
|
|
|
492
|
$data->{year} //= $time[5] + 1900; |
55
|
|
|
|
|
|
|
|
56
|
93
|
|
|
|
|
317
|
return $data; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub build_args { |
60
|
96
|
|
|
96
|
0
|
302
|
my ($self, $data) = @_; |
61
|
|
|
|
|
|
|
|
62
|
96
|
|
|
|
|
394
|
my @time = gmtime time; |
63
|
|
|
|
|
|
|
|
64
|
96
|
|
33
|
|
|
354
|
$data->{day} //= $time[3]; |
65
|
96
|
|
66
|
|
|
310
|
$data->{hour} //= $time[2]; |
66
|
96
|
|
66
|
|
|
306
|
$data->{minute} //= $time[1]; |
67
|
96
|
|
33
|
|
|
267
|
$data->{month} //= $time[4] + 1; |
68
|
96
|
|
66
|
|
|
324
|
$data->{second} //= $time[0]; |
69
|
96
|
|
33
|
|
|
271
|
$data->{year} //= $time[5] + 1900; |
70
|
|
|
|
|
|
|
|
71
|
96
|
|
|
|
|
326
|
return $data; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# METHODS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub add { |
77
|
8
|
|
|
8
|
1
|
23
|
my ($self, $data) = @_; |
78
|
|
|
|
|
|
|
|
79
|
8
|
|
|
|
|
20
|
for my $name (qw(days hours minutes months seconds years)) { |
80
|
48
|
50
|
|
|
|
252
|
if (my $code = $self->can("add_$name")) { |
81
|
48
|
|
|
|
|
210
|
$self->$code($data->{$name}); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
8
|
|
|
|
|
105
|
return $self; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub add_days { |
89
|
11
|
|
|
11
|
1
|
32
|
my ($self, $size) = @_; |
90
|
|
|
|
|
|
|
|
91
|
11
|
|
100
|
|
|
40
|
$size //= 0; |
92
|
|
|
|
|
|
|
|
93
|
11
|
100
|
|
|
|
47
|
$size = ($self->timeseconds->ONE_DAY * $size) if $size; |
94
|
|
|
|
|
|
|
|
95
|
11
|
|
|
|
|
153
|
return $self->reset($self->epoch + $size); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub add_hours { |
99
|
11
|
|
|
11
|
1
|
37
|
my ($self, $size) = @_; |
100
|
|
|
|
|
|
|
|
101
|
11
|
|
100
|
|
|
39
|
$size //= 0; |
102
|
|
|
|
|
|
|
|
103
|
11
|
100
|
|
|
|
44
|
$size = ($self->timeseconds->ONE_HOUR * $size) if $size; |
104
|
|
|
|
|
|
|
|
105
|
11
|
|
|
|
|
117
|
return $self->reset($self->epoch + $size); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub add_hms { |
109
|
3
|
|
|
3
|
1
|
9
|
my ($self, $h, $m, $s) = @_; |
110
|
|
|
|
|
|
|
|
111
|
3
|
|
|
|
|
8
|
my $data = {}; |
112
|
|
|
|
|
|
|
|
113
|
3
|
100
|
|
|
|
13
|
$data->{hours} = $h if defined $h; |
114
|
3
|
50
|
|
|
|
17
|
$data->{minutes} = $m if defined $m; |
115
|
3
|
100
|
|
|
|
41
|
$data->{seconds} = $s if defined $s; |
116
|
|
|
|
|
|
|
|
117
|
3
|
|
|
|
|
34
|
return $self->add($data); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub add_mdy { |
121
|
3
|
|
|
3
|
1
|
17
|
my ($self, $m, $d, $y) = @_; |
122
|
|
|
|
|
|
|
|
123
|
3
|
|
|
|
|
10
|
my $data = {}; |
124
|
|
|
|
|
|
|
|
125
|
3
|
50
|
|
|
|
12
|
$data->{days} = $d if defined $d; |
126
|
3
|
100
|
|
|
|
11
|
$data->{months} = $m if defined $m; |
127
|
3
|
100
|
|
|
|
9
|
$data->{years} = $y if defined $y; |
128
|
|
|
|
|
|
|
|
129
|
3
|
|
|
|
|
11
|
return $self->add($data); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub add_minutes { |
133
|
11
|
|
|
11
|
1
|
33
|
my ($self, $size) = @_; |
134
|
|
|
|
|
|
|
|
135
|
11
|
|
100
|
|
|
51
|
$size //= 0; |
136
|
|
|
|
|
|
|
|
137
|
11
|
100
|
|
|
|
44
|
$size = ($self->timeseconds->ONE_MINUTE * $size) if $size; |
138
|
|
|
|
|
|
|
|
139
|
11
|
|
|
|
|
102
|
return $self->reset($self->epoch + $size); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub add_months { |
143
|
11
|
|
|
11
|
1
|
39
|
my ($self, $size) = @_; |
144
|
|
|
|
|
|
|
|
145
|
11
|
|
100
|
|
|
46
|
$size //= 0; |
146
|
|
|
|
|
|
|
|
147
|
11
|
100
|
|
|
|
54
|
$size = ($self->timeseconds->ONE_MONTH * $size) if $size; |
148
|
|
|
|
|
|
|
|
149
|
11
|
|
|
|
|
105
|
return $self->reset($self->epoch + $size); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub add_seconds { |
153
|
11
|
|
|
11
|
1
|
47
|
my ($self, $size) = @_; |
154
|
|
|
|
|
|
|
|
155
|
11
|
|
100
|
|
|
40
|
$size //= 0; |
156
|
|
|
|
|
|
|
|
157
|
11
|
|
|
|
|
35
|
return $self->reset($self->epoch + $size); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub add_years { |
161
|
11
|
|
|
11
|
1
|
49
|
my ($self, $size) = @_; |
162
|
|
|
|
|
|
|
|
163
|
11
|
|
100
|
|
|
42
|
$size //= 0; |
164
|
|
|
|
|
|
|
|
165
|
11
|
100
|
|
|
|
48
|
$size = ($self->timeseconds->ONE_YEAR * $size) if $size; |
166
|
|
|
|
|
|
|
|
167
|
11
|
|
|
|
|
94
|
return $self->reset($self->epoch + $size); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub assertion { |
171
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
0
|
my $assert = $self->SUPER::assertion; |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
0
|
$assert->clear->expression('number'); |
176
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
0
|
return $assert; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub epoch { |
181
|
343
|
|
|
343
|
1
|
631
|
my ($self) = @_; |
182
|
|
|
|
|
|
|
|
183
|
343
|
|
|
|
|
767
|
return $self->timepiece->epoch; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub explain { |
187
|
13
|
|
|
13
|
1
|
41
|
my ($self) = @_; |
188
|
|
|
|
|
|
|
|
189
|
13
|
|
|
|
|
88
|
return $self->epoch; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub format { |
193
|
4
|
|
|
4
|
1
|
12
|
my ($self, @args) = @_; |
194
|
|
|
|
|
|
|
|
195
|
4
|
|
|
|
|
19
|
return $self->timepiece->strftime(@args); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub hms { |
199
|
1
|
|
|
1
|
1
|
4
|
my ($self) = @_; |
200
|
|
|
|
|
|
|
|
201
|
1
|
|
|
|
|
6
|
return $self->timepiece->hms; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub iso8601 { |
205
|
7
|
|
|
7
|
1
|
18
|
my ($self) = @_; |
206
|
|
|
|
|
|
|
|
207
|
7
|
|
|
|
|
25
|
return $self->timepiece->datetime; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub mdy { |
211
|
1
|
|
|
1
|
1
|
4
|
my ($self) = @_; |
212
|
|
|
|
|
|
|
|
213
|
1
|
|
|
|
|
5
|
return $self->timepiece->mdy; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub parse { |
217
|
1
|
|
|
1
|
1
|
5
|
my ($self, @args) = @_; |
218
|
|
|
|
|
|
|
|
219
|
1
|
|
|
|
|
5
|
my $timepiece = $self->timepiece->strptime(@args); |
220
|
|
|
|
|
|
|
|
221
|
1
|
|
|
|
|
246
|
return $self->reset($timepiece->epoch); |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub reset { |
225
|
134
|
|
|
134
|
1
|
14385
|
my ($self, $time) = @_; |
226
|
|
|
|
|
|
|
|
227
|
134
|
|
33
|
|
|
336
|
$time ||= time; |
228
|
|
|
|
|
|
|
|
229
|
134
|
|
|
|
|
420
|
my @time = gmtime $time; |
230
|
|
|
|
|
|
|
|
231
|
134
|
|
|
|
|
494
|
$self->day($time[3]); |
232
|
134
|
|
|
|
|
410
|
$self->hour($time[2]); |
233
|
134
|
|
|
|
|
397
|
$self->minute($time[1]); |
234
|
134
|
|
|
|
|
451
|
$self->month($time[4] + 1); |
235
|
134
|
|
|
|
|
479
|
$self->second($time[0]); |
236
|
134
|
|
|
|
|
479
|
$self->year($time[5] + 1900); |
237
|
|
|
|
|
|
|
|
238
|
134
|
|
|
|
|
994
|
return $self; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub restart { |
242
|
0
|
|
|
0
|
1
|
0
|
my ($self, $here) = @_; |
243
|
|
|
|
|
|
|
|
244
|
0
|
|
|
|
|
0
|
my $timepiece = $self->timepiece->truncate(to => $here); |
245
|
|
|
|
|
|
|
|
246
|
0
|
|
|
|
|
0
|
return $self->reset($timepiece->epoch); |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub restart_day { |
250
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
251
|
|
|
|
|
|
|
|
252
|
0
|
|
|
|
|
0
|
return $self->restart('day'); |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
sub restart_hour { |
256
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
257
|
|
|
|
|
|
|
|
258
|
0
|
|
|
|
|
0
|
return $self->restart('hour'); |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
sub restart_minute { |
262
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
263
|
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
0
|
return $self->restart('minute'); |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
sub restart_month { |
268
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
269
|
|
|
|
|
|
|
|
270
|
0
|
|
|
|
|
0
|
return $self->restart('month'); |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
sub restart_quarter { |
274
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
275
|
|
|
|
|
|
|
|
276
|
0
|
|
|
|
|
0
|
return $self->restart('quarter'); |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
sub restart_second { |
280
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
281
|
|
|
|
|
|
|
|
282
|
0
|
|
|
|
|
0
|
return $self->restart('second'); |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
sub restart_year { |
286
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
287
|
|
|
|
|
|
|
|
288
|
0
|
|
|
|
|
0
|
return $self->restart('year'); |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
sub rfc822 { |
292
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
293
|
|
|
|
|
|
|
|
294
|
1
|
|
|
|
|
6
|
return $self->format('%a, %d %b %Y %H:%M:%S %z'); |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
sub rfc1123 { |
298
|
1
|
|
|
1
|
1
|
5
|
my ($self) = @_; |
299
|
|
|
|
|
|
|
|
300
|
1
|
|
|
|
|
6
|
return $self->format('%a, %d %b %Y %T GMT'); |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
sub rfc3339 { |
304
|
6
|
|
|
6
|
1
|
15
|
my ($self) = @_; |
305
|
|
|
|
|
|
|
|
306
|
6
|
|
|
|
|
11
|
return "@{[$self->iso8601]}Z"; |
|
6
|
|
|
|
|
22
|
|
307
|
|
|
|
|
|
|
} |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
sub rfc7231 { |
310
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
311
|
|
|
|
|
|
|
|
312
|
1
|
|
|
|
|
6
|
return $self->timepiece->strftime; |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
sub set { |
316
|
9
|
|
|
9
|
1
|
34
|
my ($self, $data) = @_; |
317
|
|
|
|
|
|
|
|
318
|
9
|
|
|
|
|
20
|
for my $name (qw(day hour minute month second year)) { |
319
|
54
|
100
|
|
|
|
124
|
if (defined $data->{$name}) { |
320
|
22
|
|
|
|
|
105
|
$self->$name($data->{$name}); |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
|
324
|
9
|
|
|
|
|
117
|
return $self; |
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
sub set_hms { |
328
|
3
|
|
|
3
|
1
|
11
|
my ($self, $h, $m, $s) = @_; |
329
|
|
|
|
|
|
|
|
330
|
3
|
|
|
|
|
10
|
my $data = {}; |
331
|
|
|
|
|
|
|
|
332
|
3
|
100
|
|
|
|
11
|
$data->{hour} = $h if defined $h; |
333
|
3
|
50
|
|
|
|
11
|
$data->{minute} = $m if defined $m; |
334
|
3
|
50
|
|
|
|
12
|
$data->{second} = $s if defined $s; |
335
|
|
|
|
|
|
|
|
336
|
3
|
|
|
|
|
14
|
return $self->set($data); |
337
|
|
|
|
|
|
|
} |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
sub set_mdy { |
340
|
3
|
|
|
3
|
1
|
13
|
my ($self, $m, $d, $y) = @_; |
341
|
|
|
|
|
|
|
|
342
|
3
|
|
|
|
|
7
|
my $data = {}; |
343
|
|
|
|
|
|
|
|
344
|
3
|
50
|
|
|
|
13
|
$data->{day} = $d if defined $d; |
345
|
3
|
100
|
|
|
|
13
|
$data->{month} = $m if defined $m; |
346
|
3
|
100
|
|
|
|
13
|
$data->{year} = $y if defined $y; |
347
|
|
|
|
|
|
|
|
348
|
3
|
|
|
|
|
14
|
return $self->set($data); |
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
sub string { |
352
|
5
|
|
|
5
|
1
|
759
|
my ($self) = @_; |
353
|
|
|
|
|
|
|
|
354
|
5
|
|
|
|
|
21
|
return $self->rfc3339; |
355
|
|
|
|
|
|
|
} |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
sub sub { |
358
|
8
|
|
|
8
|
1
|
24
|
my ($self, $data) = @_; |
359
|
|
|
|
|
|
|
|
360
|
8
|
|
|
|
|
39
|
for my $name (qw(days hours minutes months seconds years)) { |
361
|
48
|
50
|
|
|
|
270
|
if (my $code = $self->can("sub_$name")) { |
362
|
48
|
|
|
|
|
206
|
$self->$code($data->{$name}); |
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
} |
365
|
|
|
|
|
|
|
|
366
|
8
|
|
|
|
|
111
|
return $self; |
367
|
|
|
|
|
|
|
} |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
sub sub_days { |
370
|
11
|
|
|
11
|
1
|
38
|
my ($self, $size) = @_; |
371
|
|
|
|
|
|
|
|
372
|
11
|
|
100
|
|
|
50
|
$size //= 0; |
373
|
|
|
|
|
|
|
|
374
|
11
|
100
|
|
|
|
58
|
$size = ($self->timeseconds->ONE_DAY * $size) if $size; |
375
|
|
|
|
|
|
|
|
376
|
11
|
|
|
|
|
144
|
return $self->reset($self->epoch - $size); |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
sub sub_hours { |
380
|
11
|
|
|
11
|
1
|
47
|
my ($self, $size) = @_; |
381
|
|
|
|
|
|
|
|
382
|
11
|
|
100
|
|
|
46
|
$size //= 0; |
383
|
|
|
|
|
|
|
|
384
|
11
|
100
|
|
|
|
51
|
$size = ($self->timeseconds->ONE_HOUR * $size) if $size; |
385
|
|
|
|
|
|
|
|
386
|
11
|
|
|
|
|
103
|
return $self->reset($self->epoch - $size); |
387
|
|
|
|
|
|
|
} |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
sub sub_hms { |
390
|
3
|
|
|
3
|
1
|
10
|
my ($self, $h, $m, $s) = @_; |
391
|
|
|
|
|
|
|
|
392
|
3
|
|
|
|
|
5
|
my $data = {}; |
393
|
|
|
|
|
|
|
|
394
|
3
|
100
|
|
|
|
16
|
$data->{hours} = $h if defined $h; |
395
|
3
|
50
|
|
|
|
12
|
$data->{minutes} = $m if defined $m; |
396
|
3
|
100
|
|
|
|
14
|
$data->{seconds} = $s if defined $s; |
397
|
|
|
|
|
|
|
|
398
|
3
|
|
|
|
|
15
|
return $self->sub($data); |
399
|
|
|
|
|
|
|
} |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
sub sub_mdy { |
402
|
3
|
|
|
3
|
1
|
13
|
my ($self, $m, $d, $y) = @_; |
403
|
|
|
|
|
|
|
|
404
|
3
|
|
|
|
|
9
|
my $data = {}; |
405
|
|
|
|
|
|
|
|
406
|
3
|
50
|
|
|
|
17
|
$data->{days} = $d if defined $d; |
407
|
3
|
50
|
|
|
|
12
|
$data->{months} = $m if defined $m; |
408
|
3
|
100
|
|
|
|
11
|
$data->{years} = $y if defined $y; |
409
|
|
|
|
|
|
|
|
410
|
3
|
|
|
|
|
14
|
return $self->sub($data); |
411
|
|
|
|
|
|
|
} |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
sub sub_minutes { |
414
|
11
|
|
|
11
|
1
|
40
|
my ($self, $size) = @_; |
415
|
|
|
|
|
|
|
|
416
|
11
|
|
100
|
|
|
56
|
$size //= 0; |
417
|
|
|
|
|
|
|
|
418
|
11
|
100
|
|
|
|
46
|
$size = ($self->timeseconds->ONE_MINUTE * $size) if $size; |
419
|
|
|
|
|
|
|
|
420
|
11
|
|
|
|
|
103
|
return $self->reset($self->epoch - $size); |
421
|
|
|
|
|
|
|
} |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
sub sub_months { |
424
|
11
|
|
|
11
|
1
|
41
|
my ($self, $size) = @_; |
425
|
|
|
|
|
|
|
|
426
|
11
|
|
100
|
|
|
64
|
$size //= 0; |
427
|
|
|
|
|
|
|
|
428
|
11
|
100
|
|
|
|
49
|
$size = ($self->timeseconds->ONE_MONTH * $size) if $size; |
429
|
|
|
|
|
|
|
|
430
|
11
|
|
|
|
|
105
|
return $self->reset($self->epoch - $size); |
431
|
|
|
|
|
|
|
} |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
sub sub_seconds { |
434
|
11
|
|
|
11
|
1
|
43
|
my ($self, $size) = @_; |
435
|
|
|
|
|
|
|
|
436
|
11
|
|
100
|
|
|
48
|
$size //= 0; |
437
|
|
|
|
|
|
|
|
438
|
11
|
|
|
|
|
32
|
return $self->reset($self->epoch - $size); |
439
|
|
|
|
|
|
|
} |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
sub sub_years { |
442
|
11
|
|
|
11
|
1
|
49
|
my ($self, $size) = @_; |
443
|
|
|
|
|
|
|
|
444
|
11
|
|
100
|
|
|
64
|
$size //= 0; |
445
|
|
|
|
|
|
|
|
446
|
11
|
100
|
|
|
|
40
|
$size = ($self->timeseconds->ONE_YEAR * $size) if $size; |
447
|
|
|
|
|
|
|
|
448
|
11
|
|
|
|
|
90
|
return $self->reset($self->epoch - $size); |
449
|
|
|
|
|
|
|
} |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
sub timelocal { |
452
|
358
|
|
|
358
|
0
|
584
|
my ($self) = @_; |
453
|
|
|
|
|
|
|
|
454
|
358
|
|
|
|
|
1051
|
require Time::Local; |
455
|
|
|
|
|
|
|
|
456
|
358
|
|
|
|
|
954
|
my $day = $self->day; |
457
|
358
|
|
|
|
|
998
|
my $hour = $self->hour; |
458
|
358
|
|
|
|
|
987
|
my $minute = $self->minute; |
459
|
358
|
|
|
|
|
930
|
my $month = $self->month - 1; |
460
|
358
|
|
|
|
|
951
|
my $second = $self->second; |
461
|
358
|
|
|
|
|
946
|
my $year = $self->year; |
462
|
|
|
|
|
|
|
|
463
|
358
|
|
|
|
|
1297
|
return Time::Local::timegm($second, $minute, $hour, $day, $month, $year); |
464
|
|
|
|
|
|
|
} |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
sub timepiece { |
467
|
358
|
|
|
358
|
0
|
728
|
my ($self) = @_; |
468
|
|
|
|
|
|
|
|
469
|
358
|
|
|
|
|
2966
|
require Time::Piece; |
470
|
|
|
|
|
|
|
|
471
|
358
|
|
|
|
|
20110
|
return Time::Piece->gmtime(0 + $self->timelocal); |
472
|
|
|
|
|
|
|
} |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
sub timeseconds { |
475
|
60
|
|
|
60
|
0
|
139
|
my ($self, $time) = @_; |
476
|
|
|
|
|
|
|
|
477
|
60
|
|
|
|
|
273
|
require Time::Seconds; |
478
|
|
|
|
|
|
|
|
479
|
60
|
|
50
|
|
|
608
|
return Time::Seconds->new($time // 0); |
480
|
|
|
|
|
|
|
} |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
1; |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
=head1 NAME |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
Venus::Date - Date Class |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
=cut |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
=head1 ABSTRACT |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
Date Class for Perl 5 |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
=cut |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=head1 SYNOPSIS |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
package main; |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
use Venus::Date; |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
my $date = Venus::Date->new(570672000); |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
# $date->string; |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
# '1988-02-01T00:00:00Z' |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=cut |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=head1 DESCRIPTION |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
This package provides methods for formatting, parsing, and manipulating date |
515
|
|
|
|
|
|
|
and time data. |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
=cut |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
This package has the following attributes: |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
=cut |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
=head2 day |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
day(Int) |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
This attribute is read-write, accepts C<(Int)> values, and is optional. |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
=cut |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
=head2 month |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
month(Int) |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
This attribute is read-write, accepts C<(Int)> values, and is optional. |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=cut |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
=head2 year |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
year(Int) |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
This attribute is read-write, accepts C<(Int)> values, and is optional. |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=cut |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
=head2 hour |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
hour(Int) |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
This attribute is read-write, accepts C<(Int)> values, and is optional. |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
=cut |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
=head2 minute |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
minute(Int) |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
This attribute is read-write, accepts C<(Int)> values, and is optional. |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
=cut |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
=head2 second |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
second(Int) |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
This attribute is read-write, accepts C<(Int)> values, and is optional. |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
=cut |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
=head1 INHERITS |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
This package inherits behaviors from: |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
L |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=cut |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
=head1 INTEGRATES |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
This package integrates behaviors from: |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
L |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
L |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
=cut |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
=head1 METHODS |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
This package provides the following methods: |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=cut |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=head2 add |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
add(HashRef $data) (Date) |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
The add method increments the date and time attributes specified. |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
I> |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
=over 4 |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
=item add example 1 |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
# given: synopsis; |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
$date = $date->add({ |
612
|
|
|
|
|
|
|
days => 1, |
613
|
|
|
|
|
|
|
months => 1, |
614
|
|
|
|
|
|
|
years => 1, |
615
|
|
|
|
|
|
|
}); |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
# $date->string; # 1989-03-03T16:17:54Z |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
# $date->epoch; # 604945074 |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
=back |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
=over 4 |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
=item add example 2 |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
# given: synopsis; |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
$date = $date->add({ |
633
|
|
|
|
|
|
|
hours => 1, |
634
|
|
|
|
|
|
|
minutes => 1, |
635
|
|
|
|
|
|
|
seconds => 1, |
636
|
|
|
|
|
|
|
}); |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T01:01:01Z |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
# $date->epoch; # 570675661 |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
=back |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
=cut |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
=head2 add_days |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
add_days(Int $days) (Any) |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
The add_days method increments the C attribute. |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
I> |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
=over 4 |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
=item add_days example 1 |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
# given: synopsis; |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
$date = $date->add_days(1); |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
# $date->string; # 1988-02-02T00:00:00Z |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
# $date->epoch; # 570758400 |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
=back |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
=over 4 |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
=item add_days example 2 |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
# given: synopsis; |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
$date = $date->add_days(40); |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
# $date->string; # 1988-03-12T00:00:00Z |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
# $date->epoch; # 574128000 |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
=back |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
=over 4 |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
=item add_days example 3 |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
# given: synopsis; |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
$date = $date->add_days(-1); |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T00:00:00Z |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
# $date->epoch; # 570585600 |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
=back |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
=cut |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
=head2 add_hms |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
add_hms(Maybe[Int] $hours, Maybe[Int] $minutes, Maybe[Int] $seconds) (Date) |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
The add_hms method increments the C, C, and C attributes. |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
I> |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
=over 4 |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
=item add_hms example 1 |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
# given: synopsis; |
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
$date = $date->add_hms(1, 0, 0); |
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T01:00:00Z |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
# $date->epoch; # 570675600 |
717
|
|
|
|
|
|
|
|
718
|
|
|
|
|
|
|
=back |
719
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
=over 4 |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
=item add_hms example 2 |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
# given: synopsis; |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
$date = $date->add_hms(undef, 1, 1); |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:01:01Z |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
# $date->epoch; # 570672061 |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=back |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
=over 4 |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
=item add_hms example 3 |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
# given: synopsis; |
739
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
$date = $date->add_hms(1, 1); |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T01:01:00Z |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
# $date->epoch; # 570675660 |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
=back |
747
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
=cut |
749
|
|
|
|
|
|
|
|
750
|
|
|
|
|
|
|
=head2 add_hours |
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
add_hours(Int $hours) (Any) |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
The add_hours method increments the C attribute. |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
I> |
757
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
=over 4 |
759
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
=item add_hours example 1 |
761
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
# given: synopsis; |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
$date = $date->add_hours(1); |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T01:00:00Z |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
# $date->epoch; # 570675600 |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
=back |
771
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
=over 4 |
773
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
=item add_hours example 2 |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
# given: synopsis; |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
$date = $date->add_hours(25); |
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
# $date->string; # 1988-02-02T01:00:00Z |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
# $date->epoch; # 570762000 |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
=back |
785
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
=over 4 |
787
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
=item add_hours example 3 |
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
# given: synopsis; |
791
|
|
|
|
|
|
|
|
792
|
|
|
|
|
|
|
$date = $date->add_hours(-1); |
793
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T23:00:00Z |
795
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
# $date->epoch; # 570668400 |
797
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
=back |
799
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
=cut |
801
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
=head2 add_mdy |
803
|
|
|
|
|
|
|
|
804
|
|
|
|
|
|
|
add_mdy(Maybe[Int] $months, Maybe[Int] $days, Maybe[Int] $years) (Date) |
805
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
The add_mdy method increments the C, C, and C attributes. |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
I> |
809
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
=over 4 |
811
|
|
|
|
|
|
|
|
812
|
|
|
|
|
|
|
=item add_mdy example 1 |
813
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
# given: synopsis; |
815
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
$date = $date->add_mdy(1, 0, 0); |
817
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
# $date->string; # 1988-03-02T10:29:04Z |
819
|
|
|
|
|
|
|
|
820
|
|
|
|
|
|
|
# $date->epoch; # 573301744 |
821
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
=back |
823
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
=over 4 |
825
|
|
|
|
|
|
|
|
826
|
|
|
|
|
|
|
=item add_mdy example 2 |
827
|
|
|
|
|
|
|
|
828
|
|
|
|
|
|
|
# given: synopsis; |
829
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
$date = $date->add_mdy(undef, 1, 1); |
831
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
# $date->string; # 1989-02-01T05:48:50Z |
833
|
|
|
|
|
|
|
|
834
|
|
|
|
|
|
|
# $date->epoch; # 602315330 |
835
|
|
|
|
|
|
|
|
836
|
|
|
|
|
|
|
=back |
837
|
|
|
|
|
|
|
|
838
|
|
|
|
|
|
|
=over 4 |
839
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
=item add_mdy example 3 |
841
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
# given: synopsis; |
843
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
$date = $date->add_mdy(1, 1); |
845
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
# $date->string; # 1988-03-03T10:29:04Z |
847
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
# $date->epoch; # 573388144 |
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
=back |
851
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
=cut |
853
|
|
|
|
|
|
|
|
854
|
|
|
|
|
|
|
=head2 add_minutes |
855
|
|
|
|
|
|
|
|
856
|
|
|
|
|
|
|
add_minutes(Int $minutes) (Date) |
857
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
The add_minutes method increments the C attribute. |
859
|
|
|
|
|
|
|
|
860
|
|
|
|
|
|
|
I> |
861
|
|
|
|
|
|
|
|
862
|
|
|
|
|
|
|
=over 4 |
863
|
|
|
|
|
|
|
|
864
|
|
|
|
|
|
|
=item add_minutes example 1 |
865
|
|
|
|
|
|
|
|
866
|
|
|
|
|
|
|
# given: synopsis; |
867
|
|
|
|
|
|
|
|
868
|
|
|
|
|
|
|
$date = $date->add_minutes(1); |
869
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:01:00Z |
871
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
# $date->epoch; # 570672060 |
873
|
|
|
|
|
|
|
|
874
|
|
|
|
|
|
|
=back |
875
|
|
|
|
|
|
|
|
876
|
|
|
|
|
|
|
=over 4 |
877
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
=item add_minutes example 2 |
879
|
|
|
|
|
|
|
|
880
|
|
|
|
|
|
|
# given: synopsis; |
881
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
$date = $date->add_minutes(61); |
883
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T01:01:00Z |
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
# $date->epoch; # 570675660 |
887
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
=back |
889
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
=over 4 |
891
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
=item add_minutes example 3 |
893
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
# given: synopsis; |
895
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
$date = $date->add_minutes(-1); |
897
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T23:59:00Z |
899
|
|
|
|
|
|
|
|
900
|
|
|
|
|
|
|
# $date->epoch; # 570671940 |
901
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
=back |
903
|
|
|
|
|
|
|
|
904
|
|
|
|
|
|
|
=cut |
905
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
=head2 add_months |
907
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
add_months(Int $months) (Date) |
909
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
The add_months method increments the C attribute. |
911
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
I> |
913
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
=over 4 |
915
|
|
|
|
|
|
|
|
916
|
|
|
|
|
|
|
=item add_months example 1 |
917
|
|
|
|
|
|
|
|
918
|
|
|
|
|
|
|
# given: synopsis; |
919
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
$date = $date->add_months(1); |
921
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
# $date->string; # 1988-03-02T10:29:04Z |
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
# $date->epoch; # 573301744 |
925
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
=back |
927
|
|
|
|
|
|
|
|
928
|
|
|
|
|
|
|
=over 4 |
929
|
|
|
|
|
|
|
|
930
|
|
|
|
|
|
|
=item add_months example 2 |
931
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
# given: synopsis; |
933
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
$date = $date->add_months(13); |
935
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
# $date->string; # 1989-03-02T16:17:52Z |
937
|
|
|
|
|
|
|
|
938
|
|
|
|
|
|
|
# $date->epoch; # 604858672 |
939
|
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
=back |
941
|
|
|
|
|
|
|
|
942
|
|
|
|
|
|
|
=over 4 |
943
|
|
|
|
|
|
|
|
944
|
|
|
|
|
|
|
=item add_months example 3 |
945
|
|
|
|
|
|
|
|
946
|
|
|
|
|
|
|
# given: synopsis; |
947
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
$date = $date->add_months(-1); |
949
|
|
|
|
|
|
|
|
950
|
|
|
|
|
|
|
# $date->string; # 1988-01-01T13:30:56Z |
951
|
|
|
|
|
|
|
|
952
|
|
|
|
|
|
|
# $date->epoch; # 568042256 |
953
|
|
|
|
|
|
|
|
954
|
|
|
|
|
|
|
=back |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
=cut |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
=head2 add_seconds |
959
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
add_seconds(Int $seconds) (Date) |
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
The add_seconds method increments the C attribute. |
963
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
I> |
965
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
=over 4 |
967
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
=item add_seconds example 1 |
969
|
|
|
|
|
|
|
|
970
|
|
|
|
|
|
|
# given: synopsis; |
971
|
|
|
|
|
|
|
|
972
|
|
|
|
|
|
|
$date = $date->add_seconds(1); |
973
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:00:01Z |
975
|
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
# $date->epoch; # 570672001 |
977
|
|
|
|
|
|
|
|
978
|
|
|
|
|
|
|
=back |
979
|
|
|
|
|
|
|
|
980
|
|
|
|
|
|
|
=over 4 |
981
|
|
|
|
|
|
|
|
982
|
|
|
|
|
|
|
=item add_seconds example 2 |
983
|
|
|
|
|
|
|
|
984
|
|
|
|
|
|
|
# given: synopsis; |
985
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
$date = $date->add_seconds(61); |
987
|
|
|
|
|
|
|
|
988
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:01:01Z |
989
|
|
|
|
|
|
|
|
990
|
|
|
|
|
|
|
# $date->epoch; # 570672061 |
991
|
|
|
|
|
|
|
|
992
|
|
|
|
|
|
|
=back |
993
|
|
|
|
|
|
|
|
994
|
|
|
|
|
|
|
=over 4 |
995
|
|
|
|
|
|
|
|
996
|
|
|
|
|
|
|
=item add_seconds example 3 |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
# given: synopsis; |
999
|
|
|
|
|
|
|
|
1000
|
|
|
|
|
|
|
$date = $date->add_seconds(-1); |
1001
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T23:59:59Z |
1003
|
|
|
|
|
|
|
|
1004
|
|
|
|
|
|
|
# $date->epoch; # 570671999 |
1005
|
|
|
|
|
|
|
|
1006
|
|
|
|
|
|
|
=back |
1007
|
|
|
|
|
|
|
|
1008
|
|
|
|
|
|
|
=cut |
1009
|
|
|
|
|
|
|
|
1010
|
|
|
|
|
|
|
=head2 add_years |
1011
|
|
|
|
|
|
|
|
1012
|
|
|
|
|
|
|
add_years(Int $years) (Date) |
1013
|
|
|
|
|
|
|
|
1014
|
|
|
|
|
|
|
The add_years method increments the C attribute. |
1015
|
|
|
|
|
|
|
|
1016
|
|
|
|
|
|
|
I> |
1017
|
|
|
|
|
|
|
|
1018
|
|
|
|
|
|
|
=over 4 |
1019
|
|
|
|
|
|
|
|
1020
|
|
|
|
|
|
|
=item add_years example 1 |
1021
|
|
|
|
|
|
|
|
1022
|
|
|
|
|
|
|
# given: synopsis; |
1023
|
|
|
|
|
|
|
|
1024
|
|
|
|
|
|
|
$date = $date->add_years(1); |
1025
|
|
|
|
|
|
|
|
1026
|
|
|
|
|
|
|
# $date->string; # 1989-01-31T05:48:50Z |
1027
|
|
|
|
|
|
|
|
1028
|
|
|
|
|
|
|
# $date->epoch; # 602228930 |
1029
|
|
|
|
|
|
|
|
1030
|
|
|
|
|
|
|
=back |
1031
|
|
|
|
|
|
|
|
1032
|
|
|
|
|
|
|
=over 4 |
1033
|
|
|
|
|
|
|
|
1034
|
|
|
|
|
|
|
=item add_years example 2 |
1035
|
|
|
|
|
|
|
|
1036
|
|
|
|
|
|
|
# given: synopsis; |
1037
|
|
|
|
|
|
|
|
1038
|
|
|
|
|
|
|
$date = $date->add_years(50); |
1039
|
|
|
|
|
|
|
|
1040
|
|
|
|
|
|
|
# $date->string; # 2038-01-31T02:41:40Z |
1041
|
|
|
|
|
|
|
|
1042
|
|
|
|
|
|
|
# $date->epoch; # 2148518500 |
1043
|
|
|
|
|
|
|
|
1044
|
|
|
|
|
|
|
=back |
1045
|
|
|
|
|
|
|
|
1046
|
|
|
|
|
|
|
=over 4 |
1047
|
|
|
|
|
|
|
|
1048
|
|
|
|
|
|
|
=item add_years example 3 |
1049
|
|
|
|
|
|
|
|
1050
|
|
|
|
|
|
|
# given: synopsis; |
1051
|
|
|
|
|
|
|
|
1052
|
|
|
|
|
|
|
$date = $date->add_years(-1); |
1053
|
|
|
|
|
|
|
|
1054
|
|
|
|
|
|
|
# $date->string; # 1987-01-31T18:11:10Z |
1055
|
|
|
|
|
|
|
|
1056
|
|
|
|
|
|
|
# $date->epoch; # 539115070 |
1057
|
|
|
|
|
|
|
|
1058
|
|
|
|
|
|
|
=back |
1059
|
|
|
|
|
|
|
|
1060
|
|
|
|
|
|
|
=cut |
1061
|
|
|
|
|
|
|
|
1062
|
|
|
|
|
|
|
=head2 epoch |
1063
|
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
epoch() (Int) |
1065
|
|
|
|
|
|
|
|
1066
|
|
|
|
|
|
|
The epoch method returns the epoch. |
1067
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
I> |
1069
|
|
|
|
|
|
|
|
1070
|
|
|
|
|
|
|
=over 4 |
1071
|
|
|
|
|
|
|
|
1072
|
|
|
|
|
|
|
=item epoch example 1 |
1073
|
|
|
|
|
|
|
|
1074
|
|
|
|
|
|
|
# given: synopsis; |
1075
|
|
|
|
|
|
|
|
1076
|
|
|
|
|
|
|
my $epoch = $date->epoch; |
1077
|
|
|
|
|
|
|
|
1078
|
|
|
|
|
|
|
# 570672000 |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
=back |
1081
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
=cut |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
=head2 explain |
1085
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
explain() (Int) |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
The explain method returns the epoch and is used in stringification operations. |
1089
|
|
|
|
|
|
|
|
1090
|
|
|
|
|
|
|
I> |
1091
|
|
|
|
|
|
|
|
1092
|
|
|
|
|
|
|
=over 4 |
1093
|
|
|
|
|
|
|
|
1094
|
|
|
|
|
|
|
=item explain example 1 |
1095
|
|
|
|
|
|
|
|
1096
|
|
|
|
|
|
|
# given: synopsis; |
1097
|
|
|
|
|
|
|
|
1098
|
|
|
|
|
|
|
my $explain = $date->explain; |
1099
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
# 570672000 |
1101
|
|
|
|
|
|
|
|
1102
|
|
|
|
|
|
|
=back |
1103
|
|
|
|
|
|
|
|
1104
|
|
|
|
|
|
|
=cut |
1105
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
=head2 format |
1107
|
|
|
|
|
|
|
|
1108
|
|
|
|
|
|
|
format(Str $format) (Str) |
1109
|
|
|
|
|
|
|
|
1110
|
|
|
|
|
|
|
The format method returns the formatted date and time string. See |
1111
|
|
|
|
|
|
|
L for formatting |
1112
|
|
|
|
|
|
|
rules. |
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
I> |
1115
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
=over 4 |
1117
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
=item format example 1 |
1119
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
# given: synopsis; |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
my $format = $date->format('%A, %B %e, %Y'); |
1123
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
# Monday, February 1, 1988 |
1125
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
=back |
1127
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
=over 4 |
1129
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
=item format example 2 |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
# given: synopsis; |
1133
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
my $format = $date->format('%b %e %a'); |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
# Feb 1 Mon |
1137
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
=back |
1139
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
=cut |
1141
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
=head2 hms |
1143
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
hms() (Str) |
1145
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
The hms method returns the time formatted as C. |
1147
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
I> |
1149
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
=over 4 |
1151
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
=item hms example 1 |
1153
|
|
|
|
|
|
|
|
1154
|
|
|
|
|
|
|
# given: synopsis; |
1155
|
|
|
|
|
|
|
|
1156
|
|
|
|
|
|
|
my $hms = $date->hms; |
1157
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
# 00:00:00 |
1159
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
=back |
1161
|
|
|
|
|
|
|
|
1162
|
|
|
|
|
|
|
=cut |
1163
|
|
|
|
|
|
|
|
1164
|
|
|
|
|
|
|
=head2 iso8601 |
1165
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
iso8601() (Str) |
1167
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
The iso8601 method returns the date and time formatted as an ISO8601 string. |
1169
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
I> |
1171
|
|
|
|
|
|
|
|
1172
|
|
|
|
|
|
|
=over 4 |
1173
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
=item iso8601 example 1 |
1175
|
|
|
|
|
|
|
|
1176
|
|
|
|
|
|
|
# given: synopsis; |
1177
|
|
|
|
|
|
|
|
1178
|
|
|
|
|
|
|
my $iso8601 = $date->iso8601; |
1179
|
|
|
|
|
|
|
|
1180
|
|
|
|
|
|
|
# 1988-02-01T00:00:00 |
1181
|
|
|
|
|
|
|
|
1182
|
|
|
|
|
|
|
=back |
1183
|
|
|
|
|
|
|
|
1184
|
|
|
|
|
|
|
=cut |
1185
|
|
|
|
|
|
|
|
1186
|
|
|
|
|
|
|
=head2 mdy |
1187
|
|
|
|
|
|
|
|
1188
|
|
|
|
|
|
|
mdy() (Str) |
1189
|
|
|
|
|
|
|
|
1190
|
|
|
|
|
|
|
The mdy method returns the date formatted as C. |
1191
|
|
|
|
|
|
|
|
1192
|
|
|
|
|
|
|
I> |
1193
|
|
|
|
|
|
|
|
1194
|
|
|
|
|
|
|
=over 4 |
1195
|
|
|
|
|
|
|
|
1196
|
|
|
|
|
|
|
=item mdy example 1 |
1197
|
|
|
|
|
|
|
|
1198
|
|
|
|
|
|
|
# given: synopsis; |
1199
|
|
|
|
|
|
|
|
1200
|
|
|
|
|
|
|
my $mdy = $date->mdy; |
1201
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
# 02-01-1988 |
1203
|
|
|
|
|
|
|
|
1204
|
|
|
|
|
|
|
=back |
1205
|
|
|
|
|
|
|
|
1206
|
|
|
|
|
|
|
=cut |
1207
|
|
|
|
|
|
|
|
1208
|
|
|
|
|
|
|
=head2 parse |
1209
|
|
|
|
|
|
|
|
1210
|
|
|
|
|
|
|
parse(Any @data) (Date) |
1211
|
|
|
|
|
|
|
|
1212
|
|
|
|
|
|
|
The parse method resets and returns a date object based on the parsed time |
1213
|
|
|
|
|
|
|
provided. See L for |
1214
|
|
|
|
|
|
|
parsing rules. |
1215
|
|
|
|
|
|
|
|
1216
|
|
|
|
|
|
|
I> |
1217
|
|
|
|
|
|
|
|
1218
|
|
|
|
|
|
|
=over 4 |
1219
|
|
|
|
|
|
|
|
1220
|
|
|
|
|
|
|
=item parse example 1 |
1221
|
|
|
|
|
|
|
|
1222
|
|
|
|
|
|
|
# given: synopsis; |
1223
|
|
|
|
|
|
|
|
1224
|
|
|
|
|
|
|
$date = $date->parse('Monday, February 1, 1988', '%A, %B %e, %Y'); |
1225
|
|
|
|
|
|
|
|
1226
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:00:00Z |
1227
|
|
|
|
|
|
|
|
1228
|
|
|
|
|
|
|
# $date->epoch; # 570672000 |
1229
|
|
|
|
|
|
|
|
1230
|
|
|
|
|
|
|
=back |
1231
|
|
|
|
|
|
|
|
1232
|
|
|
|
|
|
|
=cut |
1233
|
|
|
|
|
|
|
|
1234
|
|
|
|
|
|
|
=head2 reset |
1235
|
|
|
|
|
|
|
|
1236
|
|
|
|
|
|
|
reset(Int $time) (Date) |
1237
|
|
|
|
|
|
|
|
1238
|
|
|
|
|
|
|
The reset method resets all attributes to correspond with the epoch provided. |
1239
|
|
|
|
|
|
|
|
1240
|
|
|
|
|
|
|
I> |
1241
|
|
|
|
|
|
|
|
1242
|
|
|
|
|
|
|
=over 4 |
1243
|
|
|
|
|
|
|
|
1244
|
|
|
|
|
|
|
=item reset example 1 |
1245
|
|
|
|
|
|
|
|
1246
|
|
|
|
|
|
|
# given: synopsis; |
1247
|
|
|
|
|
|
|
|
1248
|
|
|
|
|
|
|
$date = $date->reset(631152000); |
1249
|
|
|
|
|
|
|
|
1250
|
|
|
|
|
|
|
# $date->string; # 1990-01-01T00:00:00Z |
1251
|
|
|
|
|
|
|
|
1252
|
|
|
|
|
|
|
# $date->epoch; # 631152000 |
1253
|
|
|
|
|
|
|
|
1254
|
|
|
|
|
|
|
=back |
1255
|
|
|
|
|
|
|
|
1256
|
|
|
|
|
|
|
=cut |
1257
|
|
|
|
|
|
|
|
1258
|
|
|
|
|
|
|
=head2 restart |
1259
|
|
|
|
|
|
|
|
1260
|
|
|
|
|
|
|
restart(Str $interval) (Date) |
1261
|
|
|
|
|
|
|
|
1262
|
|
|
|
|
|
|
The restart method truncates the date and time to the specified unit of time, |
1263
|
|
|
|
|
|
|
e.g. C, C, C, C, C, C, C. |
1264
|
|
|
|
|
|
|
|
1265
|
|
|
|
|
|
|
I> |
1266
|
|
|
|
|
|
|
|
1267
|
|
|
|
|
|
|
=over 4 |
1268
|
|
|
|
|
|
|
|
1269
|
|
|
|
|
|
|
=item restart example 1 |
1270
|
|
|
|
|
|
|
|
1271
|
|
|
|
|
|
|
# given: synopsis; |
1272
|
|
|
|
|
|
|
|
1273
|
|
|
|
|
|
|
$date = $date->restart('year'); |
1274
|
|
|
|
|
|
|
|
1275
|
|
|
|
|
|
|
# $date->string; # 1988-01-01T00:00:00Z |
1276
|
|
|
|
|
|
|
|
1277
|
|
|
|
|
|
|
# $date->epoch; # 567993600 |
1278
|
|
|
|
|
|
|
|
1279
|
|
|
|
|
|
|
=back |
1280
|
|
|
|
|
|
|
|
1281
|
|
|
|
|
|
|
=over 4 |
1282
|
|
|
|
|
|
|
|
1283
|
|
|
|
|
|
|
=item restart example 2 |
1284
|
|
|
|
|
|
|
|
1285
|
|
|
|
|
|
|
# given: synopsis; |
1286
|
|
|
|
|
|
|
|
1287
|
|
|
|
|
|
|
$date = $date->restart('quarter'); |
1288
|
|
|
|
|
|
|
|
1289
|
|
|
|
|
|
|
# $date->string; # 1988-01-01T00:00:00Z |
1290
|
|
|
|
|
|
|
|
1291
|
|
|
|
|
|
|
# $date->epoch; # 567993600 |
1292
|
|
|
|
|
|
|
|
1293
|
|
|
|
|
|
|
=back |
1294
|
|
|
|
|
|
|
|
1295
|
|
|
|
|
|
|
=over 4 |
1296
|
|
|
|
|
|
|
|
1297
|
|
|
|
|
|
|
=item restart example 3 |
1298
|
|
|
|
|
|
|
|
1299
|
|
|
|
|
|
|
# given: synopsis; |
1300
|
|
|
|
|
|
|
|
1301
|
|
|
|
|
|
|
$date = $date->restart('month'); |
1302
|
|
|
|
|
|
|
|
1303
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:00:00Z |
1304
|
|
|
|
|
|
|
|
1305
|
|
|
|
|
|
|
# $date->epoch; # 570672000 |
1306
|
|
|
|
|
|
|
|
1307
|
|
|
|
|
|
|
=back |
1308
|
|
|
|
|
|
|
|
1309
|
|
|
|
|
|
|
=cut |
1310
|
|
|
|
|
|
|
|
1311
|
|
|
|
|
|
|
=head2 restart_day |
1312
|
|
|
|
|
|
|
|
1313
|
|
|
|
|
|
|
restart_day() (Date) |
1314
|
|
|
|
|
|
|
|
1315
|
|
|
|
|
|
|
The restart_day method truncates the date and time to the C. |
1316
|
|
|
|
|
|
|
|
1317
|
|
|
|
|
|
|
I> |
1318
|
|
|
|
|
|
|
|
1319
|
|
|
|
|
|
|
=over 4 |
1320
|
|
|
|
|
|
|
|
1321
|
|
|
|
|
|
|
=item restart_day example 1 |
1322
|
|
|
|
|
|
|
|
1323
|
|
|
|
|
|
|
# given: synopsis; |
1324
|
|
|
|
|
|
|
|
1325
|
|
|
|
|
|
|
$date = $date->restart_day; |
1326
|
|
|
|
|
|
|
|
1327
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:00:00Z |
1328
|
|
|
|
|
|
|
|
1329
|
|
|
|
|
|
|
# $date->epoch; # 570672000 |
1330
|
|
|
|
|
|
|
|
1331
|
|
|
|
|
|
|
=back |
1332
|
|
|
|
|
|
|
|
1333
|
|
|
|
|
|
|
=cut |
1334
|
|
|
|
|
|
|
|
1335
|
|
|
|
|
|
|
=head2 restart_hour |
1336
|
|
|
|
|
|
|
|
1337
|
|
|
|
|
|
|
restart_hour() (Date) |
1338
|
|
|
|
|
|
|
|
1339
|
|
|
|
|
|
|
The restart_hour method truncates the date and time to the C. |
1340
|
|
|
|
|
|
|
|
1341
|
|
|
|
|
|
|
I> |
1342
|
|
|
|
|
|
|
|
1343
|
|
|
|
|
|
|
=over 4 |
1344
|
|
|
|
|
|
|
|
1345
|
|
|
|
|
|
|
=item restart_hour example 1 |
1346
|
|
|
|
|
|
|
|
1347
|
|
|
|
|
|
|
# given: synopsis; |
1348
|
|
|
|
|
|
|
|
1349
|
|
|
|
|
|
|
$date = $date->restart_hour; |
1350
|
|
|
|
|
|
|
|
1351
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:00:00Z |
1352
|
|
|
|
|
|
|
|
1353
|
|
|
|
|
|
|
# $date->epoch; # 570672000 |
1354
|
|
|
|
|
|
|
|
1355
|
|
|
|
|
|
|
=back |
1356
|
|
|
|
|
|
|
|
1357
|
|
|
|
|
|
|
=cut |
1358
|
|
|
|
|
|
|
|
1359
|
|
|
|
|
|
|
=head2 restart_minute |
1360
|
|
|
|
|
|
|
|
1361
|
|
|
|
|
|
|
restart_minute() (Date) |
1362
|
|
|
|
|
|
|
|
1363
|
|
|
|
|
|
|
The restart_minute method truncates the date and time to the C. |
1364
|
|
|
|
|
|
|
|
1365
|
|
|
|
|
|
|
I> |
1366
|
|
|
|
|
|
|
|
1367
|
|
|
|
|
|
|
=over 4 |
1368
|
|
|
|
|
|
|
|
1369
|
|
|
|
|
|
|
=item restart_minute example 1 |
1370
|
|
|
|
|
|
|
|
1371
|
|
|
|
|
|
|
# given: synopsis; |
1372
|
|
|
|
|
|
|
|
1373
|
|
|
|
|
|
|
$date = $date->restart_minute; |
1374
|
|
|
|
|
|
|
|
1375
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:00:00Z |
1376
|
|
|
|
|
|
|
|
1377
|
|
|
|
|
|
|
# $date->epoch; # 570672000 |
1378
|
|
|
|
|
|
|
|
1379
|
|
|
|
|
|
|
=back |
1380
|
|
|
|
|
|
|
|
1381
|
|
|
|
|
|
|
=cut |
1382
|
|
|
|
|
|
|
|
1383
|
|
|
|
|
|
|
=head2 restart_month |
1384
|
|
|
|
|
|
|
|
1385
|
|
|
|
|
|
|
restart_month() (Date) |
1386
|
|
|
|
|
|
|
|
1387
|
|
|
|
|
|
|
The restart_month method truncates the date and time to the C. |
1388
|
|
|
|
|
|
|
|
1389
|
|
|
|
|
|
|
I> |
1390
|
|
|
|
|
|
|
|
1391
|
|
|
|
|
|
|
=over 4 |
1392
|
|
|
|
|
|
|
|
1393
|
|
|
|
|
|
|
=item restart_month example 1 |
1394
|
|
|
|
|
|
|
|
1395
|
|
|
|
|
|
|
# given: synopsis; |
1396
|
|
|
|
|
|
|
|
1397
|
|
|
|
|
|
|
$date = $date->restart_month; |
1398
|
|
|
|
|
|
|
|
1399
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:00:00Z |
1400
|
|
|
|
|
|
|
|
1401
|
|
|
|
|
|
|
# $date->epoch; # 570672000 |
1402
|
|
|
|
|
|
|
|
1403
|
|
|
|
|
|
|
=back |
1404
|
|
|
|
|
|
|
|
1405
|
|
|
|
|
|
|
=cut |
1406
|
|
|
|
|
|
|
|
1407
|
|
|
|
|
|
|
=head2 restart_quarter |
1408
|
|
|
|
|
|
|
|
1409
|
|
|
|
|
|
|
restart_quarter() (Date) |
1410
|
|
|
|
|
|
|
|
1411
|
|
|
|
|
|
|
The restart_quarter method truncates the date and time to the C. |
1412
|
|
|
|
|
|
|
|
1413
|
|
|
|
|
|
|
I> |
1414
|
|
|
|
|
|
|
|
1415
|
|
|
|
|
|
|
=over 4 |
1416
|
|
|
|
|
|
|
|
1417
|
|
|
|
|
|
|
=item restart_quarter example 1 |
1418
|
|
|
|
|
|
|
|
1419
|
|
|
|
|
|
|
# given: synopsis; |
1420
|
|
|
|
|
|
|
|
1421
|
|
|
|
|
|
|
$date = $date->restart_quarter; |
1422
|
|
|
|
|
|
|
|
1423
|
|
|
|
|
|
|
# $date->string; # 1988-01-01T00:00:00Z |
1424
|
|
|
|
|
|
|
|
1425
|
|
|
|
|
|
|
# $date->epoch; # 567993600 |
1426
|
|
|
|
|
|
|
|
1427
|
|
|
|
|
|
|
=back |
1428
|
|
|
|
|
|
|
|
1429
|
|
|
|
|
|
|
=cut |
1430
|
|
|
|
|
|
|
|
1431
|
|
|
|
|
|
|
=head2 restart_second |
1432
|
|
|
|
|
|
|
|
1433
|
|
|
|
|
|
|
restart_second() (Date) |
1434
|
|
|
|
|
|
|
|
1435
|
|
|
|
|
|
|
The restart_second method truncates the date and time to the C. |
1436
|
|
|
|
|
|
|
|
1437
|
|
|
|
|
|
|
I> |
1438
|
|
|
|
|
|
|
|
1439
|
|
|
|
|
|
|
=over 4 |
1440
|
|
|
|
|
|
|
|
1441
|
|
|
|
|
|
|
=item restart_second example 1 |
1442
|
|
|
|
|
|
|
|
1443
|
|
|
|
|
|
|
# given: synopsis; |
1444
|
|
|
|
|
|
|
|
1445
|
|
|
|
|
|
|
$date = $date->restart_second; |
1446
|
|
|
|
|
|
|
|
1447
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:00:00Z |
1448
|
|
|
|
|
|
|
|
1449
|
|
|
|
|
|
|
# $date->epoch; # 570672000 |
1450
|
|
|
|
|
|
|
|
1451
|
|
|
|
|
|
|
=back |
1452
|
|
|
|
|
|
|
|
1453
|
|
|
|
|
|
|
=cut |
1454
|
|
|
|
|
|
|
|
1455
|
|
|
|
|
|
|
=head2 restart_year |
1456
|
|
|
|
|
|
|
|
1457
|
|
|
|
|
|
|
restart_year() (Date) |
1458
|
|
|
|
|
|
|
|
1459
|
|
|
|
|
|
|
The restart_year method truncates the date and time to the C. |
1460
|
|
|
|
|
|
|
|
1461
|
|
|
|
|
|
|
I> |
1462
|
|
|
|
|
|
|
|
1463
|
|
|
|
|
|
|
=over 4 |
1464
|
|
|
|
|
|
|
|
1465
|
|
|
|
|
|
|
=item restart_year example 1 |
1466
|
|
|
|
|
|
|
|
1467
|
|
|
|
|
|
|
# given: synopsis; |
1468
|
|
|
|
|
|
|
|
1469
|
|
|
|
|
|
|
$date = $date->restart_year; |
1470
|
|
|
|
|
|
|
|
1471
|
|
|
|
|
|
|
# $date->string; # 1988-01-01T00:00:00Z |
1472
|
|
|
|
|
|
|
|
1473
|
|
|
|
|
|
|
# $date->epoch; # 567993600 |
1474
|
|
|
|
|
|
|
|
1475
|
|
|
|
|
|
|
=back |
1476
|
|
|
|
|
|
|
|
1477
|
|
|
|
|
|
|
=cut |
1478
|
|
|
|
|
|
|
|
1479
|
|
|
|
|
|
|
=head2 rfc1123 |
1480
|
|
|
|
|
|
|
|
1481
|
|
|
|
|
|
|
rfc1123() (Str) |
1482
|
|
|
|
|
|
|
|
1483
|
|
|
|
|
|
|
The rfc1123 method returns the date and time formatted as an RFC1123 string. |
1484
|
|
|
|
|
|
|
|
1485
|
|
|
|
|
|
|
I> |
1486
|
|
|
|
|
|
|
|
1487
|
|
|
|
|
|
|
=over 4 |
1488
|
|
|
|
|
|
|
|
1489
|
|
|
|
|
|
|
=item rfc1123 example 1 |
1490
|
|
|
|
|
|
|
|
1491
|
|
|
|
|
|
|
# given: synopsis; |
1492
|
|
|
|
|
|
|
|
1493
|
|
|
|
|
|
|
my $rfc1123 = $date->rfc1123; |
1494
|
|
|
|
|
|
|
|
1495
|
|
|
|
|
|
|
# Mon, 01 Feb 1988 00:00:00 GMT |
1496
|
|
|
|
|
|
|
|
1497
|
|
|
|
|
|
|
=back |
1498
|
|
|
|
|
|
|
|
1499
|
|
|
|
|
|
|
=cut |
1500
|
|
|
|
|
|
|
|
1501
|
|
|
|
|
|
|
=head2 rfc3339 |
1502
|
|
|
|
|
|
|
|
1503
|
|
|
|
|
|
|
rfc3339() (Str) |
1504
|
|
|
|
|
|
|
|
1505
|
|
|
|
|
|
|
The rfc3339 method returns the date and time formatted as an RFC3339 string. |
1506
|
|
|
|
|
|
|
|
1507
|
|
|
|
|
|
|
I> |
1508
|
|
|
|
|
|
|
|
1509
|
|
|
|
|
|
|
=over 4 |
1510
|
|
|
|
|
|
|
|
1511
|
|
|
|
|
|
|
=item rfc3339 example 1 |
1512
|
|
|
|
|
|
|
|
1513
|
|
|
|
|
|
|
# given: synopsis; |
1514
|
|
|
|
|
|
|
|
1515
|
|
|
|
|
|
|
my $rfc3339 = $date->rfc3339; |
1516
|
|
|
|
|
|
|
|
1517
|
|
|
|
|
|
|
# 1988-02-01T00:00:00Z |
1518
|
|
|
|
|
|
|
|
1519
|
|
|
|
|
|
|
=back |
1520
|
|
|
|
|
|
|
|
1521
|
|
|
|
|
|
|
=cut |
1522
|
|
|
|
|
|
|
|
1523
|
|
|
|
|
|
|
=head2 rfc7231 |
1524
|
|
|
|
|
|
|
|
1525
|
|
|
|
|
|
|
rfc7231() (Str) |
1526
|
|
|
|
|
|
|
|
1527
|
|
|
|
|
|
|
The rfc7231 method returns the date and time formatted as an RFC7231 string. |
1528
|
|
|
|
|
|
|
|
1529
|
|
|
|
|
|
|
I> |
1530
|
|
|
|
|
|
|
|
1531
|
|
|
|
|
|
|
=over 4 |
1532
|
|
|
|
|
|
|
|
1533
|
|
|
|
|
|
|
=item rfc7231 example 1 |
1534
|
|
|
|
|
|
|
|
1535
|
|
|
|
|
|
|
# given: synopsis; |
1536
|
|
|
|
|
|
|
|
1537
|
|
|
|
|
|
|
my $rfc7231 = $date->rfc7231; |
1538
|
|
|
|
|
|
|
|
1539
|
|
|
|
|
|
|
# Mon, 01 Feb 1988 00:00:00 UTC |
1540
|
|
|
|
|
|
|
|
1541
|
|
|
|
|
|
|
=back |
1542
|
|
|
|
|
|
|
|
1543
|
|
|
|
|
|
|
=cut |
1544
|
|
|
|
|
|
|
|
1545
|
|
|
|
|
|
|
=head2 rfc822 |
1546
|
|
|
|
|
|
|
|
1547
|
|
|
|
|
|
|
rfc822() (Str) |
1548
|
|
|
|
|
|
|
|
1549
|
|
|
|
|
|
|
The rfc822 method returns the date and time formatted as an RFC822 string. |
1550
|
|
|
|
|
|
|
|
1551
|
|
|
|
|
|
|
I> |
1552
|
|
|
|
|
|
|
|
1553
|
|
|
|
|
|
|
=over 4 |
1554
|
|
|
|
|
|
|
|
1555
|
|
|
|
|
|
|
=item rfc822 example 1 |
1556
|
|
|
|
|
|
|
|
1557
|
|
|
|
|
|
|
# given: synopsis; |
1558
|
|
|
|
|
|
|
|
1559
|
|
|
|
|
|
|
my $rfc822 = $date->rfc822; |
1560
|
|
|
|
|
|
|
|
1561
|
|
|
|
|
|
|
# Mon, 01 Feb 1988 00:00:00 +0000 |
1562
|
|
|
|
|
|
|
|
1563
|
|
|
|
|
|
|
=back |
1564
|
|
|
|
|
|
|
|
1565
|
|
|
|
|
|
|
=cut |
1566
|
|
|
|
|
|
|
|
1567
|
|
|
|
|
|
|
=head2 set |
1568
|
|
|
|
|
|
|
|
1569
|
|
|
|
|
|
|
set(HashRef $data) (Date) |
1570
|
|
|
|
|
|
|
|
1571
|
|
|
|
|
|
|
The set method sets the date and time attributes specified. |
1572
|
|
|
|
|
|
|
|
1573
|
|
|
|
|
|
|
I> |
1574
|
|
|
|
|
|
|
|
1575
|
|
|
|
|
|
|
=over 4 |
1576
|
|
|
|
|
|
|
|
1577
|
|
|
|
|
|
|
=item set example 1 |
1578
|
|
|
|
|
|
|
|
1579
|
|
|
|
|
|
|
# given: synopsis; |
1580
|
|
|
|
|
|
|
|
1581
|
|
|
|
|
|
|
$date = $date->set({ |
1582
|
|
|
|
|
|
|
day => 1, |
1583
|
|
|
|
|
|
|
month => 1, |
1584
|
|
|
|
|
|
|
year => 2000, |
1585
|
|
|
|
|
|
|
}); |
1586
|
|
|
|
|
|
|
|
1587
|
|
|
|
|
|
|
# $date->string; # 2000-01-01T00:00:00Z |
1588
|
|
|
|
|
|
|
|
1589
|
|
|
|
|
|
|
# $date->epoch; # 946684800 |
1590
|
|
|
|
|
|
|
|
1591
|
|
|
|
|
|
|
=back |
1592
|
|
|
|
|
|
|
|
1593
|
|
|
|
|
|
|
=over 4 |
1594
|
|
|
|
|
|
|
|
1595
|
|
|
|
|
|
|
=item set example 2 |
1596
|
|
|
|
|
|
|
|
1597
|
|
|
|
|
|
|
# given: synopsis; |
1598
|
|
|
|
|
|
|
|
1599
|
|
|
|
|
|
|
$date = $date->set({ |
1600
|
|
|
|
|
|
|
day => 1, |
1601
|
|
|
|
|
|
|
month => 12, |
1602
|
|
|
|
|
|
|
}); |
1603
|
|
|
|
|
|
|
|
1604
|
|
|
|
|
|
|
# $date->string; # 1988-12-01T00:00:00Z |
1605
|
|
|
|
|
|
|
|
1606
|
|
|
|
|
|
|
# $date->epoch; # 596937600 |
1607
|
|
|
|
|
|
|
|
1608
|
|
|
|
|
|
|
=back |
1609
|
|
|
|
|
|
|
|
1610
|
|
|
|
|
|
|
=over 4 |
1611
|
|
|
|
|
|
|
|
1612
|
|
|
|
|
|
|
=item set example 3 |
1613
|
|
|
|
|
|
|
|
1614
|
|
|
|
|
|
|
# given: synopsis; |
1615
|
|
|
|
|
|
|
|
1616
|
|
|
|
|
|
|
$date = $date->set({ |
1617
|
|
|
|
|
|
|
day => 1, |
1618
|
|
|
|
|
|
|
month => 12, |
1619
|
|
|
|
|
|
|
year => 1979, |
1620
|
|
|
|
|
|
|
}); |
1621
|
|
|
|
|
|
|
|
1622
|
|
|
|
|
|
|
# $date->string; # 1979-12-01T00:00:00Z |
1623
|
|
|
|
|
|
|
|
1624
|
|
|
|
|
|
|
# $date->epoch; # 312854400 |
1625
|
|
|
|
|
|
|
|
1626
|
|
|
|
|
|
|
=back |
1627
|
|
|
|
|
|
|
|
1628
|
|
|
|
|
|
|
=cut |
1629
|
|
|
|
|
|
|
|
1630
|
|
|
|
|
|
|
=head2 set_hms |
1631
|
|
|
|
|
|
|
|
1632
|
|
|
|
|
|
|
set_hms(Maybe[Int] $hours, Maybe[Int] $minutes, Maybe[Int] $seconds) (Date) |
1633
|
|
|
|
|
|
|
|
1634
|
|
|
|
|
|
|
The set_hms method sets the C, C, and C attributes. |
1635
|
|
|
|
|
|
|
|
1636
|
|
|
|
|
|
|
I> |
1637
|
|
|
|
|
|
|
|
1638
|
|
|
|
|
|
|
=over 4 |
1639
|
|
|
|
|
|
|
|
1640
|
|
|
|
|
|
|
=item set_hms example 1 |
1641
|
|
|
|
|
|
|
|
1642
|
|
|
|
|
|
|
# given: synopsis; |
1643
|
|
|
|
|
|
|
|
1644
|
|
|
|
|
|
|
$date = $date->set_hms(1, 0, 0); |
1645
|
|
|
|
|
|
|
|
1646
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T01:00:00Z |
1647
|
|
|
|
|
|
|
|
1648
|
|
|
|
|
|
|
# $date->epoch; # 570675600 |
1649
|
|
|
|
|
|
|
|
1650
|
|
|
|
|
|
|
=back |
1651
|
|
|
|
|
|
|
|
1652
|
|
|
|
|
|
|
=over 4 |
1653
|
|
|
|
|
|
|
|
1654
|
|
|
|
|
|
|
=item set_hms example 2 |
1655
|
|
|
|
|
|
|
|
1656
|
|
|
|
|
|
|
# given: synopsis; |
1657
|
|
|
|
|
|
|
|
1658
|
|
|
|
|
|
|
$date = $date->set_hms(undef, 30, 30); |
1659
|
|
|
|
|
|
|
|
1660
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:30:30Z |
1661
|
|
|
|
|
|
|
|
1662
|
|
|
|
|
|
|
# $date->epoch; # 570673830 |
1663
|
|
|
|
|
|
|
|
1664
|
|
|
|
|
|
|
=back |
1665
|
|
|
|
|
|
|
|
1666
|
|
|
|
|
|
|
=over 4 |
1667
|
|
|
|
|
|
|
|
1668
|
|
|
|
|
|
|
=item set_hms example 3 |
1669
|
|
|
|
|
|
|
|
1670
|
|
|
|
|
|
|
# given: synopsis; |
1671
|
|
|
|
|
|
|
|
1672
|
|
|
|
|
|
|
$date = $date->set_hms(0, 59, 59); |
1673
|
|
|
|
|
|
|
|
1674
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:59:59Z |
1675
|
|
|
|
|
|
|
|
1676
|
|
|
|
|
|
|
# $date->epoch; # 570675599 |
1677
|
|
|
|
|
|
|
|
1678
|
|
|
|
|
|
|
=back |
1679
|
|
|
|
|
|
|
|
1680
|
|
|
|
|
|
|
=cut |
1681
|
|
|
|
|
|
|
|
1682
|
|
|
|
|
|
|
=head2 set_mdy |
1683
|
|
|
|
|
|
|
|
1684
|
|
|
|
|
|
|
set_mdy(Maybe[Int] $months, Maybe[Int] $days, Maybe[Int] $years) (Date) |
1685
|
|
|
|
|
|
|
|
1686
|
|
|
|
|
|
|
The set_mdy method sets the C, C, and C attributes. |
1687
|
|
|
|
|
|
|
|
1688
|
|
|
|
|
|
|
|
1689
|
|
|
|
|
|
|
|
1690
|
|
|
|
|
|
|
|
1691
|
|
|
|
|
|
|
I> |
1692
|
|
|
|
|
|
|
|
1693
|
|
|
|
|
|
|
=over 4 |
1694
|
|
|
|
|
|
|
|
1695
|
|
|
|
|
|
|
=item set_mdy example 1 |
1696
|
|
|
|
|
|
|
|
1697
|
|
|
|
|
|
|
# given: synopsis; |
1698
|
|
|
|
|
|
|
|
1699
|
|
|
|
|
|
|
$date = $date->set_mdy(4, 30, 1990); |
1700
|
|
|
|
|
|
|
|
1701
|
|
|
|
|
|
|
# $date->string; # 1990-04-30T00:00:00Z |
1702
|
|
|
|
|
|
|
|
1703
|
|
|
|
|
|
|
# $date->epoch; # 641433600 |
1704
|
|
|
|
|
|
|
|
1705
|
|
|
|
|
|
|
=back |
1706
|
|
|
|
|
|
|
|
1707
|
|
|
|
|
|
|
=over 4 |
1708
|
|
|
|
|
|
|
|
1709
|
|
|
|
|
|
|
=item set_mdy example 2 |
1710
|
|
|
|
|
|
|
|
1711
|
|
|
|
|
|
|
# given: synopsis; |
1712
|
|
|
|
|
|
|
|
1713
|
|
|
|
|
|
|
$date = $date->set_mdy(4, 30, undef); |
1714
|
|
|
|
|
|
|
|
1715
|
|
|
|
|
|
|
# $date->string; # 1988-04-30T00:00:00Z |
1716
|
|
|
|
|
|
|
|
1717
|
|
|
|
|
|
|
# $date->epoch; # 578361600 |
1718
|
|
|
|
|
|
|
|
1719
|
|
|
|
|
|
|
=back |
1720
|
|
|
|
|
|
|
|
1721
|
|
|
|
|
|
|
=over 4 |
1722
|
|
|
|
|
|
|
|
1723
|
|
|
|
|
|
|
=item set_mdy example 3 |
1724
|
|
|
|
|
|
|
|
1725
|
|
|
|
|
|
|
# given: synopsis; |
1726
|
|
|
|
|
|
|
|
1727
|
|
|
|
|
|
|
$date = $date->set_mdy(undef, 15, undef); |
1728
|
|
|
|
|
|
|
|
1729
|
|
|
|
|
|
|
# $date->string; # 1988-02-15T00:00:00Z |
1730
|
|
|
|
|
|
|
|
1731
|
|
|
|
|
|
|
# $date->epoch; # 571881600 |
1732
|
|
|
|
|
|
|
|
1733
|
|
|
|
|
|
|
=back |
1734
|
|
|
|
|
|
|
|
1735
|
|
|
|
|
|
|
=cut |
1736
|
|
|
|
|
|
|
|
1737
|
|
|
|
|
|
|
=head2 string |
1738
|
|
|
|
|
|
|
|
1739
|
|
|
|
|
|
|
string() (Str) |
1740
|
|
|
|
|
|
|
|
1741
|
|
|
|
|
|
|
The string method returns a date and time string, and is an alias for |
1742
|
|
|
|
|
|
|
L. |
1743
|
|
|
|
|
|
|
|
1744
|
|
|
|
|
|
|
I> |
1745
|
|
|
|
|
|
|
|
1746
|
|
|
|
|
|
|
=over 4 |
1747
|
|
|
|
|
|
|
|
1748
|
|
|
|
|
|
|
=item string example 1 |
1749
|
|
|
|
|
|
|
|
1750
|
|
|
|
|
|
|
# given: synopsis; |
1751
|
|
|
|
|
|
|
|
1752
|
|
|
|
|
|
|
my $string = $date->string; |
1753
|
|
|
|
|
|
|
|
1754
|
|
|
|
|
|
|
# 1988-02-01T00:00:00Z |
1755
|
|
|
|
|
|
|
|
1756
|
|
|
|
|
|
|
=back |
1757
|
|
|
|
|
|
|
|
1758
|
|
|
|
|
|
|
=cut |
1759
|
|
|
|
|
|
|
|
1760
|
|
|
|
|
|
|
=head2 sub |
1761
|
|
|
|
|
|
|
|
1762
|
|
|
|
|
|
|
sub(HashRef $data) (Date) |
1763
|
|
|
|
|
|
|
|
1764
|
|
|
|
|
|
|
The sub method method decrements the date and time attributes specified. |
1765
|
|
|
|
|
|
|
|
1766
|
|
|
|
|
|
|
I> |
1767
|
|
|
|
|
|
|
|
1768
|
|
|
|
|
|
|
=over 4 |
1769
|
|
|
|
|
|
|
|
1770
|
|
|
|
|
|
|
=item sub example 1 |
1771
|
|
|
|
|
|
|
|
1772
|
|
|
|
|
|
|
# given: synopsis; |
1773
|
|
|
|
|
|
|
|
1774
|
|
|
|
|
|
|
$date = $date->sub({ |
1775
|
|
|
|
|
|
|
days => 1, |
1776
|
|
|
|
|
|
|
months => 1, |
1777
|
|
|
|
|
|
|
years => 1, |
1778
|
|
|
|
|
|
|
}); |
1779
|
|
|
|
|
|
|
|
1780
|
|
|
|
|
|
|
# $date->string; # 1986-12-31T07:42:06Z |
1781
|
|
|
|
|
|
|
|
1782
|
|
|
|
|
|
|
# $date->epoch; # 536398926 |
1783
|
|
|
|
|
|
|
|
1784
|
|
|
|
|
|
|
=back |
1785
|
|
|
|
|
|
|
|
1786
|
|
|
|
|
|
|
=over 4 |
1787
|
|
|
|
|
|
|
|
1788
|
|
|
|
|
|
|
=item sub example 2 |
1789
|
|
|
|
|
|
|
|
1790
|
|
|
|
|
|
|
# given: synopsis; |
1791
|
|
|
|
|
|
|
|
1792
|
|
|
|
|
|
|
$date = $date->sub({ |
1793
|
|
|
|
|
|
|
hours => 1, |
1794
|
|
|
|
|
|
|
minutes => 1, |
1795
|
|
|
|
|
|
|
seconds => 1, |
1796
|
|
|
|
|
|
|
}); |
1797
|
|
|
|
|
|
|
|
1798
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T22:58:59Z |
1799
|
|
|
|
|
|
|
|
1800
|
|
|
|
|
|
|
# $date->epoch; # 570668339 |
1801
|
|
|
|
|
|
|
|
1802
|
|
|
|
|
|
|
=back |
1803
|
|
|
|
|
|
|
|
1804
|
|
|
|
|
|
|
=cut |
1805
|
|
|
|
|
|
|
|
1806
|
|
|
|
|
|
|
=head2 sub_days |
1807
|
|
|
|
|
|
|
|
1808
|
|
|
|
|
|
|
sub_days(Int $days) (Date) |
1809
|
|
|
|
|
|
|
|
1810
|
|
|
|
|
|
|
The sub_days method decrements the C attribute. |
1811
|
|
|
|
|
|
|
|
1812
|
|
|
|
|
|
|
I> |
1813
|
|
|
|
|
|
|
|
1814
|
|
|
|
|
|
|
=over 4 |
1815
|
|
|
|
|
|
|
|
1816
|
|
|
|
|
|
|
=item sub_days example 1 |
1817
|
|
|
|
|
|
|
|
1818
|
|
|
|
|
|
|
# given: synopsis; |
1819
|
|
|
|
|
|
|
|
1820
|
|
|
|
|
|
|
$date = $date->sub_days(1); |
1821
|
|
|
|
|
|
|
|
1822
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T00:00:00Z |
1823
|
|
|
|
|
|
|
|
1824
|
|
|
|
|
|
|
# $date->epoch; # 570585600 |
1825
|
|
|
|
|
|
|
|
1826
|
|
|
|
|
|
|
=back |
1827
|
|
|
|
|
|
|
|
1828
|
|
|
|
|
|
|
=over 4 |
1829
|
|
|
|
|
|
|
|
1830
|
|
|
|
|
|
|
=item sub_days example 2 |
1831
|
|
|
|
|
|
|
|
1832
|
|
|
|
|
|
|
# given: synopsis; |
1833
|
|
|
|
|
|
|
|
1834
|
|
|
|
|
|
|
$date = $date->sub_days(32); |
1835
|
|
|
|
|
|
|
|
1836
|
|
|
|
|
|
|
# $date->string; # 1987-12-31T00:00:00Z |
1837
|
|
|
|
|
|
|
|
1838
|
|
|
|
|
|
|
# $date->epoch; # 567907200 |
1839
|
|
|
|
|
|
|
|
1840
|
|
|
|
|
|
|
=back |
1841
|
|
|
|
|
|
|
|
1842
|
|
|
|
|
|
|
=over 4 |
1843
|
|
|
|
|
|
|
|
1844
|
|
|
|
|
|
|
=item sub_days example 3 |
1845
|
|
|
|
|
|
|
|
1846
|
|
|
|
|
|
|
# given: synopsis; |
1847
|
|
|
|
|
|
|
|
1848
|
|
|
|
|
|
|
$date = $date->sub_days(-1); |
1849
|
|
|
|
|
|
|
|
1850
|
|
|
|
|
|
|
# $date->string; # 1988-02-02T00:00:00Z |
1851
|
|
|
|
|
|
|
|
1852
|
|
|
|
|
|
|
# $date->epoch; # 570758400 |
1853
|
|
|
|
|
|
|
|
1854
|
|
|
|
|
|
|
=back |
1855
|
|
|
|
|
|
|
|
1856
|
|
|
|
|
|
|
=cut |
1857
|
|
|
|
|
|
|
|
1858
|
|
|
|
|
|
|
=head2 sub_hms |
1859
|
|
|
|
|
|
|
|
1860
|
|
|
|
|
|
|
sub_hms(Maybe[Int] $hours, Maybe[Int] $minutes, Maybe[Int] $seconds) (Date) |
1861
|
|
|
|
|
|
|
|
1862
|
|
|
|
|
|
|
The sub_hms method decrements the C, C, and C attributes. |
1863
|
|
|
|
|
|
|
|
1864
|
|
|
|
|
|
|
I> |
1865
|
|
|
|
|
|
|
|
1866
|
|
|
|
|
|
|
=over 4 |
1867
|
|
|
|
|
|
|
|
1868
|
|
|
|
|
|
|
=item sub_hms example 1 |
1869
|
|
|
|
|
|
|
|
1870
|
|
|
|
|
|
|
# given: synopsis; |
1871
|
|
|
|
|
|
|
|
1872
|
|
|
|
|
|
|
$date = $date->sub_hms(1, 0, 0); |
1873
|
|
|
|
|
|
|
|
1874
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T23:00:00Z |
1875
|
|
|
|
|
|
|
|
1876
|
|
|
|
|
|
|
# $date->epoch; # 570668400 |
1877
|
|
|
|
|
|
|
|
1878
|
|
|
|
|
|
|
=back |
1879
|
|
|
|
|
|
|
|
1880
|
|
|
|
|
|
|
=over 4 |
1881
|
|
|
|
|
|
|
|
1882
|
|
|
|
|
|
|
=item sub_hms example 2 |
1883
|
|
|
|
|
|
|
|
1884
|
|
|
|
|
|
|
# given: synopsis; |
1885
|
|
|
|
|
|
|
|
1886
|
|
|
|
|
|
|
$date = $date->sub_hms(undef, 1, 1); |
1887
|
|
|
|
|
|
|
|
1888
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T23:58:59Z |
1889
|
|
|
|
|
|
|
|
1890
|
|
|
|
|
|
|
# $date->epoch; # 570671939 |
1891
|
|
|
|
|
|
|
|
1892
|
|
|
|
|
|
|
=back |
1893
|
|
|
|
|
|
|
|
1894
|
|
|
|
|
|
|
=over 4 |
1895
|
|
|
|
|
|
|
|
1896
|
|
|
|
|
|
|
=item sub_hms example 3 |
1897
|
|
|
|
|
|
|
|
1898
|
|
|
|
|
|
|
# given: synopsis; |
1899
|
|
|
|
|
|
|
|
1900
|
|
|
|
|
|
|
$date = $date->sub_hms(1, 1); |
1901
|
|
|
|
|
|
|
|
1902
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T22:59:00Z |
1903
|
|
|
|
|
|
|
|
1904
|
|
|
|
|
|
|
# $date->epoch; # 570668340 |
1905
|
|
|
|
|
|
|
|
1906
|
|
|
|
|
|
|
=back |
1907
|
|
|
|
|
|
|
|
1908
|
|
|
|
|
|
|
=cut |
1909
|
|
|
|
|
|
|
|
1910
|
|
|
|
|
|
|
=head2 sub_hours |
1911
|
|
|
|
|
|
|
|
1912
|
|
|
|
|
|
|
sub_hours(Int $hours) (Any) |
1913
|
|
|
|
|
|
|
|
1914
|
|
|
|
|
|
|
The sub_hours method decrements the C attribute. |
1915
|
|
|
|
|
|
|
|
1916
|
|
|
|
|
|
|
I> |
1917
|
|
|
|
|
|
|
|
1918
|
|
|
|
|
|
|
=over 4 |
1919
|
|
|
|
|
|
|
|
1920
|
|
|
|
|
|
|
=item sub_hours example 1 |
1921
|
|
|
|
|
|
|
|
1922
|
|
|
|
|
|
|
# given: synopsis; |
1923
|
|
|
|
|
|
|
|
1924
|
|
|
|
|
|
|
$date = $date->sub_hours(1); |
1925
|
|
|
|
|
|
|
|
1926
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T23:00:00Z |
1927
|
|
|
|
|
|
|
|
1928
|
|
|
|
|
|
|
# $date->epoch; # 570668400 |
1929
|
|
|
|
|
|
|
|
1930
|
|
|
|
|
|
|
=back |
1931
|
|
|
|
|
|
|
|
1932
|
|
|
|
|
|
|
=over 4 |
1933
|
|
|
|
|
|
|
|
1934
|
|
|
|
|
|
|
=item sub_hours example 2 |
1935
|
|
|
|
|
|
|
|
1936
|
|
|
|
|
|
|
# given: synopsis; |
1937
|
|
|
|
|
|
|
|
1938
|
|
|
|
|
|
|
$date = $date->sub_hours(25); |
1939
|
|
|
|
|
|
|
|
1940
|
|
|
|
|
|
|
# $date->string; # 1988-01-30T23:00:00Z |
1941
|
|
|
|
|
|
|
|
1942
|
|
|
|
|
|
|
# $date->epoch; # 570582000 |
1943
|
|
|
|
|
|
|
|
1944
|
|
|
|
|
|
|
=back |
1945
|
|
|
|
|
|
|
|
1946
|
|
|
|
|
|
|
=over 4 |
1947
|
|
|
|
|
|
|
|
1948
|
|
|
|
|
|
|
=item sub_hours example 3 |
1949
|
|
|
|
|
|
|
|
1950
|
|
|
|
|
|
|
# given: synopsis; |
1951
|
|
|
|
|
|
|
|
1952
|
|
|
|
|
|
|
$date = $date->sub_hours(-1); |
1953
|
|
|
|
|
|
|
|
1954
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T01:00:00Z |
1955
|
|
|
|
|
|
|
|
1956
|
|
|
|
|
|
|
# $date->epoch; # 570675600 |
1957
|
|
|
|
|
|
|
|
1958
|
|
|
|
|
|
|
=back |
1959
|
|
|
|
|
|
|
|
1960
|
|
|
|
|
|
|
=cut |
1961
|
|
|
|
|
|
|
|
1962
|
|
|
|
|
|
|
=head2 sub_mdy |
1963
|
|
|
|
|
|
|
|
1964
|
|
|
|
|
|
|
sub_mdy(Maybe[Int] $months, Maybe[Int] $days, Maybe[Int] $years) (Date) |
1965
|
|
|
|
|
|
|
|
1966
|
|
|
|
|
|
|
The sub_mdy method decrements the C, C, and C attributes. |
1967
|
|
|
|
|
|
|
|
1968
|
|
|
|
|
|
|
I> |
1969
|
|
|
|
|
|
|
|
1970
|
|
|
|
|
|
|
=over 4 |
1971
|
|
|
|
|
|
|
|
1972
|
|
|
|
|
|
|
=item sub_mdy example 1 |
1973
|
|
|
|
|
|
|
|
1974
|
|
|
|
|
|
|
# given: synopsis; |
1975
|
|
|
|
|
|
|
|
1976
|
|
|
|
|
|
|
$date = $date->sub_mdy(1, 1, 1); |
1977
|
|
|
|
|
|
|
|
1978
|
|
|
|
|
|
|
# $date->string; # 1986-12-31T07:42:06Z |
1979
|
|
|
|
|
|
|
|
1980
|
|
|
|
|
|
|
# $date->epoch; # 536398926 |
1981
|
|
|
|
|
|
|
|
1982
|
|
|
|
|
|
|
=back |
1983
|
|
|
|
|
|
|
|
1984
|
|
|
|
|
|
|
=over 4 |
1985
|
|
|
|
|
|
|
|
1986
|
|
|
|
|
|
|
=item sub_mdy example 2 |
1987
|
|
|
|
|
|
|
|
1988
|
|
|
|
|
|
|
# given: synopsis; |
1989
|
|
|
|
|
|
|
|
1990
|
|
|
|
|
|
|
$date = $date->sub_mdy(1, 1, undef); |
1991
|
|
|
|
|
|
|
|
1992
|
|
|
|
|
|
|
# $date->string; # 1987-12-31T13:30:56Z |
1993
|
|
|
|
|
|
|
|
1994
|
|
|
|
|
|
|
# $date->epoch; # 567955856 |
1995
|
|
|
|
|
|
|
|
1996
|
|
|
|
|
|
|
=back |
1997
|
|
|
|
|
|
|
|
1998
|
|
|
|
|
|
|
=over 4 |
1999
|
|
|
|
|
|
|
|
2000
|
|
|
|
|
|
|
=item sub_mdy example 3 |
2001
|
|
|
|
|
|
|
|
2002
|
|
|
|
|
|
|
# given: synopsis; |
2003
|
|
|
|
|
|
|
|
2004
|
|
|
|
|
|
|
$date = $date->sub_mdy(1, 1); |
2005
|
|
|
|
|
|
|
|
2006
|
|
|
|
|
|
|
# $date->string; # 1987-12-31T13:30:56Z |
2007
|
|
|
|
|
|
|
|
2008
|
|
|
|
|
|
|
# $date->epoch; # 567955856 |
2009
|
|
|
|
|
|
|
|
2010
|
|
|
|
|
|
|
=back |
2011
|
|
|
|
|
|
|
|
2012
|
|
|
|
|
|
|
=cut |
2013
|
|
|
|
|
|
|
|
2014
|
|
|
|
|
|
|
=head2 sub_minutes |
2015
|
|
|
|
|
|
|
|
2016
|
|
|
|
|
|
|
sub_minutes(Int $minutes) (Date) |
2017
|
|
|
|
|
|
|
|
2018
|
|
|
|
|
|
|
The sub_minutes method decrements the C attribute. |
2019
|
|
|
|
|
|
|
|
2020
|
|
|
|
|
|
|
I> |
2021
|
|
|
|
|
|
|
|
2022
|
|
|
|
|
|
|
=over 4 |
2023
|
|
|
|
|
|
|
|
2024
|
|
|
|
|
|
|
=item sub_minutes example 1 |
2025
|
|
|
|
|
|
|
|
2026
|
|
|
|
|
|
|
# given: synopsis; |
2027
|
|
|
|
|
|
|
|
2028
|
|
|
|
|
|
|
$date = $date->sub_minutes(1); |
2029
|
|
|
|
|
|
|
|
2030
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T23:59:00Z |
2031
|
|
|
|
|
|
|
|
2032
|
|
|
|
|
|
|
# $date->epoch; # 570671940 |
2033
|
|
|
|
|
|
|
|
2034
|
|
|
|
|
|
|
=back |
2035
|
|
|
|
|
|
|
|
2036
|
|
|
|
|
|
|
=over 4 |
2037
|
|
|
|
|
|
|
|
2038
|
|
|
|
|
|
|
=item sub_minutes example 2 |
2039
|
|
|
|
|
|
|
|
2040
|
|
|
|
|
|
|
# given: synopsis; |
2041
|
|
|
|
|
|
|
|
2042
|
|
|
|
|
|
|
$date = $date->sub_minutes(61); |
2043
|
|
|
|
|
|
|
|
2044
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T22:59:00Z |
2045
|
|
|
|
|
|
|
|
2046
|
|
|
|
|
|
|
# $date->epoch; # 570668340 |
2047
|
|
|
|
|
|
|
|
2048
|
|
|
|
|
|
|
=back |
2049
|
|
|
|
|
|
|
|
2050
|
|
|
|
|
|
|
=over 4 |
2051
|
|
|
|
|
|
|
|
2052
|
|
|
|
|
|
|
=item sub_minutes example 3 |
2053
|
|
|
|
|
|
|
|
2054
|
|
|
|
|
|
|
# given: synopsis; |
2055
|
|
|
|
|
|
|
|
2056
|
|
|
|
|
|
|
$date = $date->sub_minutes(-1); |
2057
|
|
|
|
|
|
|
|
2058
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:01:00Z |
2059
|
|
|
|
|
|
|
|
2060
|
|
|
|
|
|
|
# $date->epoch; # 570672060 |
2061
|
|
|
|
|
|
|
|
2062
|
|
|
|
|
|
|
=back |
2063
|
|
|
|
|
|
|
|
2064
|
|
|
|
|
|
|
=cut |
2065
|
|
|
|
|
|
|
|
2066
|
|
|
|
|
|
|
=head2 sub_months |
2067
|
|
|
|
|
|
|
|
2068
|
|
|
|
|
|
|
sub_months(Int $months) (Date) |
2069
|
|
|
|
|
|
|
|
2070
|
|
|
|
|
|
|
The sub_months method decrements the C attribute. |
2071
|
|
|
|
|
|
|
|
2072
|
|
|
|
|
|
|
I> |
2073
|
|
|
|
|
|
|
|
2074
|
|
|
|
|
|
|
=over 4 |
2075
|
|
|
|
|
|
|
|
2076
|
|
|
|
|
|
|
=item sub_months example 1 |
2077
|
|
|
|
|
|
|
|
2078
|
|
|
|
|
|
|
# given: synopsis; |
2079
|
|
|
|
|
|
|
|
2080
|
|
|
|
|
|
|
$date = $date->sub_months(1); |
2081
|
|
|
|
|
|
|
|
2082
|
|
|
|
|
|
|
# $date->string; # 1988-01-01T13:30:56Z |
2083
|
|
|
|
|
|
|
|
2084
|
|
|
|
|
|
|
# $date->epoch; # 568042256 |
2085
|
|
|
|
|
|
|
|
2086
|
|
|
|
|
|
|
=back |
2087
|
|
|
|
|
|
|
|
2088
|
|
|
|
|
|
|
=over 4 |
2089
|
|
|
|
|
|
|
|
2090
|
|
|
|
|
|
|
=item sub_months example 2 |
2091
|
|
|
|
|
|
|
|
2092
|
|
|
|
|
|
|
# given: synopsis; |
2093
|
|
|
|
|
|
|
|
2094
|
|
|
|
|
|
|
$date = $date->sub_months(13); |
2095
|
|
|
|
|
|
|
|
2096
|
|
|
|
|
|
|
# $date->string; # 1987-01-01T07:42:08Z |
2097
|
|
|
|
|
|
|
|
2098
|
|
|
|
|
|
|
# $date->epoch; # 536485328 |
2099
|
|
|
|
|
|
|
|
2100
|
|
|
|
|
|
|
=back |
2101
|
|
|
|
|
|
|
|
2102
|
|
|
|
|
|
|
=over 4 |
2103
|
|
|
|
|
|
|
|
2104
|
|
|
|
|
|
|
=item sub_months example 3 |
2105
|
|
|
|
|
|
|
|
2106
|
|
|
|
|
|
|
# given: synopsis; |
2107
|
|
|
|
|
|
|
|
2108
|
|
|
|
|
|
|
$date = $date->sub_months(-1); |
2109
|
|
|
|
|
|
|
|
2110
|
|
|
|
|
|
|
# $date->string; # 1988-03-02T10:29:04Z |
2111
|
|
|
|
|
|
|
|
2112
|
|
|
|
|
|
|
# $date->epoch; # 573301744 |
2113
|
|
|
|
|
|
|
|
2114
|
|
|
|
|
|
|
=back |
2115
|
|
|
|
|
|
|
|
2116
|
|
|
|
|
|
|
=cut |
2117
|
|
|
|
|
|
|
|
2118
|
|
|
|
|
|
|
=head2 sub_seconds |
2119
|
|
|
|
|
|
|
|
2120
|
|
|
|
|
|
|
sub_seconds(Int $seconds) (Date) |
2121
|
|
|
|
|
|
|
|
2122
|
|
|
|
|
|
|
The sub_seconds method decrements the C attribute. |
2123
|
|
|
|
|
|
|
|
2124
|
|
|
|
|
|
|
I> |
2125
|
|
|
|
|
|
|
|
2126
|
|
|
|
|
|
|
=over 4 |
2127
|
|
|
|
|
|
|
|
2128
|
|
|
|
|
|
|
=item sub_seconds example 1 |
2129
|
|
|
|
|
|
|
|
2130
|
|
|
|
|
|
|
# given: synopsis; |
2131
|
|
|
|
|
|
|
|
2132
|
|
|
|
|
|
|
$date = $date->sub_seconds(1); |
2133
|
|
|
|
|
|
|
|
2134
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T23:59:59Z |
2135
|
|
|
|
|
|
|
|
2136
|
|
|
|
|
|
|
# $date->epoch; # 570671999 |
2137
|
|
|
|
|
|
|
|
2138
|
|
|
|
|
|
|
=back |
2139
|
|
|
|
|
|
|
|
2140
|
|
|
|
|
|
|
=over 4 |
2141
|
|
|
|
|
|
|
|
2142
|
|
|
|
|
|
|
=item sub_seconds example 2 |
2143
|
|
|
|
|
|
|
|
2144
|
|
|
|
|
|
|
# given: synopsis; |
2145
|
|
|
|
|
|
|
|
2146
|
|
|
|
|
|
|
$date = $date->sub_seconds(61); |
2147
|
|
|
|
|
|
|
|
2148
|
|
|
|
|
|
|
# $date->string; # 1988-01-31T23:58:59Z |
2149
|
|
|
|
|
|
|
|
2150
|
|
|
|
|
|
|
# $date->epoch; # 570671939 |
2151
|
|
|
|
|
|
|
|
2152
|
|
|
|
|
|
|
=back |
2153
|
|
|
|
|
|
|
|
2154
|
|
|
|
|
|
|
=over 4 |
2155
|
|
|
|
|
|
|
|
2156
|
|
|
|
|
|
|
=item sub_seconds example 3 |
2157
|
|
|
|
|
|
|
|
2158
|
|
|
|
|
|
|
# given: synopsis; |
2159
|
|
|
|
|
|
|
|
2160
|
|
|
|
|
|
|
$date = $date->sub_seconds(-1); |
2161
|
|
|
|
|
|
|
|
2162
|
|
|
|
|
|
|
# $date->string; # 1988-02-01T00:00:01Z |
2163
|
|
|
|
|
|
|
|
2164
|
|
|
|
|
|
|
# $date->epoch; # 570672001 |
2165
|
|
|
|
|
|
|
|
2166
|
|
|
|
|
|
|
=back |
2167
|
|
|
|
|
|
|
|
2168
|
|
|
|
|
|
|
=cut |
2169
|
|
|
|
|
|
|
|
2170
|
|
|
|
|
|
|
=head2 sub_years |
2171
|
|
|
|
|
|
|
|
2172
|
|
|
|
|
|
|
sub_years(Int $years) (Date) |
2173
|
|
|
|
|
|
|
|
2174
|
|
|
|
|
|
|
The sub_years method decrements the C attribute. |
2175
|
|
|
|
|
|
|
|
2176
|
|
|
|
|
|
|
I> |
2177
|
|
|
|
|
|
|
|
2178
|
|
|
|
|
|
|
=over 4 |
2179
|
|
|
|
|
|
|
|
2180
|
|
|
|
|
|
|
=item sub_years example 1 |
2181
|
|
|
|
|
|
|
|
2182
|
|
|
|
|
|
|
# given: synopsis; |
2183
|
|
|
|
|
|
|
|
2184
|
|
|
|
|
|
|
$date = $date->sub_years(1); |
2185
|
|
|
|
|
|
|
|
2186
|
|
|
|
|
|
|
# $date->string; # 1987-01-31T18:11:10Z |
2187
|
|
|
|
|
|
|
|
2188
|
|
|
|
|
|
|
# $date->epoch; # 539115070 |
2189
|
|
|
|
|
|
|
|
2190
|
|
|
|
|
|
|
=back |
2191
|
|
|
|
|
|
|
|
2192
|
|
|
|
|
|
|
=over 4 |
2193
|
|
|
|
|
|
|
|
2194
|
|
|
|
|
|
|
=item sub_years example 2 |
2195
|
|
|
|
|
|
|
|
2196
|
|
|
|
|
|
|
# given: synopsis; |
2197
|
|
|
|
|
|
|
|
2198
|
|
|
|
|
|
|
$date = $date->sub_years(25); |
2199
|
|
|
|
|
|
|
|
2200
|
|
|
|
|
|
|
# $date->string; # 1963-01-31T22:39:10Z |
2201
|
|
|
|
|
|
|
|
2202
|
|
|
|
|
|
|
# $date->epoch; # -218251250 |
2203
|
|
|
|
|
|
|
|
2204
|
|
|
|
|
|
|
=back |
2205
|
|
|
|
|
|
|
|
2206
|
|
|
|
|
|
|
=over 4 |
2207
|
|
|
|
|
|
|
|
2208
|
|
|
|
|
|
|
=item sub_years example 3 |
2209
|
|
|
|
|
|
|
|
2210
|
|
|
|
|
|
|
# given: synopsis; |
2211
|
|
|
|
|
|
|
|
2212
|
|
|
|
|
|
|
$date = $date->sub_years(-1); |
2213
|
|
|
|
|
|
|
|
2214
|
|
|
|
|
|
|
# $date->string; # 1989-01-31T05:48:50Z |
2215
|
|
|
|
|
|
|
|
2216
|
|
|
|
|
|
|
# $date->epoch; # 602228930 |
2217
|
|
|
|
|
|
|
|
2218
|
|
|
|
|
|
|
=back |
2219
|
|
|
|
|
|
|
|
2220
|
|
|
|
|
|
|
=cut |
2221
|
|
|
|
|
|
|
|
2222
|
|
|
|
|
|
|
=head1 OPERATORS |
2223
|
|
|
|
|
|
|
|
2224
|
|
|
|
|
|
|
This package overloads the following operators: |
2225
|
|
|
|
|
|
|
|
2226
|
|
|
|
|
|
|
=cut |
2227
|
|
|
|
|
|
|
|
2228
|
|
|
|
|
|
|
=over 4 |
2229
|
|
|
|
|
|
|
|
2230
|
|
|
|
|
|
|
=item operation: C<(!=)> |
2231
|
|
|
|
|
|
|
|
2232
|
|
|
|
|
|
|
This package overloads the C operator. |
2233
|
|
|
|
|
|
|
|
2234
|
|
|
|
|
|
|
B |
2235
|
|
|
|
|
|
|
|
2236
|
|
|
|
|
|
|
# given: synopsis; |
2237
|
|
|
|
|
|
|
|
2238
|
|
|
|
|
|
|
my $result = $date != 570672001; |
2239
|
|
|
|
|
|
|
|
2240
|
|
|
|
|
|
|
# 1 |
2241
|
|
|
|
|
|
|
|
2242
|
|
|
|
|
|
|
=back |
2243
|
|
|
|
|
|
|
|
2244
|
|
|
|
|
|
|
=over 4 |
2245
|
|
|
|
|
|
|
|
2246
|
|
|
|
|
|
|
=item operation: C<(+)> |
2247
|
|
|
|
|
|
|
|
2248
|
|
|
|
|
|
|
This package overloads the C<+> operator. |
2249
|
|
|
|
|
|
|
|
2250
|
|
|
|
|
|
|
B |
2251
|
|
|
|
|
|
|
|
2252
|
|
|
|
|
|
|
# given: synopsis; |
2253
|
|
|
|
|
|
|
|
2254
|
|
|
|
|
|
|
my $result = $date + 0; |
2255
|
|
|
|
|
|
|
|
2256
|
|
|
|
|
|
|
# 570672000 |
2257
|
|
|
|
|
|
|
|
2258
|
|
|
|
|
|
|
=back |
2259
|
|
|
|
|
|
|
|
2260
|
|
|
|
|
|
|
=over 4 |
2261
|
|
|
|
|
|
|
|
2262
|
|
|
|
|
|
|
=item operation: C<(-)> |
2263
|
|
|
|
|
|
|
|
2264
|
|
|
|
|
|
|
This package overloads the C<-> operator. |
2265
|
|
|
|
|
|
|
|
2266
|
|
|
|
|
|
|
B |
2267
|
|
|
|
|
|
|
|
2268
|
|
|
|
|
|
|
# given: synopsis; |
2269
|
|
|
|
|
|
|
|
2270
|
|
|
|
|
|
|
my $result = $date - 0; |
2271
|
|
|
|
|
|
|
|
2272
|
|
|
|
|
|
|
# 570672000 |
2273
|
|
|
|
|
|
|
|
2274
|
|
|
|
|
|
|
=back |
2275
|
|
|
|
|
|
|
|
2276
|
|
|
|
|
|
|
=over 4 |
2277
|
|
|
|
|
|
|
|
2278
|
|
|
|
|
|
|
=item operation: C<(0+)> |
2279
|
|
|
|
|
|
|
|
2280
|
|
|
|
|
|
|
This package overloads the C<0+> operator. |
2281
|
|
|
|
|
|
|
|
2282
|
|
|
|
|
|
|
B |
2283
|
|
|
|
|
|
|
|
2284
|
|
|
|
|
|
|
# given: synopsis; |
2285
|
|
|
|
|
|
|
|
2286
|
|
|
|
|
|
|
my $result = 0 + $date; |
2287
|
|
|
|
|
|
|
|
2288
|
|
|
|
|
|
|
# 570672000 |
2289
|
|
|
|
|
|
|
|
2290
|
|
|
|
|
|
|
=back |
2291
|
|
|
|
|
|
|
|
2292
|
|
|
|
|
|
|
=over 4 |
2293
|
|
|
|
|
|
|
|
2294
|
|
|
|
|
|
|
=item operation: C<(E)> |
2295
|
|
|
|
|
|
|
|
2296
|
|
|
|
|
|
|
This package overloads the C> operator. |
2297
|
|
|
|
|
|
|
|
2298
|
|
|
|
|
|
|
B |
2299
|
|
|
|
|
|
|
|
2300
|
|
|
|
|
|
|
# given: synopsis; |
2301
|
|
|
|
|
|
|
|
2302
|
|
|
|
|
|
|
my $result = $date < 570672001; |
2303
|
|
|
|
|
|
|
|
2304
|
|
|
|
|
|
|
# 1 |
2305
|
|
|
|
|
|
|
|
2306
|
|
|
|
|
|
|
=back |
2307
|
|
|
|
|
|
|
|
2308
|
|
|
|
|
|
|
=over 4 |
2309
|
|
|
|
|
|
|
|
2310
|
|
|
|
|
|
|
=item operation: C<(E=)> |
2311
|
|
|
|
|
|
|
|
2312
|
|
|
|
|
|
|
This package overloads the C=> operator. |
2313
|
|
|
|
|
|
|
|
2314
|
|
|
|
|
|
|
B |
2315
|
|
|
|
|
|
|
|
2316
|
|
|
|
|
|
|
# given: synopsis; |
2317
|
|
|
|
|
|
|
|
2318
|
|
|
|
|
|
|
my $result = $date <= 570672000; |
2319
|
|
|
|
|
|
|
|
2320
|
|
|
|
|
|
|
# 1 |
2321
|
|
|
|
|
|
|
|
2322
|
|
|
|
|
|
|
=back |
2323
|
|
|
|
|
|
|
|
2324
|
|
|
|
|
|
|
=over 4 |
2325
|
|
|
|
|
|
|
|
2326
|
|
|
|
|
|
|
=item operation: C<(==)> |
2327
|
|
|
|
|
|
|
|
2328
|
|
|
|
|
|
|
This package overloads the C<==> operator. |
2329
|
|
|
|
|
|
|
|
2330
|
|
|
|
|
|
|
B |
2331
|
|
|
|
|
|
|
|
2332
|
|
|
|
|
|
|
# given: synopsis; |
2333
|
|
|
|
|
|
|
|
2334
|
|
|
|
|
|
|
my $result = $date == 570672000; |
2335
|
|
|
|
|
|
|
|
2336
|
|
|
|
|
|
|
# 1 |
2337
|
|
|
|
|
|
|
|
2338
|
|
|
|
|
|
|
=back |
2339
|
|
|
|
|
|
|
|
2340
|
|
|
|
|
|
|
=over 4 |
2341
|
|
|
|
|
|
|
|
2342
|
|
|
|
|
|
|
=item operation: C<(E)> |
2343
|
|
|
|
|
|
|
|
2344
|
|
|
|
|
|
|
This package overloads the C> operator. |
2345
|
|
|
|
|
|
|
|
2346
|
|
|
|
|
|
|
B |
2347
|
|
|
|
|
|
|
|
2348
|
|
|
|
|
|
|
# given: synopsis; |
2349
|
|
|
|
|
|
|
|
2350
|
|
|
|
|
|
|
my $result = $date > 570671999; |
2351
|
|
|
|
|
|
|
|
2352
|
|
|
|
|
|
|
# 1 |
2353
|
|
|
|
|
|
|
|
2354
|
|
|
|
|
|
|
=back |
2355
|
|
|
|
|
|
|
|
2356
|
|
|
|
|
|
|
=over 4 |
2357
|
|
|
|
|
|
|
|
2358
|
|
|
|
|
|
|
=item operation: C<(E=)> |
2359
|
|
|
|
|
|
|
|
2360
|
|
|
|
|
|
|
This package overloads the C=> operator. |
2361
|
|
|
|
|
|
|
|
2362
|
|
|
|
|
|
|
B |
2363
|
|
|
|
|
|
|
|
2364
|
|
|
|
|
|
|
# given: synopsis; |
2365
|
|
|
|
|
|
|
|
2366
|
|
|
|
|
|
|
my $result = $date >= 570672000; |
2367
|
|
|
|
|
|
|
|
2368
|
|
|
|
|
|
|
# 1 |
2369
|
|
|
|
|
|
|
|
2370
|
|
|
|
|
|
|
=back |
2371
|
|
|
|
|
|
|
|
2372
|
|
|
|
|
|
|
=over 4 |
2373
|
|
|
|
|
|
|
|
2374
|
|
|
|
|
|
|
=item operation: C<(eq)> |
2375
|
|
|
|
|
|
|
|
2376
|
|
|
|
|
|
|
This package overloads the C operator. |
2377
|
|
|
|
|
|
|
|
2378
|
|
|
|
|
|
|
B |
2379
|
|
|
|
|
|
|
|
2380
|
|
|
|
|
|
|
# given: synopsis; |
2381
|
|
|
|
|
|
|
|
2382
|
|
|
|
|
|
|
my $result = $date eq '570672000'; |
2383
|
|
|
|
|
|
|
|
2384
|
|
|
|
|
|
|
# 1 |
2385
|
|
|
|
|
|
|
|
2386
|
|
|
|
|
|
|
=back |
2387
|
|
|
|
|
|
|
|
2388
|
|
|
|
|
|
|
=over 4 |
2389
|
|
|
|
|
|
|
|
2390
|
|
|
|
|
|
|
=item operation: C<(ne)> |
2391
|
|
|
|
|
|
|
|
2392
|
|
|
|
|
|
|
This package overloads the C operator. |
2393
|
|
|
|
|
|
|
|
2394
|
|
|
|
|
|
|
B |
2395
|
|
|
|
|
|
|
|
2396
|
|
|
|
|
|
|
# given: synopsis; |
2397
|
|
|
|
|
|
|
|
2398
|
|
|
|
|
|
|
my $result = $date ne '560672000'; |
2399
|
|
|
|
|
|
|
|
2400
|
|
|
|
|
|
|
# 1 |
2401
|
|
|
|
|
|
|
|
2402
|
|
|
|
|
|
|
=back |
2403
|
|
|
|
|
|
|
|
2404
|
|
|
|
|
|
|
=over 4 |
2405
|
|
|
|
|
|
|
|
2406
|
|
|
|
|
|
|
=item operation: C<("")> |
2407
|
|
|
|
|
|
|
|
2408
|
|
|
|
|
|
|
This package overloads the C<""> operator. |
2409
|
|
|
|
|
|
|
|
2410
|
|
|
|
|
|
|
B |
2411
|
|
|
|
|
|
|
|
2412
|
|
|
|
|
|
|
# given: synopsis; |
2413
|
|
|
|
|
|
|
|
2414
|
|
|
|
|
|
|
my $result = "$date"; |
2415
|
|
|
|
|
|
|
|
2416
|
|
|
|
|
|
|
# "570672000" |
2417
|
|
|
|
|
|
|
|
2418
|
|
|
|
|
|
|
=back |
2419
|
|
|
|
|
|
|
|
2420
|
|
|
|
|
|
|
=over 4 |
2421
|
|
|
|
|
|
|
|
2422
|
|
|
|
|
|
|
=item operation: C<(~~)> |
2423
|
|
|
|
|
|
|
|
2424
|
|
|
|
|
|
|
This package overloads the C<~~> operator. |
2425
|
|
|
|
|
|
|
|
2426
|
|
|
|
|
|
|
B |
2427
|
|
|
|
|
|
|
|
2428
|
|
|
|
|
|
|
# given: synopsis; |
2429
|
|
|
|
|
|
|
|
2430
|
|
|
|
|
|
|
my $result = $date ~~ '570672000'; |
2431
|
|
|
|
|
|
|
|
2432
|
|
|
|
|
|
|
# 1 |
2433
|
|
|
|
|
|
|
|
2434
|
|
|
|
|
|
|
=back |
2435
|
|
|
|
|
|
|
|
2436
|
|
|
|
|
|
|
=head1 AUTHORS |
2437
|
|
|
|
|
|
|
|
2438
|
|
|
|
|
|
|
Awncorp, C |
2439
|
|
|
|
|
|
|
|
2440
|
|
|
|
|
|
|
=cut |
2441
|
|
|
|
|
|
|
|
2442
|
|
|
|
|
|
|
=head1 LICENSE |
2443
|
|
|
|
|
|
|
|
2444
|
|
|
|
|
|
|
Copyright (C) 2000, Al Newkirk. |
2445
|
|
|
|
|
|
|
|
2446
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
2447
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
2448
|
|
|
|
|
|
|
|
2449
|
|
|
|
|
|
|
=cut |