line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormHandler::Field::Date::Infinite; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
13589
|
use Moose; |
|
2
|
|
|
|
|
734433
|
|
|
2
|
|
|
|
|
14
|
|
4
|
|
|
|
|
|
|
extends 'HTML::FormHandler::Field::Date'; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10691
|
use version; our $VERSION = qv('0.1.2'); |
|
2
|
|
|
|
|
2397
|
|
|
2
|
|
|
|
|
9
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'deflate_method' => ( is => "ro", |
9
|
|
|
|
|
|
|
default => sub { \&my_date_deflate } ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub my_date_deflate { |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
0
|
|
|
my ( $self, $value ) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
0
|
|
|
|
|
if ($value->is_infinite) { |
16
|
|
|
|
|
|
|
## plain stringification |
17
|
0
|
0
|
|
|
|
|
if ( $value->isa("DateTime::Infinite::Future")) { |
18
|
0
|
|
|
|
|
|
return "infinity"; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
else { |
21
|
0
|
|
|
|
|
|
return "-infinity"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
0
|
|
|
|
|
|
return HTML::FormHandler::Field::Date::date_deflate($self,$value); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
override 'validate' => sub { |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $self = shift; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
if ( $self->value and $self->value =~ /^(-?inf)(?:init[ey])?$/i) { |
35
|
|
|
|
|
|
|
return $self->_set_value( lc $1 eq "-inf" ? DateTime::Infinite::Past->new : DateTime::Infinite::Future->new ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
|
|
|
|
|
|
return super(); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
}; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
44
|
2
|
|
|
2
|
|
1184
|
use namespace::autoclean; |
|
2
|
|
|
|
|
1956
|
|
|
2
|
|
|
|
|
7
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
47
|
|
|
|
|
|
|
__END__ |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 NAME |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
HTML::FormHandler::Field::Date::Infinite - Subclass of |
52
|
|
|
|
|
|
|
HTML::FormHandler::Field::Date that supports DateTime::Infinite. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Valid input strings are: |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
-inf |
57
|
|
|
|
|
|
|
inf |
58
|
|
|
|
|
|
|
-infinit[ey] |
59
|
|
|
|
|
|
|
infinit[ey] |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 VERSION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This document describes HTML::FormHandler::Field::Date::Infinite version 0.0.1 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SYNOPSIS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
## In your form: |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
has_field my_date => ( |
71
|
|
|
|
|
|
|
type => 'Date::Infinite', |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
## when rendered it will now display -inf / inf and accepts variations |
75
|
|
|
|
|
|
|
## of "infinite" as input and will update the model as |
76
|
|
|
|
|
|
|
## apropriate. Otherwise works as a normal HF::Field::Date |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 DESCRIPTION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
A slight alteration of the original FH::Field::Date to make it also |
81
|
|
|
|
|
|
|
accept infinite input for dates (DateTime supports this). |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This module does not introduce new errors, if any, they originate from |
86
|
|
|
|
|
|
|
in HTML::FormHandler::Field::Date or above. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
HTML::FormHandler::Field::Date::Infinite requires no configuration files or environment variables. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
DateTime |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
None reported. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
No bugs have been reported. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
106
|
|
|
|
|
|
|
C<bug-html-formhandler-field-date-infinite@rt.cpan.org>, or through the web interface at |
107
|
|
|
|
|
|
|
L<http://rt.cpan.org>. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 AUTHOR |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Torbjørn Lindahl C<< <torbjorn.lindahl@gmail.com> >> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 LICENCE AND COPYRIGHT |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Copyright (c) 2013, Torbjørn Lindahl C<< <torbjorn.lindahl@gmail.com> >>. All rights reserved. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
118
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. See L<perlartistic>. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
124
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
125
|
|
|
|
|
|
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
126
|
|
|
|
|
|
|
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER |
127
|
|
|
|
|
|
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
128
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
129
|
|
|
|
|
|
|
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
130
|
|
|
|
|
|
|
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
131
|
|
|
|
|
|
|
NECESSARY SERVICING, REPAIR, OR CORRECTION. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
134
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
135
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE |
136
|
|
|
|
|
|
|
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
137
|
|
|
|
|
|
|
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
138
|
|
|
|
|
|
|
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
139
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
140
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
141
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
142
|
|
|
|
|
|
|
SUCH DAMAGES. |