| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
6
|
|
|
6
|
|
39853
|
use 5.010; |
|
|
6
|
|
|
|
|
15
|
|
|
|
6
|
|
|
|
|
212
|
|
|
2
|
6
|
|
|
6
|
|
25
|
use strict; |
|
|
6
|
|
|
|
|
8
|
|
|
|
6
|
|
|
|
|
162
|
|
|
3
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
|
6
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
134
|
|
|
4
|
6
|
|
|
6
|
|
3208
|
use utf8; |
|
|
6
|
|
|
|
|
44
|
|
|
|
6
|
|
|
|
|
22
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package DateTimeX::Format::Ago; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
|
9
|
6
|
|
|
6
|
|
354
|
$DateTimeX::Format::Ago::AUTHORITY = 'cpan:TOBYINK'; |
|
10
|
6
|
|
|
|
|
92
|
$DateTimeX::Format::Ago::VERSION = '0.005'; |
|
11
|
|
|
|
|
|
|
} |
|
12
|
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
29
|
use Carp qw(); |
|
|
6
|
|
|
|
|
10
|
|
|
|
6
|
|
|
|
|
89
|
|
|
14
|
6
|
|
|
6
|
|
5464
|
use DateTime; |
|
|
6
|
|
|
|
|
740840
|
|
|
|
6
|
|
|
|
|
230
|
|
|
15
|
6
|
|
|
6
|
|
55
|
use Scalar::Util qw(blessed); |
|
|
6
|
|
|
|
|
7
|
|
|
|
6
|
|
|
|
|
2610
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our %__; |
|
18
|
|
|
|
|
|
|
BEGIN { |
|
19
|
6
|
|
|
6
|
|
66
|
$__{ENG} = $__{EN} = { |
|
20
|
|
|
|
|
|
|
future => "in the future", |
|
21
|
|
|
|
|
|
|
recent => "just now", |
|
22
|
|
|
|
|
|
|
years => ["%d years ago", "a year ago"], |
|
23
|
|
|
|
|
|
|
months => ["%d months ago", "a month ago"], |
|
24
|
|
|
|
|
|
|
weeks => ["%d weeks ago", "a week ago"], |
|
25
|
|
|
|
|
|
|
days => ["%d days ago", "a day ago"], |
|
26
|
|
|
|
|
|
|
hours => ["%d hours ago", "an hour ago"], |
|
27
|
|
|
|
|
|
|
minutes => ["%d minutes ago", "a minute ago"], |
|
28
|
|
|
|
|
|
|
}; |
|
29
|
6
|
|
|
|
|
36
|
$__{GER} = $__{DEU} = $__{DE} = { |
|
30
|
|
|
|
|
|
|
future => "in der Zukunft", |
|
31
|
|
|
|
|
|
|
recent => "gerade jetzt", |
|
32
|
|
|
|
|
|
|
years => ["vor %d Jahren", "vor einem Jahr"], |
|
33
|
|
|
|
|
|
|
months => ["vor %d Monaten", "vor einem Monat"], |
|
34
|
|
|
|
|
|
|
weeks => ["vor %d Wochen", "vor einer Woche"], |
|
35
|
|
|
|
|
|
|
days => ["vor %d Tagen", "vor einem Tag"], |
|
36
|
|
|
|
|
|
|
hours => ["vor %d Stunden", "vor einer Stunde"], |
|
37
|
|
|
|
|
|
|
minutes => ["vor %d Minuten", "vor einer Minute"], |
|
38
|
|
|
|
|
|
|
}; |
|
39
|
6
|
|
|
|
|
52
|
$__{FRE} = $__{FRA} = $__{FR} = { |
|
40
|
|
|
|
|
|
|
future => "à l'avenir", |
|
41
|
|
|
|
|
|
|
recent => "récemment", |
|
42
|
|
|
|
|
|
|
years => ["il y a %d ans", "il y a un an"], |
|
43
|
|
|
|
|
|
|
months => ["il y a %d mois", "il y a un mois"], |
|
44
|
|
|
|
|
|
|
weeks => ["il y a %d semaines", "il y a une semaine"], |
|
45
|
|
|
|
|
|
|
days => ["il y a %d jours", "il y a un jour"], |
|
46
|
|
|
|
|
|
|
hours => ["il y a %d heures", "il y a une heure"], |
|
47
|
|
|
|
|
|
|
minutes => ["il y a %d minutes", "il y a une minute"], |
|
48
|
|
|
|
|
|
|
}; |
|
49
|
6
|
|
|
|
|
37
|
$__{KOR} = $__{KO} = { |
|
50
|
|
|
|
|
|
|
future => "잠시 후", |
|
51
|
|
|
|
|
|
|
recent => "방금 전", |
|
52
|
|
|
|
|
|
|
years => ["%d년 전", "작년"], |
|
53
|
|
|
|
|
|
|
months => ["%d개월 전", "지난달"], |
|
54
|
|
|
|
|
|
|
weeks => ["%d주 전", "지난주"], |
|
55
|
|
|
|
|
|
|
days => ["%d일 전", "어제"], |
|
56
|
|
|
|
|
|
|
hours => ["%d시간 전", "1시간 전"], |
|
57
|
|
|
|
|
|
|
minutes => ["%d분 전", "1분 전"] |
|
58
|
|
|
|
|
|
|
}; #"# fix for Scite syntax highlighter |
|
59
|
6
|
|
|
|
|
90
|
$__{SPA} = $__{ES} = { |
|
60
|
|
|
|
|
|
|
future => "en el futuro", |
|
61
|
|
|
|
|
|
|
recent => "ahora mismo", |
|
62
|
|
|
|
|
|
|
years => ["hace %d años", "hace un año"], |
|
63
|
|
|
|
|
|
|
months => ["hace %d meses", "hace un mes"], |
|
64
|
|
|
|
|
|
|
weeks => ["hace %d semanas", "hace una semana"], |
|
65
|
|
|
|
|
|
|
days => ["hace %d días", "hace un día"], |
|
66
|
|
|
|
|
|
|
hours => ["hace %d horas", "hace una hora"], |
|
67
|
|
|
|
|
|
|
minutes => ["hace %d minutos", "hace un minuto"], |
|
68
|
|
|
|
|
|
|
}; |
|
69
|
6
|
|
|
|
|
40
|
$__{POR} = $__{PT} = { |
|
70
|
|
|
|
|
|
|
future => "no futuro", |
|
71
|
|
|
|
|
|
|
recent => "agora", |
|
72
|
|
|
|
|
|
|
years => ["%d anos atrás", "há um ano"], |
|
73
|
|
|
|
|
|
|
months => ["%d meses atrás", "há um mês"], |
|
74
|
|
|
|
|
|
|
weeks => ["%d semanas atrás", "há uma semana"], |
|
75
|
|
|
|
|
|
|
days => ["%d dias atrás", "há um dia"], |
|
76
|
|
|
|
|
|
|
hours => ["%d horas atrás", "há uma hora"], |
|
77
|
|
|
|
|
|
|
minutes => ["%d minutos atrás", "há um minuto"], |
|
78
|
|
|
|
|
|
|
}; |
|
79
|
6
|
|
|
|
|
2842
|
$__{IND} = $__{ID} = { |
|
80
|
|
|
|
|
|
|
future => "yang akan datang", |
|
81
|
|
|
|
|
|
|
recent => "baru saja", |
|
82
|
|
|
|
|
|
|
years => ["%d tahun yang lalu", "setahun yang lalu"], |
|
83
|
|
|
|
|
|
|
months => ["%d bulan yang lalu", "sebulan yang lalu"], |
|
84
|
|
|
|
|
|
|
weeks => ["%d minggu yang lalu", "seminggu yang lalu"], |
|
85
|
|
|
|
|
|
|
days => ["%d hari yang lalu", "sehari yang lalu"], |
|
86
|
|
|
|
|
|
|
hours => ["%d jam yang lalu", "sejam yang lalu"], |
|
87
|
|
|
|
|
|
|
minutes => ["%d menit yang lalu", "semenit yang lalu"], |
|
88
|
|
|
|
|
|
|
}; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub new |
|
92
|
|
|
|
|
|
|
{ |
|
93
|
4
|
|
|
4
|
1
|
2650
|
my ($class, %options) = @_; |
|
94
|
4
|
|
0
|
|
|
15
|
$options{'language'} //= ($ENV{LANG} // 'en'); |
|
|
|
|
33
|
|
|
|
|
|
95
|
4
|
|
|
|
|
12
|
$options{'language'} =~ s/\..*$//; |
|
96
|
4
|
|
|
|
|
22
|
bless \%options, $class; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub parse_datetime |
|
100
|
|
|
|
|
|
|
{ |
|
101
|
0
|
|
|
0
|
1
|
0
|
Carp::croak(sprintf("%s doesn't do parsing", __PACKAGE__)); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _now |
|
105
|
|
|
|
|
|
|
{ |
|
106
|
601
|
100
|
|
601
|
|
1238
|
if ($INC{'Time/HiRes.pm'}) |
|
107
|
|
|
|
|
|
|
{ |
|
108
|
1
|
|
|
|
|
5
|
return 'DateTime'->from_epoch(epoch => Time::HiRes::time()); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
600
|
|
|
|
|
1192
|
return 'DateTime'->now; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub format_datetime |
|
114
|
|
|
|
|
|
|
{ |
|
115
|
601
|
|
|
601
|
1
|
585305
|
my ($self, $datetime) = @_; |
|
116
|
601
|
50
|
|
|
|
2151
|
$self = $self->new unless blessed($self); |
|
117
|
|
|
|
|
|
|
|
|
118
|
601
|
|
|
|
|
962
|
my $now = $self->_now; |
|
119
|
601
|
|
|
|
|
90857
|
my $delta = $now - $datetime; |
|
120
|
601
|
|
|
|
|
103500
|
my %strings = $self->_strings; |
|
121
|
|
|
|
|
|
|
|
|
122
|
601
|
100
|
|
|
|
1566
|
return $strings{future} if $delta->is_negative; |
|
123
|
|
|
|
|
|
|
|
|
124
|
580
|
|
|
|
|
6720
|
foreach my $unit (qw/years months weeks days hours minutes/) |
|
125
|
|
|
|
|
|
|
{ |
|
126
|
2844
|
50
|
|
|
|
4621
|
$strings{$unit}[0] = uc "%d $unit ago" |
|
127
|
|
|
|
|
|
|
unless defined $strings{$unit}[0]; |
|
128
|
|
|
|
|
|
|
|
|
129
|
2844
|
|
|
|
|
4367
|
my $n = $delta->in_units($unit); |
|
130
|
|
|
|
|
|
|
|
|
131
|
2844
|
100
|
|
|
|
40550
|
if ($n > 0) |
|
132
|
|
|
|
|
|
|
{ |
|
133
|
405
|
100
|
66
|
|
|
931
|
if (exists $strings{$unit}[$n] |
|
134
|
|
|
|
|
|
|
and defined $strings{$unit}[$n]) |
|
135
|
|
|
|
|
|
|
{ |
|
136
|
45
|
|
|
|
|
461
|
return sprintf($strings{$unit}[$n], $n); |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
360
|
|
|
|
|
3619
|
return sprintf($strings{$unit}[0], $n); |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
175
|
|
|
|
|
1119
|
return $strings{recent}; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub _strings |
|
147
|
|
|
|
|
|
|
{ |
|
148
|
601
|
|
|
601
|
|
684
|
my ($self) = @_; |
|
149
|
601
|
50
|
|
|
|
1769
|
$self = $self->new unless blessed($self); |
|
150
|
|
|
|
|
|
|
|
|
151
|
601
|
|
|
|
|
1092
|
my $language = uc $self->{language}; |
|
152
|
601
|
|
|
|
|
1111
|
while (length $language) |
|
153
|
|
|
|
|
|
|
{ |
|
154
|
601
|
50
|
|
|
|
1275
|
return %{$__{$language}} if defined $__{$language}; |
|
|
601
|
|
|
|
|
3108
|
|
|
155
|
0
|
|
|
|
|
|
$language =~ s/(^|[_-])([^_-]*)$//; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
Carp::croak(sprintf("%s doesn't know about language '%s'", __PACKAGE__, $self->{language})); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
__PACKAGE__ |
|
162
|
|
|
|
|
|
|
__END__ |