line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Random::Day; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
237821
|
use strict; |
|
11
|
|
|
|
|
98
|
|
|
11
|
|
|
|
|
348
|
|
4
|
11
|
|
|
11
|
|
63
|
use warnings; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
318
|
|
5
|
|
|
|
|
|
|
|
6
|
11
|
|
|
11
|
|
5376
|
use Class::Utils qw(set_params); |
|
11
|
|
|
|
|
64204
|
|
|
11
|
|
|
|
|
215
|
|
7
|
11
|
|
|
11
|
|
11508
|
use DateTime; |
|
11
|
|
|
|
|
6366679
|
|
|
11
|
|
|
|
|
681
|
|
8
|
11
|
|
|
11
|
|
7552
|
use DateTime::Event::Random; |
|
11
|
|
|
|
|
588952
|
|
|
11
|
|
|
|
|
492
|
|
9
|
11
|
|
|
11
|
|
6740
|
use DateTime::Event::Recurrence; |
|
11
|
|
|
|
|
75588
|
|
|
11
|
|
|
|
|
451
|
|
10
|
11
|
|
|
11
|
|
113
|
use English; |
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
129
|
|
11
|
11
|
|
|
11
|
|
5911
|
use Error::Pure qw(err); |
|
11
|
|
|
|
|
42
|
|
|
11
|
|
|
|
|
13287
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 0.12; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Constructor. |
16
|
|
|
|
|
|
|
sub new { |
17
|
26
|
|
|
26
|
1
|
67623
|
my ($class, @params) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Create object. |
20
|
26
|
|
|
|
|
89
|
my $self = bless {}, $class; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Day. |
23
|
26
|
|
|
|
|
102
|
$self->{'day'} = undef; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# DateTime object from. |
26
|
26
|
|
|
|
|
141
|
$self->{'dt_from'} = DateTime->new( |
27
|
|
|
|
|
|
|
'year' => 1900, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# DateTime object to. |
31
|
26
|
|
|
|
|
10465
|
$self->{'dt_to'} = DateTime->new( |
32
|
|
|
|
|
|
|
'year' => 2050, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Month. |
36
|
26
|
|
|
|
|
7587
|
$self->{'month'} = undef; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Year. |
39
|
26
|
|
|
|
|
64
|
$self->{'year'} = undef; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Process parameters. |
42
|
26
|
|
|
|
|
108
|
set_params($self, @params); |
43
|
|
|
|
|
|
|
|
44
|
24
|
|
|
|
|
307
|
return $self; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Get DateTime object with random date. |
48
|
|
|
|
|
|
|
sub get { |
49
|
1
|
|
|
1
|
1
|
6
|
my ($self, $date) = @_; |
50
|
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
5
|
if ($self->{'year'}) { |
52
|
0
|
0
|
|
|
|
0
|
if ($self->{'month'}) { |
53
|
0
|
0
|
|
|
|
0
|
if ($self->{'day'}) { |
54
|
|
|
|
|
|
|
$date = $self->random_day_month_year( |
55
|
|
|
|
|
|
|
$self->{'day'}, |
56
|
|
|
|
|
|
|
$self->{'month'}, |
57
|
0
|
|
|
|
|
0
|
$self->{'year'}, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
} else { |
60
|
|
|
|
|
|
|
$date = $self->random_month_year( |
61
|
|
|
|
|
|
|
$self->{'month'}, |
62
|
0
|
|
|
|
|
0
|
$self->{'year'}, |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} else { |
66
|
0
|
0
|
|
|
|
0
|
if ($self->{'day'}) { |
67
|
|
|
|
|
|
|
$date = $self->random_day_year( |
68
|
|
|
|
|
|
|
$self->{'day'}, |
69
|
0
|
|
|
|
|
0
|
$self->{'year'}, |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
} else { |
72
|
0
|
|
|
|
|
0
|
$date = $self->random_year($self->{'year'}); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} else { |
76
|
1
|
50
|
|
|
|
10
|
if ($self->{'month'}) { |
77
|
0
|
0
|
|
|
|
0
|
if ($self->{'day'}) { |
78
|
|
|
|
|
|
|
$date = $self->random_day_month( |
79
|
|
|
|
|
|
|
$self->{'day'}, |
80
|
0
|
|
|
|
|
0
|
$self->{'month'}, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} else { |
83
|
0
|
|
|
|
|
0
|
$date = $self->random_month($self->{'month'}); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} else { |
86
|
1
|
50
|
|
|
|
4
|
if ($self->{'day'}) { |
87
|
0
|
|
|
|
|
0
|
$date = $self->random_day($self->{'day'}); |
88
|
|
|
|
|
|
|
} else { |
89
|
1
|
|
|
|
|
3
|
$date = $self->random; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
7508
|
return $date; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Random DateTime object for day. |
98
|
|
|
|
|
|
|
sub random { |
99
|
7
|
|
|
7
|
1
|
19
|
my $self = shift; |
100
|
|
|
|
|
|
|
|
101
|
7
|
|
|
|
|
97
|
my $daily = DateTime::Event::Recurrence->daily; |
102
|
|
|
|
|
|
|
|
103
|
7
|
|
|
|
|
3235
|
return $daily->next($self->_range); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Random DateTime object for day defined by day. |
107
|
|
|
|
|
|
|
sub random_day { |
108
|
6
|
|
|
6
|
1
|
42
|
my ($self, $day) = @_; |
109
|
|
|
|
|
|
|
|
110
|
6
|
|
|
|
|
19
|
$self->_check_day($day); |
111
|
2
|
|
|
|
|
18
|
my $monthly_day = DateTime::Event::Recurrence->monthly( |
112
|
|
|
|
|
|
|
'days' => $day, |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
|
115
|
2
|
|
|
|
|
1006
|
return $monthly_day->next($self->random); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# Random DateTime object for day defined by day and month. |
119
|
|
|
|
|
|
|
sub random_day_month { |
120
|
5
|
|
|
5
|
1
|
36
|
my ($self, $day, $month) = @_; |
121
|
|
|
|
|
|
|
|
122
|
5
|
|
|
|
|
14
|
$self->_check_day($day); |
123
|
3
|
|
|
|
|
19
|
my $yearly_day_month = DateTime::Event::Recurrence->yearly( |
124
|
|
|
|
|
|
|
'days' => $day, |
125
|
|
|
|
|
|
|
'months' => $month, |
126
|
|
|
|
|
|
|
); |
127
|
3
|
|
|
|
|
1314
|
my $dt = $yearly_day_month->next($self->random); |
128
|
3
|
100
|
|
|
|
24670
|
if (! defined $dt) { |
129
|
2
|
|
|
|
|
12
|
err 'Cannot create DateTime object.'; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
1
|
|
|
|
|
15
|
return $dt; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# DateTime object for day defined by day, month and year. |
136
|
|
|
|
|
|
|
sub random_day_month_year { |
137
|
5
|
|
|
5
|
1
|
31
|
my ($self, $day, $month, $year) = @_; |
138
|
|
|
|
|
|
|
|
139
|
5
|
|
|
|
|
16
|
$self->_check_day($day); |
140
|
2
|
|
|
|
|
3
|
my $dt = eval { |
141
|
2
|
|
|
|
|
8
|
DateTime->new( |
142
|
|
|
|
|
|
|
'day' => $day, |
143
|
|
|
|
|
|
|
'month' => $month, |
144
|
|
|
|
|
|
|
'year' => $year, |
145
|
|
|
|
|
|
|
); |
146
|
|
|
|
|
|
|
}; |
147
|
2
|
100
|
|
|
|
1141
|
if ($EVAL_ERROR) { |
148
|
1
|
|
|
|
|
2039
|
err 'Cannot create DateTime object.', |
149
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
1
|
|
|
|
|
4
|
return $dt; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# Random DateTime object for day defined by month. |
156
|
|
|
|
|
|
|
sub random_month { |
157
|
2
|
|
|
2
|
1
|
11
|
my ($self, $month) = @_; |
158
|
|
|
|
|
|
|
|
159
|
2
|
|
|
|
|
8
|
my $random_day = $self->_range; |
160
|
|
|
|
|
|
|
|
161
|
2
|
|
|
|
|
10240
|
return $self->random_month_year($month, $random_day->year); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
# Random DateTime object for day defined by month and year. |
165
|
|
|
|
|
|
|
sub random_month_year { |
166
|
4
|
|
|
4
|
1
|
29
|
my ($self, $month, $year) = @_; |
167
|
|
|
|
|
|
|
|
168
|
4
|
|
|
|
|
8
|
my $after = eval { |
169
|
4
|
|
|
|
|
18
|
DateTime->new( |
170
|
|
|
|
|
|
|
'day' => 1, |
171
|
|
|
|
|
|
|
'month' => $month, |
172
|
|
|
|
|
|
|
'year' => $year, |
173
|
|
|
|
|
|
|
); |
174
|
|
|
|
|
|
|
}; |
175
|
4
|
100
|
|
|
|
2605
|
if ($EVAL_ERROR) { |
176
|
2
|
|
|
|
|
4266
|
err 'Cannot create DateTime object.', |
177
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
2
|
|
|
|
|
10
|
my $before = $after->clone; |
181
|
2
|
|
|
|
|
31
|
$before->add(months => 1)->subtract(days => 1); |
182
|
|
|
|
|
|
|
|
183
|
2
|
|
|
|
|
5303
|
my $daily = DateTime::Event::Recurrence->daily; |
184
|
2
|
|
|
|
|
1306
|
return $daily->next(DateTime::Event::Random->datetime( |
185
|
|
|
|
|
|
|
'after' => $after, |
186
|
|
|
|
|
|
|
'before' => $before, |
187
|
|
|
|
|
|
|
)); |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# Random DateTime object for day defined by year. |
191
|
|
|
|
|
|
|
sub random_year { |
192
|
1
|
|
|
1
|
1
|
7
|
my ($self, $year) = @_; |
193
|
|
|
|
|
|
|
|
194
|
1
|
|
|
|
|
12
|
my $daily = DateTime::Event::Recurrence->daily; |
195
|
|
|
|
|
|
|
|
196
|
1
|
|
|
|
|
779
|
return $daily->next(DateTime::Event::Random->datetime( |
197
|
|
|
|
|
|
|
'after' => DateTime->new( |
198
|
|
|
|
|
|
|
'day' => 1, |
199
|
|
|
|
|
|
|
'month' => 1, |
200
|
|
|
|
|
|
|
'year' => $year, |
201
|
|
|
|
|
|
|
), |
202
|
|
|
|
|
|
|
'before' => DateTime->new( |
203
|
|
|
|
|
|
|
'day' => 31, |
204
|
|
|
|
|
|
|
'month' => 12, |
205
|
|
|
|
|
|
|
'year' => $year, |
206
|
|
|
|
|
|
|
), |
207
|
|
|
|
|
|
|
)); |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
# Check day. |
211
|
|
|
|
|
|
|
sub _check_day { |
212
|
16
|
|
|
16
|
|
46
|
my ($self, $day) = @_; |
213
|
|
|
|
|
|
|
|
214
|
16
|
100
|
|
|
|
150
|
if ($day !~ m/^\d+$/ms) { |
215
|
6
|
|
|
|
|
31
|
err "Day isn't positive number."; |
216
|
|
|
|
|
|
|
} |
217
|
10
|
100
|
|
|
|
34
|
if ($day == 0) { |
218
|
3
|
|
|
|
|
21
|
err 'Day cannot be a zero.'; |
219
|
|
|
|
|
|
|
} |
220
|
7
|
|
|
|
|
11
|
return; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
# Random date in range. |
224
|
|
|
|
|
|
|
sub _range { |
225
|
9
|
|
|
9
|
|
28
|
my $self = shift; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
return DateTime::Event::Random->datetime( |
228
|
|
|
|
|
|
|
'after' => $self->{'dt_from'}, |
229
|
9
|
|
|
|
|
90
|
'before' => $self->{'dt_to'}, |
230
|
|
|
|
|
|
|
); |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
1; |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
__END__ |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=pod |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=encoding utf8 |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 NAME |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Random::Day - Class for random day generation. |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 SYNOPSIS |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
use Random::Day; |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
my $obj = Random::Day->new(%params); |
250
|
|
|
|
|
|
|
my $dt = $obj->get; |
251
|
|
|
|
|
|
|
my $dt = $obj->random; |
252
|
|
|
|
|
|
|
my $dt = $obj->random_day($day); |
253
|
|
|
|
|
|
|
my $dt = $obj->random_day_month($day, $month); |
254
|
|
|
|
|
|
|
my $dt = $obj->random_day_month_year($day, $month, $year); |
255
|
|
|
|
|
|
|
my $dt = $obj->random_month($month); |
256
|
|
|
|
|
|
|
my $dt = $obj->random_month_year($month, $year); |
257
|
|
|
|
|
|
|
my $dt = $obj->random_year($year); |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head1 METHODS |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head2 C<new> |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
my $obj = Random::Day->new(%params); |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Constructor. |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=over 8 |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=item * C<day> |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
Day. |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
Default value is undef. |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=item * C<dt_from> |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
DateTime object from. |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
Default value is DateTime object for 1900 year. |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=item * C<dt_to> |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
DateTime object to. |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
Default value is DateTime object for 2050 year. |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=item * C<month> |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
Month. |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
Default value is undef. |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=item * C<year> |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
Year. |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
Default value is undef. |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=back |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=head2 C<get> |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
my $dt = $obj->get; |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
Get random date defined by constructor parameters. |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
Returns DateTime object for date. |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=head2 C<random> |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
my $dt = $obj->random; |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
Get random date. |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
Returns DateTime object for date. |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=head2 C<random_day> |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
my $dt = $obj->random_day($day); |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
Get random date defined by day. |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
Returns DateTime object for date. |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=head2 C<random_day_month> |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
my $dt = $obj->random_day_month($day, $month); |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
Get random date defined by day and month. |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
Returns DateTime object for date. |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
=head2 C<random_day_month_year> |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
my $dt = $obj->random_day_month_year($day, $month, $year); |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
Get date defined by day, month and year. |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
Returns DateTime object for date. |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=head2 C<random_month> |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
my $dt = $obj->random_month($month); |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
Get random date defined by month. |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
Returns DateTime object for date. |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
=head2 C<random_month_year> |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
my $dt = $obj->random_month_year($month, $year); |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
Get random date defined by month and year. |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
Returns DateTime object for date. |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
=head2 C<random_year> |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
my $dt = $obj->random_year($year); |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
Get random date defined by year. |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
Returns DateTime object for date. |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
=head1 ERRORS |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
new(): |
368
|
|
|
|
|
|
|
From Class::Utils::set_params(): |
369
|
|
|
|
|
|
|
Unknown parameter '%s'. |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
random_day(): |
372
|
|
|
|
|
|
|
Day cannot be a zero. |
373
|
|
|
|
|
|
|
Day isn't number. |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
random_day_month(): |
376
|
|
|
|
|
|
|
Cannot create DateTime object. |
377
|
|
|
|
|
|
|
Day cannot be a zero. |
378
|
|
|
|
|
|
|
Day isn't number. |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
random_day_month_year(): |
381
|
|
|
|
|
|
|
Cannot create DateTime object. |
382
|
|
|
|
|
|
|
Error: %s |
383
|
|
|
|
|
|
|
Day cannot be a zero. |
384
|
|
|
|
|
|
|
Day isn't number. |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
random_month(): |
387
|
|
|
|
|
|
|
Cannot create DateTime object. |
388
|
|
|
|
|
|
|
Error: %s |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
random_month_year(): |
391
|
|
|
|
|
|
|
Cannot create DateTime object. |
392
|
|
|
|
|
|
|
Error: %s |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=head1 EXAMPLE |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
=for comment filename=get_random_day.pl |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
use strict; |
399
|
|
|
|
|
|
|
use warnings; |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
use Random::Day; |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
# Object. |
404
|
|
|
|
|
|
|
my $obj = Random::Day->new; |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
# Get date. |
407
|
|
|
|
|
|
|
my $dt = $obj->get; |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
# Print out. |
410
|
|
|
|
|
|
|
print $dt->ymd."\n"; |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
# Output like: |
413
|
|
|
|
|
|
|
# \d\d\d\d-\d\d-\d\d |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
L<Class::Utils>, |
418
|
|
|
|
|
|
|
L<DateTime>, |
419
|
|
|
|
|
|
|
L<DateTime::Event::Random>, |
420
|
|
|
|
|
|
|
L<DateTime::Event::Recurrence>, |
421
|
|
|
|
|
|
|
L<English>, |
422
|
|
|
|
|
|
|
L<Error::Pure>. |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
=head1 SEE ALSO |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
=over |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
=item L<Data::Random> |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
Perl module to generate random data |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
=back |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
=head1 REPOSITORY |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Random-Day> |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
=head1 AUTHOR |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
L<http://skim.cz> |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
© 2013-2023 Michal Josef Špaček |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
BSD 2-Clause License |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
=head1 VERSION |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
0.12 |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
=cut |