File Coverage

blib/lib/Rose/HTML/Form/Field/DateTime/EndDate.pm
Criterion Covered Total %
statement 14 14 100.0
branch 4 4 100.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 23 23 100.0


line stmt bran cond sub pod time code
1              
2             use strict;
3 2     2   792  
  2         4  
  2         55  
4             use base 'Rose::HTML::Form::Field::DateTime';
5 2     2   16  
  2         5  
  2         301  
6             our $VERSION = '0.606';
7              
8             {
9             my($self) = shift;
10              
11 32     32 1 47 my $date = $self->SUPER::inflate_value(@_);
12              
13 32         84 return $date unless(UNIVERSAL::isa($date, 'DateTime'));
14              
15 32 100       116 no warnings;
16             # Pin to the last second of the day if no time is set
17 2     2   13 $date->set(hour => 23, minute => 59, second => 59, nanosecond => 999999999)
  2         3  
  2         215  
18             unless($self->input_value_filtered =~ /\d:\d|[ap]\.?m/i);
19 27 100       72  
20             return $date;
21             }
22 27         4660  
23             1;
24              
25              
26             =head1 NAME
27              
28             Rose::HTML::Form::Field::DateTime::EndDate - Text field for an "end date" in a date range.
29              
30             =head1 SYNOPSIS
31              
32             $field =
33             Rose::HTML::Form::Field::DateTime::EndDate->new(
34             label => 'Date',
35             name => 'date',
36             default => '12/31/2002');
37              
38             print $field->internal_value; # "2002-12-31T23:59:59"
39             print $field->output_value; # "2002-12-31 11:59:59 PM"
40              
41             $field->input_value('blah');
42              
43             # "Could not parse date: blah"
44             $field->validate or warn $field->error;
45              
46             $field->input_value('4/30/1980 5:30 p.m.');
47              
48             $dt = $field->internal_value; # DateTime object
49              
50             print $dt->hour; # 17
51             print $dt->day_name; # Wednesday
52              
53             print $field->html;
54             ...
55              
56             =head1 DESCRIPTION
57              
58             L<Rose::HTML::Form::Field::DateTime::EndDate> is a subclass of L<Rose::HTML::Form::Field::DateTime> that pins the time to the very last nanosecond of the specified date (i.e., 23:59:59.999999999) if the time is left unspecified.
59              
60             =head1 AUTHOR
61              
62             John C. Siracusa (siracusa@gmail.com)
63              
64             =head1 LICENSE
65              
66             Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.