blob: ad84b915d301f852d28326b2021b63ac8bacb380 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
<SELECT NAME="<% $prefix %>_month" SIZE="1" <% $disabled%>>
<% $empty ? '<OPTION VALUE="">' : '' %>
% foreach ( 1 .. 12 ) {
<OPTION<% $_ == $mon ? ' SELECTED' : '' %> VALUE="<% $_ %>"><% $mon[$_-1] %>
% }
</SELECT>/<SELECT NAME="<% $prefix %>_year" SIZE="1" <% $disabled%>>
<% $empty ? '<OPTION VALUE="">' : '' %>
% for ( $start_year .. $end_year ) {
<OPTION<% $_ == $year ? ' SELECTED' : '' %> VALUE="<% $_ %>"><% $_ %>
% }
</SELECT>
<%init>
my %opt = @_;
my $prefix = $opt{'prefix'} || '';
my $disabled = $opt{'disabled'} || '';
my $empty = $opt{'empty_option'} || '';
my $start_year = $opt{'start_year'};
my $end_year = $opt{'end_year'} || '2037';
my @mon;
if ( $opt{'show_month_abbr'} ) {
@mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
# XXX: localization
} else {
@mon = ( ( map "0$_", 1 .. 9 ), 10 .. 12 ),
}
my $date = $opt{'selected_date'} || '';
$date = '' if $date eq '-';
my $mon = $opt{'selected_mon'} || 0;
my $year = $opt{'selected_year'} || 0;
if ( $date ) {
if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
( $mon, $year ) = ( $2, $1 );
} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
( $mon, $year ) = ( $1, $3 );
} else {
die "unrecognized expiration date format: $date";
}
}
unless ( $start_year ) {
my @t = localtime;
$start_year = $t[5] + 1900;
}
$start_year = $year if $start_year > $year && $year > 0;
</%init>
|