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             package Rose::HTML::Form::Field::DateTime::EndDate;
2              
3 2     2   988 use strict;
  2         5  
  2         87  
4              
5 2     2   11 use base 'Rose::HTML::Form::Field::DateTime';
  2         4  
  2         379  
6              
7             our $VERSION = '0.606';
8              
9             sub inflate_value
10             {
11 32     32 1 59 my($self) = shift;
12              
13 32         101 my $date = $self->SUPER::inflate_value(@_);
14              
15 32 100       132 return $date unless(UNIVERSAL::isa($date, 'DateTime'));
16              
17 2     2   18 no warnings;
  2         6  
  2         277  
18             # Pin to the last second of the day if no time is set
19 27 100       88 $date->set(hour => 23, minute => 59, second => 59, nanosecond => 999999999)
20             unless($self->input_value_filtered =~ /\d:\d|[ap]\.?m/i);
21              
22 27         5688 return $date;
23             }
24              
25             1;
26              
27             __END__
28              
29             =head1 NAME
30              
31             Rose::HTML::Form::Field::DateTime::EndDate - Text field for an "end date" in a date range.
32              
33             =head1 SYNOPSIS
34              
35             $field =
36             Rose::HTML::Form::Field::DateTime::EndDate->new(
37             label => 'Date',
38             name => 'date',
39             default => '12/31/2002');
40              
41             print $field->internal_value; # "2002-12-31T23:59:59"
42             print $field->output_value; # "2002-12-31 11:59:59 PM"
43              
44             $field->input_value('blah');
45              
46             # "Could not parse date: blah"
47             $field->validate or warn $field->error;
48              
49             $field->input_value('4/30/1980 5:30 p.m.');
50              
51             $dt = $field->internal_value; # DateTime object
52              
53             print $dt->hour; # 17
54             print $dt->day_name; # Wednesday
55              
56             print $field->html;
57             ...
58              
59             =head1 DESCRIPTION
60              
61             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.
62              
63             =head1 AUTHOR
64              
65             John C. Siracusa (siracusa@gmail.com)
66              
67             =head1 LICENSE
68              
69             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.