1 |
dpavlin |
168 |
# rewrite interval years into separate values for indexing |
2 |
|
|
# |
3 |
|
|
# e.g. 1998- will be indexed as 1998 1999 2000 2001 2002 2003 |
4 |
|
|
# 1993-1995 will be 1993 1994 1995 |
5 |
|
|
|
6 |
|
|
sub swish_years { |
7 |
|
|
my $out = ""; |
8 |
|
|
foreach (@_) { |
9 |
|
|
if (/(\d{4})\s*-\s*(\d{4})/) { |
10 |
|
|
my ($from,$to) = ($1,$2); |
11 |
|
|
for (my $i=$from; $i<=$to; $i++) { |
12 |
|
|
$out .= $i." "; |
13 |
|
|
} |
14 |
|
|
} elsif (/(\d{4})-/) { |
15 |
|
|
my $from = $1; |
16 |
|
|
my @t = localtime(time); |
17 |
|
|
my $to = $t[5]; |
18 |
|
|
$to += 1900; |
19 |
|
|
for (my $i=$from; $i<=$to; $i++) { |
20 |
|
|
$out .= $i." "; |
21 |
|
|
} |
22 |
|
|
} else { |
23 |
|
|
$out .= "$_ "; |
24 |
|
|
} |
25 |
|
|
} |
26 |
|
|
return $out; |
27 |
|
|
} |
28 |
|
|
|
29 |
|
|
1; |