line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Processor::Field::DateTimeManip; |
2
|
|
|
|
|
|
|
$Form::Processor::Field::DateTimeManip::VERSION = '1.162360'; |
3
|
2
|
|
|
2
|
|
492
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
43
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
40
|
|
5
|
2
|
|
|
2
|
|
5
|
use base 'Form::Processor::Field'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1083
|
|
6
|
2
|
|
|
2
|
|
12
|
use DateTime::Format::DateManip; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
343
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my %date; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub validate { |
13
|
8
|
|
|
8
|
1
|
8
|
my ( $self ) = @_; |
14
|
|
|
|
|
|
|
|
15
|
8
|
50
|
|
|
|
22
|
return unless $self->SUPER::validate; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
8
|
|
|
|
|
39
|
my $dt = DateTime::Format::DateManip->parse_datetime( $self->input ); |
19
|
|
|
|
|
|
|
|
20
|
8
|
100
|
|
|
|
466673
|
unless ( $dt ) { |
21
|
2
|
|
|
|
|
26
|
$self->add_error( "Sorry, don't understand date" ); |
22
|
2
|
|
|
|
|
7
|
return; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Manip sets the time zone to the local timezone (or what's globally set) |
26
|
|
|
|
|
|
|
# which means if the zone is later changed then the time will change. |
27
|
|
|
|
|
|
|
# So change it to a floating so if validation sets the timezone the |
28
|
|
|
|
|
|
|
# time won't change. |
29
|
|
|
|
|
|
|
# ** But fails if a timezone is specified on input ** |
30
|
|
|
|
|
|
|
# so really need to parse at a later time. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# $dt->set_time_zone( 'floating' ); |
33
|
|
|
|
|
|
|
|
34
|
6
|
|
|
|
|
257
|
$self->temp( $dt ); |
35
|
|
|
|
|
|
|
|
36
|
6
|
|
|
|
|
27
|
return 1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub input_to_value { |
40
|
6
|
|
|
6
|
1
|
7
|
my $field = shift; |
41
|
6
|
|
|
|
|
17
|
return $field->value( $field->temp ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub format_value { |
45
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
return unless my $value = $self->value; |
48
|
0
|
0
|
|
|
|
|
die "Value is not a DateTime" unless $value->isa( 'DateTime' ); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $d = $value->strftime( '%a, %b %e %Y %l:%M %p %Z' ); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# The calendar javascript popup can't parse the day & hour with a leading space, |
53
|
|
|
|
|
|
|
# so remove. |
54
|
0
|
|
|
|
|
|
$d =~ s/\s(\s\d:)/$1/; |
55
|
0
|
|
|
|
|
|
$d =~ s/\s(\s\d\s\d{4})/$1/; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return ( $self->name => $d ); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# ABSTRACT: Free-form date/time input |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |