| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
require 5.004; |
|
2
|
|
|
|
|
|
|
package Time::ProseClock; |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
19634
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
47
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
63
|
|
|
6
|
|
|
|
|
|
|
$VERSION = 1.02; |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Carp(); |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
706
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new |
|
11
|
|
|
|
|
|
|
{ |
|
12
|
1
|
|
|
1
|
0
|
12
|
my $self = shift; |
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
33
|
|
|
9
|
$self = bless {}, ref($self) || $self; |
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
5
|
$self->_set_phrases(); |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
2
|
return $self; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub display |
|
22
|
|
|
|
|
|
|
{ |
|
23
|
1
|
|
|
1
|
0
|
727
|
my $self = shift; |
|
24
|
1
|
|
33
|
|
|
7
|
my $time_arg = shift || time; |
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
50
|
|
|
|
8
|
Carp::croak(qq[invalid time format [$time_arg]]) |
|
27
|
|
|
|
|
|
|
if $time_arg !~ /^\d+$/; |
|
28
|
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
4
|
$self->_get_time($time_arg); |
|
30
|
1
|
|
|
|
|
4
|
$self->_set_minute(); |
|
31
|
1
|
|
|
|
|
3
|
$self->_set_hour(); |
|
32
|
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
5
|
my $txt = qq[$self->{'min_phrase'} $self->{'mul_phrase'} $self->{'hour_phrase'}]; |
|
34
|
1
|
|
|
|
|
3
|
$txt =~ s| {2,}| |; # there may not be a mul_phrase |
|
35
|
1
|
|
|
|
|
4
|
return $txt; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#------------------------------------------------------------------------------# |
|
40
|
|
|
|
|
|
|
# private methods # |
|
41
|
|
|
|
|
|
|
#------------------------------------------------------------------------------# |
|
42
|
|
|
|
|
|
|
sub _set_hour |
|
43
|
|
|
|
|
|
|
{ |
|
44
|
2
|
|
|
2
|
|
237
|
my $self = shift; |
|
45
|
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
4
|
my $hours = $self->{'time'}->{'hours'}; |
|
47
|
|
|
|
|
|
|
|
|
48
|
2
|
50
|
|
|
|
8
|
if ($self->{'mul'} >= 35) |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
2
|
50
|
|
|
|
4
|
($hours == 23) ? $hours = 0 : $hours++; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
2
|
|
|
|
|
6
|
$self->{'hour_phrase'} = $self->{'HourPhrases'}->[$hours]; |
|
54
|
|
|
|
|
|
|
|
|
55
|
2
|
50
|
33
|
|
|
7
|
if (($hours == 0) && ($self->{'time'}->{'minutes'} < 3)) |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
0
|
|
|
|
|
0
|
$self->{'mul_phrase'} = ''; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
3
|
return; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _set_minute |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
2
|
|
|
2
|
|
477
|
my $self = shift; |
|
66
|
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
3
|
my $minutes = $self->{'time'}->{'minutes'}; |
|
68
|
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
6
|
my $remainder = $minutes % 5; |
|
70
|
|
|
|
|
|
|
|
|
71
|
2
|
|
|
|
|
4
|
$self->{'mul'} = $minutes - $remainder; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# switch frame of reference |
|
74
|
2
|
50
|
|
|
|
6
|
$self->{'mul'} += 5 if $remainder >= 3; |
|
75
|
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
5
|
$self->{'min_phrase'} = $self->{'MinutePhrases'}->[$remainder]; |
|
77
|
|
|
|
|
|
|
|
|
78
|
2
|
50
|
|
|
|
9
|
if (exists($self->{'Multiples'}->{$self->{'mul'}})) |
|
79
|
|
|
|
|
|
|
{ |
|
80
|
2
|
|
|
|
|
6
|
$self->{'mul_phrase'} = $self->{'Multiples'}->{$self->{'mul'}}; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
else |
|
83
|
|
|
|
|
|
|
{ |
|
84
|
0
|
|
|
|
|
0
|
$self->{'mul_phrase'} = ''; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
2
|
|
|
|
|
4
|
return; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# We only need hours and minutes; finer granularity would be unprosaic. |
|
91
|
|
|
|
|
|
|
sub _get_time |
|
92
|
|
|
|
|
|
|
{ |
|
93
|
2
|
|
|
2
|
|
13
|
my $self = shift; |
|
94
|
2
|
|
|
|
|
3
|
my $time_arg = shift; |
|
95
|
2
|
|
|
|
|
182
|
@{$self->{'time'}}{qw(minutes hours)} = (localtime($time_arg))[1, 2]; |
|
|
2
|
|
|
|
|
9
|
|
|
96
|
2
|
|
|
|
|
6
|
return; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub _set_phrases |
|
100
|
|
|
|
|
|
|
{ |
|
101
|
2
|
|
|
2
|
|
225
|
my $self = shift; |
|
102
|
|
|
|
|
|
|
|
|
103
|
2
|
|
|
|
|
12
|
$self->{'MinutePhrases'} = |
|
104
|
|
|
|
|
|
|
[ |
|
105
|
|
|
|
|
|
|
'exactly', |
|
106
|
|
|
|
|
|
|
'just after', |
|
107
|
|
|
|
|
|
|
'a little after', |
|
108
|
|
|
|
|
|
|
'coming up to', |
|
109
|
|
|
|
|
|
|
'almost', |
|
110
|
|
|
|
|
|
|
]; |
|
111
|
|
|
|
|
|
|
|
|
112
|
2
|
|
|
|
|
26
|
$self->{'Multiples'} = |
|
113
|
|
|
|
|
|
|
{ |
|
114
|
|
|
|
|
|
|
0 => '', |
|
115
|
|
|
|
|
|
|
5 => 'five past', |
|
116
|
|
|
|
|
|
|
10 => 'ten past', |
|
117
|
|
|
|
|
|
|
15 => 'quarter past', |
|
118
|
|
|
|
|
|
|
20 => 'twenty past', |
|
119
|
|
|
|
|
|
|
25 => 'twenty-five past', |
|
120
|
|
|
|
|
|
|
30 => 'half past', |
|
121
|
|
|
|
|
|
|
35 => 'twenty-five to', |
|
122
|
|
|
|
|
|
|
40 => 'twenty to', |
|
123
|
|
|
|
|
|
|
45 => 'quarter to', |
|
124
|
|
|
|
|
|
|
50 => 'ten to', |
|
125
|
|
|
|
|
|
|
55 => 'five to', |
|
126
|
|
|
|
|
|
|
}; |
|
127
|
|
|
|
|
|
|
|
|
128
|
2
|
|
|
|
|
12
|
$self->{'HourPhrases'} = |
|
129
|
|
|
|
|
|
|
[ |
|
130
|
|
|
|
|
|
|
'midnight', |
|
131
|
|
|
|
|
|
|
'one in the morning', |
|
132
|
|
|
|
|
|
|
'two in the morning', |
|
133
|
|
|
|
|
|
|
'three in the morning', |
|
134
|
|
|
|
|
|
|
'four in the morning', |
|
135
|
|
|
|
|
|
|
'five in the morning', |
|
136
|
|
|
|
|
|
|
'six in the morning', |
|
137
|
|
|
|
|
|
|
'seven in the morning', |
|
138
|
|
|
|
|
|
|
'eight in the morning', |
|
139
|
|
|
|
|
|
|
'nine in the morning', |
|
140
|
|
|
|
|
|
|
'ten in the morning', |
|
141
|
|
|
|
|
|
|
'eleven in the morning', |
|
142
|
|
|
|
|
|
|
'noon', |
|
143
|
|
|
|
|
|
|
'one in the afternoon', |
|
144
|
|
|
|
|
|
|
'two in the afternoon', |
|
145
|
|
|
|
|
|
|
'three in the afternoon', |
|
146
|
|
|
|
|
|
|
'four in the afternoon', |
|
147
|
|
|
|
|
|
|
'five in the afternoon', |
|
148
|
|
|
|
|
|
|
'six at night', |
|
149
|
|
|
|
|
|
|
'seven at night', |
|
150
|
|
|
|
|
|
|
'eight at night', |
|
151
|
|
|
|
|
|
|
'nine at night', |
|
152
|
|
|
|
|
|
|
'ten at night', |
|
153
|
|
|
|
|
|
|
'eleven at night', |
|
154
|
|
|
|
|
|
|
]; |
|
155
|
|
|
|
|
|
|
|
|
156
|
2
|
|
|
|
|
6
|
return; |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
1; |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
__END__ |