| blib/lib/HTML/Tag/DATETIME.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % | 
| statement | 31 | 31 | 100.0 | 
| branch | 6 | 10 | 60.0 | 
| condition | 1 | 3 | 33.3 | 
| subroutine | 7 | 7 | 100.0 | 
| pod | 0 | 1 | 0.0 | 
| total | 45 | 52 | 86.5 | 
| line | stmt | bran | cond | sub | pod | time | code | 
|---|---|---|---|---|---|---|---|
| 1 | package HTML::Tag::DATETIME; | ||||||
| 2 | |||||||
| 3 | 1 | 1 | 6 | use strict; | |||
| 1 | 2 | ||||||
| 1 | 35 | ||||||
| 4 | 1 | 1 | 5 | use warnings; | |||
| 1 | 3 | ||||||
| 1 | 33 | ||||||
| 5 | |||||||
| 6 | 1 | 1 | 5 | use Class::AutoAccess; | |||
| 1 | 1 | ||||||
| 1 | 30 | ||||||
| 7 | 1 | 1 | 4 | use base qw(Class::AutoAccess HTML::Tag); | |||
| 1 | 1 | ||||||
| 1 | 149 | ||||||
| 8 | |||||||
| 9 | our $VERSION = '1.02'; | ||||||
| 10 | |||||||
| 11 | BEGIN { | ||||||
| 12 | 1 | 1 | 241 | our $class_def = { | |||
| 13 | element => 'DATETIME', | ||||||
| 14 | tag => 'SELECT', | ||||||
| 15 | js => 'html_tag_datetime_loader.js', | ||||||
| 16 | value => '', | ||||||
| 17 | } | ||||||
| 18 | } | ||||||
| 19 | |||||||
| 20 | sub html { | ||||||
| 21 | 6 | 6 | 0 | 166 | my $self = shift; | ||
| 22 | 6 | 63 | my $name = $self->name; | ||||
| 23 | 6 | 78 | my $value = $self->value; | ||||
| 24 | |||||||
| 25 | 6 | 48 | $value = &_normalize_value($value); | ||||
| 26 | 6 | 33 | 30 | my $js = $HTML::Tag::DATETIME::js || $self->js; | |||
| 27 | 6 | 125 | my $ret =<<""; | ||||
| 28 | |||||||
| 29 | |||||||
| 30 | |||||||
| 31 | |||||||
| 32 | 6 | 66 | return $ret; | ||||
| 33 | } | ||||||
| 34 | |||||||
| 35 | sub _normalize_value { | ||||||
| 36 | 6 | 6 | 8 | my $value = shift; | |||
| 37 | 6 | 100 | 16 | if ($value eq 'now') { | |||
| 38 | 1 | 21 | my ($min,$hour,$day,$month,$year) = (localtime())[1..5]; | ||||
| 39 | 1 | 3 | $year += 1900; | ||||
| 40 | 1 | 1 | $month++; | ||||
| 41 | 1 | 50 | 5 | $min = "0$min" if length($min) == 1; | |||
| 42 | 1 | 50 | 6 | $hour = "0$hour" if length($hour) == 1; | |||
| 43 | 1 | 50 | 3 | $month = "0$month" if length($month) == 1; | |||
| 44 | 1 | 50 | 5 | $day = "0$day" if length($day) == 1; | |||
| 45 | 1 | 5 | $value = "$year-$month-$day $hour:$min:00"; | ||||
| 46 | } | ||||||
| 47 | 6 | 12 | return $value; | ||||
| 48 | } | ||||||
| 49 | |||||||
| 50 | |||||||
| 51 | 1; | ||||||
| 52 | |||||||
| 53 | # vim: set ts=2: |