| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Time::Duration::ja; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
64255
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
79
|
|
|
4
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
120
|
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.03'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
11
|
use base qw(Exporter); |
|
|
2
|
|
|
|
|
10
|
|
|
|
2
|
|
|
|
|
344
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw( later later_exact earlier earlier_exact |
|
9
|
|
|
|
|
|
|
ago ago_exact from_now from_now_exact |
|
10
|
|
|
|
|
|
|
duration duration_exact concise ); |
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = ('interval', @EXPORT); |
|
12
|
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
13
|
use constant DEBUG => 0; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
170
|
|
|
14
|
2
|
|
|
2
|
|
2213
|
use Time::Duration qw(); |
|
|
2
|
|
|
|
|
4522
|
|
|
|
2
|
|
|
|
|
43
|
|
|
15
|
2
|
|
|
2
|
|
1214
|
use utf8; |
|
|
2
|
|
|
|
|
45
|
|
|
|
2
|
|
|
|
|
13
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
0
|
0
|
sub concise ($) { $_[0] } |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub later { |
|
20
|
0
|
|
|
0
|
0
|
0
|
interval( $_[0], $_[1], '%s前', '%s後', '現在'); } |
|
21
|
|
|
|
|
|
|
sub later_exact { |
|
22
|
0
|
|
|
0
|
0
|
0
|
interval_exact($_[0], $_[1], '%s前', '%s後', '現在'); } |
|
23
|
|
|
|
|
|
|
sub earlier { |
|
24
|
5
|
|
|
5
|
0
|
18
|
interval( $_[0], $_[1], '%s後', '%s前', '現在'); } |
|
25
|
|
|
|
|
|
|
sub earlier_exact { |
|
26
|
0
|
|
|
0
|
0
|
0
|
interval_exact($_[0], $_[1], '%s後', '%s前', '現在'); } |
|
27
|
|
|
|
|
|
|
|
|
28
|
5
|
|
|
5
|
0
|
12
|
sub ago { &earlier } |
|
29
|
0
|
|
|
0
|
0
|
0
|
sub ago_exact { &earlier_exact } |
|
30
|
0
|
|
|
0
|
0
|
0
|
sub from_now { &later } |
|
31
|
0
|
|
|
0
|
0
|
0
|
sub from_now_exact { &later_exact } |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub duration_exact { |
|
34
|
0
|
|
|
0
|
0
|
0
|
my $span = $_[0]; # interval in seconds |
|
35
|
0
|
|
0
|
|
|
0
|
my $precision = int($_[1] || 0) || 2; # precision (default: 2) |
|
36
|
0
|
0
|
|
|
|
0
|
return '0秒' unless $span; |
|
37
|
0
|
|
|
|
|
0
|
_render('%s', |
|
38
|
|
|
|
|
|
|
Time::Duration::_separate(abs $span)); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub duration { |
|
42
|
2
|
|
|
2
|
0
|
10
|
my $span = $_[0]; # interval in seconds |
|
43
|
2
|
|
50
|
|
|
14
|
my $precision = int($_[1] || 0) || 2; # precision (default: 2) |
|
44
|
2
|
50
|
|
|
|
5
|
return '0秒' unless $span; |
|
45
|
2
|
|
|
|
|
10
|
_render('%s', |
|
46
|
|
|
|
|
|
|
Time::Duration::_approximate($precision, |
|
47
|
|
|
|
|
|
|
Time::Duration::_separate(abs $span))); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub interval_exact { |
|
51
|
0
|
|
|
0
|
0
|
0
|
my $span = $_[0]; # interval, in seconds |
|
52
|
|
|
|
|
|
|
# precision is ignored |
|
53
|
0
|
0
|
|
|
|
0
|
my $direction = ($span <= -1) ? $_[2] # what a neg number gets |
|
|
|
0
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
: ($span >= 1) ? $_[3] # what a pos number gets |
|
55
|
|
|
|
|
|
|
: return $_[4]; # what zero gets |
|
56
|
0
|
|
|
|
|
0
|
_render($direction, |
|
57
|
|
|
|
|
|
|
Time::Duration::_separate($span)); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub interval { |
|
61
|
5
|
|
|
5
|
0
|
7
|
my $span = $_[0]; # interval, in seconds |
|
62
|
5
|
|
100
|
|
|
34
|
my $precision = int($_[1] || 0) || 2; # precision (default: 2) |
|
63
|
5
|
50
|
|
|
|
12
|
my $direction = ($span <= -1) ? $_[2] # what a neg number gets |
|
|
|
100
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
: ($span >= 1) ? $_[3] # what a pos number gets |
|
65
|
|
|
|
|
|
|
: return $_[4]; # what zero gets |
|
66
|
5
|
|
|
|
|
13
|
_render($direction, |
|
67
|
|
|
|
|
|
|
Time::Duration::_approximate($precision, |
|
68
|
|
|
|
|
|
|
Time::Duration::_separate($span))); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my %en2ja = ( |
|
72
|
|
|
|
|
|
|
second => '秒', |
|
73
|
|
|
|
|
|
|
minute => '分', |
|
74
|
|
|
|
|
|
|
hour => '時間', |
|
75
|
|
|
|
|
|
|
day => '日', |
|
76
|
|
|
|
|
|
|
year => '年', |
|
77
|
|
|
|
|
|
|
); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _render { |
|
80
|
|
|
|
|
|
|
# Make it into English |
|
81
|
7
|
|
|
7
|
|
260
|
my $direction = shift @_; |
|
82
|
35
|
100
|
|
|
|
115
|
my @wheel = map |
|
83
|
|
|
|
|
|
|
{ |
|
84
|
7
|
|
|
|
|
10
|
( $_->[1] == 0) ? () # zero wheels |
|
85
|
|
|
|
|
|
|
: $_->[1] . $en2ja{ $_->[0] } |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
@_; |
|
88
|
2
|
|
|
2
|
|
3898
|
use Data::Dumper; |
|
|
2
|
|
|
|
|
42503
|
|
|
|
2
|
|
|
|
|
325
|
|
|
89
|
|
|
|
|
|
|
# warn Dumper $direction, \@wheel; |
|
90
|
|
|
|
|
|
|
|
|
91
|
7
|
50
|
|
|
|
16
|
return "現在" unless @wheel; # sanity |
|
92
|
7
|
|
|
|
|
50
|
return sprintf($direction, join '', @wheel); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
|
96
|
|
|
|
|
|
|
__END__ |