| 1 | package Acme::Time::Baby; | ||||||||||||
| 2 | |||||||||||||
| 3 | 17 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 17 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 17 | ▶ | no warnings 'syntax'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 17 | ▶ | use vars qw /$VERSION/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 17 | our $VERSION = '2010090301'; | |||||||||||
| 10 | |||||||||||||
| 11 | 17 | my %languages = ( | |||||||||||
| 12 | 'en' => {numbers => [qw /one two three four five six seven | ||||||||||||
| 13 | eight nine ten eleven twelve/], | ||||||||||||
| 14 | format => "The big hand is on the %s " . | ||||||||||||
| 15 | "and the little hand is on the %s"}, | ||||||||||||
| 16 | |||||||||||||
| 17 | 'br' => {numbers => [split ' ' => | ||||||||||||
| 18 | qq /um dois tr\x{EA}s quatro cinco seis | ||||||||||||
| 19 | sete oito nove dez onze doze/], | ||||||||||||
| 20 | format => "O ponteiro grande est\x{E1} no %s " . | ||||||||||||
| 21 | "e o ponteiro pequeno est\x{E1} no %s"}, | ||||||||||||
| 22 | |||||||||||||
| 23 | 'ceb' => {numbers => [qw /usa duha tulo upat lima unom pito | ||||||||||||
| 24 | walo siyam napulo/, | ||||||||||||
| 25 | "napulo'g usa", "napulo'g duha"], | ||||||||||||
| 26 | format => "Ang dako nga kamut naa sa %s " . | ||||||||||||
| 27 | "ang gamay nga kamut naa sa %s"}, | ||||||||||||
| 28 | |||||||||||||
| 29 | 'de' => {numbers => [split ' ' => | ||||||||||||
| 30 | qq /Eins Zwei Drei Vier F\x{FC}nf Sechs Sieben | ||||||||||||
| 31 | Acht Neun Zehn Elf Zw\x{F6}lf/], | ||||||||||||
| 32 | format => "Der gro\x{DF}e Zeiger ist auf der %s " . | ||||||||||||
| 33 | "und der kleine Zeiger ist auf der %s"}, | ||||||||||||
| 34 | |||||||||||||
| 35 | 'de_ch' => {numbers => [split ' ' => | ||||||||||||
| 36 | qq /eis zw\x{F6}i dr\x{FC} vieri f\x{F6}ifi | ||||||||||||
| 37 | s\x{E4}chsi sibni | ||||||||||||
| 38 | achti n\x{FC}ni z\x{E4}ni elfi | ||||||||||||
| 39 | zw\x{F6}lfi/], | ||||||||||||
| 40 | format => "De gross zeiger isch uf em %s " . | ||||||||||||
| 41 | "und de chlii zeiger isch uf em %s"}, | ||||||||||||
| 42 | |||||||||||||
| 43 | 'du' => {numbers => [qw /een twee drie vier vijf zes zeven | ||||||||||||
| 44 | acht negen tien elf twaalf/], | ||||||||||||
| 45 | format => "De grote wijzer is op de %s " . | ||||||||||||
| 46 | "en de kleine wijzer is op de %s"}, | ||||||||||||
| 47 | |||||||||||||
| 48 | 'es' => {numbers => [qw /uno dos tres cuatro cinco seis siete | ||||||||||||
| 49 | ocho nueve diez once doce/], | ||||||||||||
| 50 | format => "La manecilla grande est\x{E1} sobre el %s y " . | ||||||||||||
| 51 | "la manecilla peque\x{F1}a est\x{E1} sobre el %s"}, | ||||||||||||
| 52 | |||||||||||||
| 53 | 'fr' => {numbers => [qw /un deux trois quatre cinq six sept | ||||||||||||
| 54 | huit neuf dix onze douze/], | ||||||||||||
| 55 | format => "La grande aiguille est sur le %s " . | ||||||||||||
| 56 | "et la petite aiguille est sur le %s"}, | ||||||||||||
| 57 | |||||||||||||
| 58 | 'hr' => {numbers => [split ' ' => | ||||||||||||
| 59 | qq /jedan dva tri \x{010d}etiri pet \x{0161}est | ||||||||||||
| 60 | sedam osam devet deset jedanaest dvanaest/], | ||||||||||||
| 61 | format => "Velika kazaljka pokazuje %s " . | ||||||||||||
| 62 | "a mala kazaljka pokazuje %s"}, | ||||||||||||
| 63 | |||||||||||||
| 64 | 'it' => {numbers => ['a una', 'e due', 'e tre', 'e quattro', | ||||||||||||
| 65 | 'e cinque', 'e sei', 'e sette', | ||||||||||||
| 66 | 'e otto', 'e nove', 'e dieci', | ||||||||||||
| 67 | 'e undici', 'e dodici'], | ||||||||||||
| 68 | format => "La lancetta lunga e' sull%s " . | ||||||||||||
| 69 | "e quella corta e' sull%s"}, | ||||||||||||
| 70 | |||||||||||||
| 71 | 'no' => {numbers => [split ' ' => | ||||||||||||
| 72 | qq /en to tre fire fem seks syv | ||||||||||||
| 73 | \x{E5}tte ni ti elleve tolv/], | ||||||||||||
| 74 | format => "Den store viseren er p\x{E5} %s " . | ||||||||||||
| 75 | "og den lille viseren er p\x{E5} %s"}, | ||||||||||||
| 76 | |||||||||||||
| 77 | 'se' => {numbers => [split ' ' => | ||||||||||||
| 78 | qq /ett tv\x{E5} tre fyra fem sex sju | ||||||||||||
| 79 | \x{E5}tta nio tio elva tolv/], | ||||||||||||
| 80 | format => "Den stora visaren \x{E4}r p\x{E5} %s " . | ||||||||||||
| 81 | "och den lilla visaren \x{E4}r p\x{E5} %s"}, | ||||||||||||
| 82 | |||||||||||||
| 83 | 'swedish chef' | ||||||||||||
| 84 | => {numbers => [qw /one tvu three ffuoor ffeefe six | ||||||||||||
| 85 | sefen eight nine ten elefen tvelfe/], | ||||||||||||
| 86 | format => "Zee beeg hund is un zee %s und zee little " . | ||||||||||||
| 87 | "hund is un zee %s. Bork, bork, bork!"}, | ||||||||||||
| 88 | |||||||||||||
| 89 | 'warez' => {numbers => [qw {()nE TW0 7HR3e f0uR f|ve 5ix | ||||||||||||
| 90 | ZE\/3n E|6hT n1nE TeN 3L3v3gn 7wELv3}], | ||||||||||||
| 91 | format => 'T|-|3 bIG h4|\||) Yz 0n thE %s ' . | ||||||||||||
| 92 | 'and 7|-|3 lIttlE |-|aND |S 0|\| Th3 %s'}, | ||||||||||||
| 93 | |||||||||||||
| 94 | ); | ||||||||||||
| 95 | |||||||||||||
| 96 | 17 | my @numbers = @{$languages {en} {numbers}}; | |||||||||||
| 97 | 17 | my $format = $languages {en} {format}; | |||||||||||
| 98 | |||||||||||||
| 99 | 16 | ▶ | sub import { | ||||||||||
|
Subroutine
import: called CC=8 SCAR=21.2
| |||||||||||||
| 100 | 16 | my $class = shift; | |||||||||||
| 101 | 16 | my $pkg = __PACKAGE__; | |||||||||||
| 102 | 16 | my $caller = caller; | |||||||||||
| 103 | |||||||||||||
| 104 | 16 | my %args = @_; | |||||||||||
| 105 | |||||||||||||
| 106 | 16 | ▶ | if ($args {language}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 107 | 13 | ▶ | if (exists $languages {$args {language}}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 108 | 13 | @numbers = @{$languages {$args {language}} {numbers}}; | |||||||||||
| 109 | 13 | $format = $languages {$args {language}} {format}; | |||||||||||
| 110 | } | ||||||||||||
| 111 | else { | ||||||||||||
| 112 | 0 | ▶ | warn "There is no support for language `$args{language}'\n" if $^W; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 113 | } | ||||||||||||
| 114 | } | ||||||||||||
| 115 | |||||||||||||
| 116 | 16 | ▶ | @numbers = @{$args {numbers}} if exists $args {numbers}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 117 | 16 | ▶ | $format = $args {format} if exists $args {format}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 118 | |||||||||||||
| 119 | 0 | ▶ | if (@numbers < 12) {die "You didn't pass in twelve numbers.\n";} | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 120 | |||||||||||||
| 121 | 17 | ▶ | no strict 'refs'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 122 | 15 | *{$caller . '::babytime'} = \&{__PACKAGE__ . '::babytime'} | |||||||||||
| 123 | 16 | ▶ | unless $args {noimport}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 124 | } | ||||||||||||
| 125 | |||||||||||||
| 126 | 21600 | ▶ | sub babytime { | ||||||||||
|
Subroutine
babytime: called CC=7 SCAR=19.8
Pod
undocumented
| |||||||||||||
| 127 | 21600 | my ($hours, $minutes); | |||||||||||
| 128 | 21600 | ▶ | if (@_) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 129 | 21600 | ▶ | ($hours, $minutes) = $_ [0] =~ /^(\d+):(\d+)$/ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 130 | or die "$_[0] is not of the form hh:mm\n"; | ||||||||||||
| 131 | } | ||||||||||||
| 132 | else { | ||||||||||||
| 133 | 0 | ($hours, $minutes) = (localtime) [2, 1]; | |||||||||||
| 134 | } | ||||||||||||
| 135 | |||||||||||||
| 136 | 21600 | ▶ | $hours ++ if $minutes > 30; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 137 | |||||||||||||
| 138 | # Turn $hours into 1 .. 12 format. | ||||||||||||
| 139 | 21600 | $hours %= 12; | |||||||||||
| 140 | 21600 | ▶ | $hours ||= 12; | ||||||||||
|
Condition100%2/2
$hours ||= 12
MC/DC100%1/1
$hours ||= 12
$hours
Truth table100%2/2
A
A= $hours
| |||||||||||||
| 141 | |||||||||||||
| 142 | 21600 | ▶ | die "There are just 60 minutes in an hour\n" if $minutes >= 60; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 143 | |||||||||||||
| 144 | # Round minutes to nearest 5 minute. | ||||||||||||
| 145 | 21600 | $minutes = sprintf "%.0f" => $minutes / 5; | |||||||||||
| 146 | 21600 | ▶ | $minutes ||= 12; | ||||||||||
|
Condition100%2/2
$minutes ||= 12
MC/DC100%1/1
$minutes ||= 12
$minutes
Truth table100%2/2
A
A= $minutes
| |||||||||||||
| 147 | |||||||||||||
| 148 | 21600 | sprintf $format => @numbers [$minutes - 1, $hours - 1]; | |||||||||||
| 149 | } | ||||||||||||
| 150 | |||||||||||||
| 151 | 17 | 1; | |||||||||||
| 152 | |||||||||||||
| 153 | __END__ | ||||||||||||