line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Mechanize::FormFiller::Value::Random::Date; |
2
|
1
|
|
|
2
|
|
252
|
use base 'WWW::Mechanize::FormFiller::Value'; |
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
3
|
|
3
|
1
|
|
|
2
|
|
1
|
use Carp qw(croak); |
|
1
|
|
|
|
|
115
|
|
|
1
|
|
|
|
|
62766
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
2
|
|
3
|
use vars qw( $VERSION ); |
|
1
|
|
|
|
|
35
|
|
|
1
|
|
|
|
|
495
|
|
6
|
1
|
|
|
2
|
|
4
|
use POSIX; |
|
1
|
|
|
|
|
1868
|
|
|
2
|
|
|
|
|
13
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.13'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
2
|
|
|
3
|
1
|
4
|
my ($class,$name,%args) = @_; |
11
|
2
|
|
|
|
|
60
|
my $self = $class->SUPER::new($name); |
12
|
2
|
0
|
|
|
|
911
|
%args = (string => '%Y%m%d') unless scalar (keys %args); |
13
|
2
|
|
100
|
|
|
11554
|
$args{min} ||= undef; |
14
|
2
|
|
100
|
|
|
11
|
$args{max} ||= undef; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
157
|
$self->{args} = \%args; |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
1
|
$self; |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub value { |
22
|
1
|
|
|
5
|
1
|
18
|
my ($self,$input) = @_; |
23
|
1
|
|
|
|
|
11
|
my $min = $self->{args}->{min}; |
24
|
1
|
|
|
|
|
2
|
my $max = $self->{args}->{max}; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
89
|
for ($min, $max) { |
27
|
|
|
|
|
|
|
$_ = strftime $self->{args}->{string}, gmtime() |
28
|
3
|
0
|
|
|
|
14
|
if $_ eq "now"; |
29
|
|
|
|
|
|
|
}; |
30
|
3
|
0
|
66
|
|
|
15
|
croak "Minimum timestamp is greater or equal maximum timestamp" |
|
|
|
66
|
|
|
|
|
31
|
|
|
|
|
|
|
if defined $max and defined $min and $max le $min; |
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
11
|
my $result; |
34
|
|
|
|
|
|
|
RANDOM: { |
35
|
3
|
|
|
|
|
12
|
my $timestamp = rand(0x7FFFFFFF); |
|
3
|
|
|
|
|
10
|
|
36
|
|
|
|
|
|
|
#warn $self->{args}->{string}; |
37
|
|
|
|
|
|
|
#warn gmtime($timestamp); |
38
|
3
|
|
|
|
|
11
|
$result = strftime $self->{args}->{string}, gmtime($timestamp); |
39
|
3
|
50
|
100
|
|
|
10
|
redo RANDOM if defined $min and $result lt $min; |
40
|
5
|
100
|
66
|
|
|
9
|
redo RANDOM if defined $max and $result ge $max; |
41
|
|
|
|
|
|
|
}; |
42
|
5
|
|
|
|
|
12
|
$result; |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |