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