| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Random::Day::InThePast; |
|
2
|
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
235949
|
use base qw(Random::Day); |
|
|
11
|
|
|
|
|
105
|
|
|
|
11
|
|
|
|
|
5281
|
|
|
4
|
11
|
|
|
11
|
|
83
|
use strict; |
|
|
11
|
|
|
|
|
25
|
|
|
|
11
|
|
|
|
|
282
|
|
|
5
|
11
|
|
|
11
|
|
80
|
use warnings; |
|
|
11
|
|
|
|
|
27
|
|
|
|
11
|
|
|
|
|
412
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
68
|
use DateTime; |
|
|
11
|
|
|
|
|
38
|
|
|
|
11
|
|
|
|
|
1858
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.13; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
|
12
|
32
|
|
|
32
|
1
|
92604
|
my ($class, @params) = @_; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Set maximal date. |
|
15
|
32
|
|
|
|
|
72
|
my $dt_to_exists = 0; |
|
16
|
32
|
|
|
|
|
135
|
foreach (my $i = 0; $i < @params; $i++) { |
|
17
|
3
|
50
|
33
|
|
|
18
|
if ($i % 1 == 1 && $params[$i] eq 'dt_to') { |
|
18
|
0
|
|
|
|
|
0
|
$params[$i+1] = DateTime->now; |
|
19
|
0
|
|
|
|
|
0
|
$dt_to_exists = 1; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
} |
|
22
|
32
|
50
|
|
|
|
125
|
if (! $dt_to_exists) { |
|
23
|
32
|
|
|
|
|
186
|
push @params, 'dt_to', DateTime->now; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Object. |
|
27
|
32
|
|
|
|
|
11729
|
return bless $class->SUPER::new(@params), $class; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=pod |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=encoding utf8 |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 NAME |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Random::Day::InThePast - Class for random day generation in the past. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
use Random::Day::InThePast; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $obj = Random::Day::InThePast->new(%params); |
|
47
|
|
|
|
|
|
|
my $dt = $obj->get; |
|
48
|
|
|
|
|
|
|
my $dt = $obj->random; |
|
49
|
|
|
|
|
|
|
my $dt = $obj->random_day($day); |
|
50
|
|
|
|
|
|
|
my $dt = $obj->random_day_month($day, $month); |
|
51
|
|
|
|
|
|
|
my $dt = $obj->random_day_month_year($day, $month, $year); |
|
52
|
|
|
|
|
|
|
my $dt = $obj->random_month($month); |
|
53
|
|
|
|
|
|
|
my $dt = $obj->random_month_year($month, $year); |
|
54
|
|
|
|
|
|
|
my $dt = $obj->random_year($year); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 METHODS |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 C<new> |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $obj = Random::Day::InThePast->new(%params); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Constructor. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=over 8 |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item * C<day> |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Day. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Default value is undef. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * C<dt_from> |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
DateTime object from. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Default value is DateTime object for 1900 year. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * C<month> |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Month. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Default value is undef. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * C<year> |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Year. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Default value is undef. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 C<get> |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $dt = $obj->get; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Get random date defined by constructor parameters. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Returns DateTime object for date. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 C<random> |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $dt = $obj->random; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Get random date. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns DateTime object for date. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 C<random_day> |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my $dt = $obj->random_day($day); |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Get random date defined by day. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Returns DateTime object for date. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 C<random_day_month> |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $dt = $obj->random_day_month($day, $month); |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Get random date defined by day and month. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns DateTime object for date. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 C<random_day_month_year> |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
my $dt = $obj->random_day_month_year($day, $month, $year); |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Get date defined by day, month and year. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Returns DateTime object for date. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 C<random_month> |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
my $dt = $obj->random_month($month); |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Get random date defined by month. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Returns DateTime object for date. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 C<random_month_year> |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
my $dt = $obj->random_month_year($month, $year); |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Get random date defined by month and year. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Returns DateTime object for date. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 C<random_year> |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
my $dt = $obj->random_year($year); |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Get random date defined by year. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Returns DateTime object for date. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 ERRORS |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
new(): |
|
159
|
|
|
|
|
|
|
From Class::Utils::set_params(): |
|
160
|
|
|
|
|
|
|
Unknown parameter '%s'. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
random_day(): |
|
163
|
|
|
|
|
|
|
From Random::Day::random_day(): |
|
164
|
|
|
|
|
|
|
Day cannot be a zero. |
|
165
|
|
|
|
|
|
|
Day isn't number. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
random_day_month(): |
|
168
|
|
|
|
|
|
|
From Random::Day::random_day_month(): |
|
169
|
|
|
|
|
|
|
Cannot create DateTime object. |
|
170
|
|
|
|
|
|
|
Day cannot be a zero. |
|
171
|
|
|
|
|
|
|
Day isn't number. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
random_day_month_year(): |
|
174
|
|
|
|
|
|
|
From Random::Day::random_day_year(): |
|
175
|
|
|
|
|
|
|
Cannot create DateTime object. |
|
176
|
|
|
|
|
|
|
Error: %s |
|
177
|
|
|
|
|
|
|
Day cannot be a zero. |
|
178
|
|
|
|
|
|
|
Day isn't number. |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
random_month(): |
|
181
|
|
|
|
|
|
|
From Random::Day::random_momth(): |
|
182
|
|
|
|
|
|
|
Cannot create DateTime object. |
|
183
|
|
|
|
|
|
|
Error: %s |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
random_month_year(): |
|
186
|
|
|
|
|
|
|
From Random::Day::random_month_year(): |
|
187
|
|
|
|
|
|
|
Begin of expected month is lesser than minimal date. |
|
188
|
|
|
|
|
|
|
Expected year: %s |
|
189
|
|
|
|
|
|
|
Expected month: %s |
|
190
|
|
|
|
|
|
|
Minimal year: %s |
|
191
|
|
|
|
|
|
|
Minimal month: %s |
|
192
|
|
|
|
|
|
|
Cannot create DateTime object. |
|
193
|
|
|
|
|
|
|
Error: %s |
|
194
|
|
|
|
|
|
|
End of expected month is greater than maximal date. |
|
195
|
|
|
|
|
|
|
Expected year: %s |
|
196
|
|
|
|
|
|
|
Expected month: %s |
|
197
|
|
|
|
|
|
|
Maximal year: %s |
|
198
|
|
|
|
|
|
|
Maximal month: %s |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
random_year(): |
|
201
|
|
|
|
|
|
|
From Random::Day::random_year(): |
|
202
|
|
|
|
|
|
|
Year is greater than maximal year. |
|
203
|
|
|
|
|
|
|
Expected year: %s |
|
204
|
|
|
|
|
|
|
Maximal year: %s |
|
205
|
|
|
|
|
|
|
Year is lesser than minimal year. |
|
206
|
|
|
|
|
|
|
Expected year: %s |
|
207
|
|
|
|
|
|
|
Minimal year: %s |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 EXAMPLE |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=for comment filename=get_random_day_in_the_past.pl |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
use strict; |
|
214
|
|
|
|
|
|
|
use warnings; |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
use Random::Day::InThePast; |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
# Object. |
|
219
|
|
|
|
|
|
|
my $obj = Random::Day::InThePast->new; |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
# Get date. |
|
222
|
|
|
|
|
|
|
my $dt = $obj->get; |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
# Print out. |
|
225
|
|
|
|
|
|
|
print $dt->ymd."\n"; |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
# Output like: |
|
228
|
|
|
|
|
|
|
# \d\d\d\d-\d\d-\d\d |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
L<Random::Day>, |
|
233
|
|
|
|
|
|
|
L<DateTime>. |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=over |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=item L<Data::Random> |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
Perl module to generate random data |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item L<Random::Day> |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Class for random day generation. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item L<Random::Day::InTheFuture> |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Class for random day generation in the future. |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=back |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Random-Day> |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 AUTHOR |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
L<http://skim.cz> |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
© 2013-2023 Michal Josef Špaček |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
BSD 2-Clause License |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head1 VERSION |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
0.13 |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=cut |