| Revision 168 (by dpavlin, 2003/11/23 15:37:43) |
added years filter for swish to support 1983- notation
|
# rewrite interval years into separate values for indexing
#
# e.g. 1998- will be indexed as 1998 1999 2000 2001 2002 2003
# 1993-1995 will be 1993 1994 1995
sub swish_years {
my $out = "";
foreach (@_) {
if (/(\d{4})\s*-\s*(\d{4})/) {
my ($from,$to) = ($1,$2);
for (my $i=$from; $i<=$to; $i++) {
$out .= $i." ";
}
} elsif (/(\d{4})-/) {
my $from = $1;
my @t = localtime(time);
my $to = $t[5];
$to += 1900;
for (my $i=$from; $i<=$to; $i++) {
$out .= $i." ";
}
} else {
$out .= "$_ ";
}
}
return $out;
}
1;