<& '/contenido/components/select.msn', name => $name.'_day', values => \@days, check => $day &>
<& '/contenido/components/select.msn', name => $name.'_month', values => \@months, check => $month &>
<& '/contenido/components/select.msn', name => $name.'_year', values => \@years, check => $year &>
<& '/contenido/components/select.msn', name => $name.'_hour', values => \@hours, check => $hour &>
<& '/contenido/components/select.msn', name => $name.'_minute', values => \@minutes, check => $minute &>
% if ( $prop->{noseconds} ) {
<input type="hidden" name="<% $prop->{attr} %>_second" value="0">
% } else {
<& '/contenido/components/select.msn', name => $name.'_second', values => \@seconds, check => $second &>
% }
% if ( ref $prop && exists $prop->{attr} ) {
<span style="padding-left:20px;"><a href="javascript:void(0)" onclick="set_<% $prop->{attr} %>_now()" style="color:red;">Сейчас!</a></span>
<script type="text/javascript">
<!--
function set_<% $prop->{attr} %>_now () {
document.forms['form'].elements['<% $prop->{attr} %>_day'].value = '<% $now->day %>';
document.forms['form'].elements['<% $prop->{attr} %>_month'].value = '<% $now->mon %>';
document.forms['form'].elements['<% $prop->{attr} %>_year'].value = '<% $now->year %>';
document.forms['form'].elements['<% $prop->{attr} %>_hour'].value = '<% $now->hour %>';
document.forms['form'].elements['<% $prop->{attr} %>_minute'].value = '<% $now->minute %>';
% unless ( $prop->{noseconds} ) {
document.forms['form'].elements['<% $prop->{attr} %>_second'].value = '<% $now->second %>';
% }
}
//-->
</script>
% if ( $prop->{allow_null} ) {
<span style="padding-left:20px;"><a href="javascript:void(0)" onclick="set_<% $prop->{attr} %>_clear()" style="color:red;">Очистить!</a></span>
<script type="text/javascript">
<!--
function set_<% $prop->{attr} %>_clear () {
document.forms['form'].elements['<% $prop->{attr} %>_day'].value = '';
document.forms['form'].elements['<% $prop->{attr} %>_month'].value = '';
document.forms['form'].elements['<% $prop->{attr} %>_year'].value = '';
document.forms['form'].elements['<% $prop->{attr} %>_hour'].value = '';
document.forms['form'].elements['<% $prop->{attr} %>_minute'].value = '';
% unless ( $prop->{noseconds} ) {
document.forms['form'].elements['<% $prop->{attr} %>_second'].value = '';
% }
}
//-->
</script>
% }
% }
<%args>
$prop
$name => undef
$check => undef
</%args>
<%init>
my @localtime = localtime(); $localtime[4]++; $localtime[5] += 1900;
# Формируем данные для select'а...
my @days = map { $_ => $_ } (1..31);
my @months = @{ $m->comp('/contenido/components/get_months.msn') };
my $start_year = $check && $check =~ /(\d{4})/ ? int($1) - 5 : $localtime[5] - 5;
my @years = map { $_ => $_ } ( $start_year .. $localtime[5] + 5);
my @hours = map { $_ => sprintf('%02d', $_) } (0 .. 23);
my @minutes = map { $_ => sprintf('%02d', $_) } (0 .. 59);
my @seconds;
if ( exists $prop->{seconds_step} && $prop->{seconds_step} > 1 ) {
@seconds = grep { ($_ % $prop->{seconds_step}) == 0 } map { $_ => sprintf('%02d', $_) } (0 .. 59);
} else {
@seconds = map { $_ => sprintf('%02d', $_) } (0 .. 59);
}
if ($prop->{allow_null}) {
unshift @days, '', '';
unshift @months, '', '';
unshift @years, '', '';
unshift @hours, '', '';
unshift @minutes, '', '';
unshift @seconds, '', '';
}
my ($year,$month,$day,$hour,$minute, $second);
if ($check) {
$check =~ /(\d{4})-(\d{1,2})-(\d{1,2})\s+(\d{1,2}):(\d{1,2}):(\d{1,2})/;
($year, $month, $day, $hour, $minute, $second) = ($1 + 0, $2 + 0, $3 + 0, $4 + 0, $5 + 0, $6 + 0);
} elsif(!$prop->{allow_null}) {
($second,$minute,$hour,$day,$month,$year) = @localtime[0 .. 5];
}
my $now = Contenido::DateTime->new;
</%init>