Jifty/Web/Form/Field/Date.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 39 CC 4 SCAR 19.1
CC
4
Cov
0%
classes
12.0
canonicalize_value
6.0
BEGIN
2.0
CRAP 6.8
1 use warnings;
2 use strict;
3
4 package Jifty::Web::Form::Field::Date;
5  
6 use base qw/Jifty::Web::Form::Field/;
7  
8 =head1 NAME
9  
10 Jifty::Web::Form::Field::Date - Add date pickers to your forms
11  
12 =head1 METHODS
13  
14 =head2 classes
15  
16 Output date fields with the class 'date'. If the current user's user object has
17 a C<calendar_starts_monday> method, and it returns true, the
18 C<calendar-starts-monday> class is added as well.
19  
20 =cut
21  
22 sub classes {
23 my $self = shift;
24 my $classes = join ' ', $self->SUPER::classes;
25 $classes .= ' date';
26  
27 if (my $user = Jifty->web->current_user->user_object) {
28 $classes .= ' calendar-starts-monday'
29 if $user->can('calendar_starts_monday')
30 && $user->calendar_starts_monday;
31 }
32  
33 return $classes;
34 }
35  
36 =head2 canonicalize_value
37  
38 If the value is a DateTime, return just the C<ymd> portion of it.
39  
40 =cut
41  
42 sub canonicalize_value {
43 my $self = shift;
44 my $value = $self->current_value;
45  
46 if (UNIVERSAL::isa($value, 'DateTime')) {
47 $value = $value->ymd;
48 }
49  
50 return $value;
51 }
52  
53  
54 1;