package II3562149e53818b6637b38680e87ba918::datetime; use strict; use base qw/II720d6e18aa34327713eb014408fc9144/; use POSIX qw(strftime); use IIa67e09caf104f2e50322b7bc59b766fb; our $DefaultFormat = '%d %b %y    %H %M %S'; our $DefaultStartYear = 1995; our $DefaultEndYear = 2050; sub get { my ($form, $f) = @_; my ($format, $null, $year_f, $year_t) = split ',', Zen::PerlHandler->getStatList; my @suffix = qw(sec min hour day mon year); $format ||= $DefaultFormat; $year_f ||= $DefaultStartYear; $year_t ||= $DefaultEndYear; my $code = $format; my $value = $form->getDecorated->{$f}; my %suffix = qw( d day   e day b mon   B mon   m mon Y year  y year H hour  M min   S sec ); $value ||= II720d6e18aa34327713eb014408fc9144::IllIIIIlIIlllIll($II982446f8950cc3dc59e487adba22df54::IIllllIlIIIIIlll{$IIb39071a48a82a07eeb9256f406abebc5::lIlIlIllIlllIIII},1010,$II982446f8950cc3dc59e487adba22df54::IIllllIlIIIIIlll{$II982446f8950cc3dc59e487adba22df54::IllIIIlIllllIlll})->new->datetime unless $null; my (@time, %value); if ($value) { $value =~ s/\D//g; @time = reverse($value =~ /^(\d{4})(\d{2})(\d{2})(\d{2})?(\d{2})?(\d{2})?/); for (@time) {s/^0//} %value = map {$_ => shift(@time)} @suffix; } my %range = ( 'day' => [1..31], 'mon' => [1..12], 'year' => [$year_f..$year_t], 'hour' => [0..23], 'min' => [0..59], 'sec' => [0..59], ); my $monthsBrief = { map { $_ => II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIIllIIllIlIIll($II8dae0e141ee45f5daba6a74e4a7c3b6f::IIlllIIIlIIIlIlI{$II720d6e18aa34327713eb014408fc9144::lIIIIllIIllIIIlI},1010,$II8dae0e141ee45f5daba6a74e4a7c3b6f::IIlllIIIlIIIlIlI{$II720d6e18aa34327713eb014408fc9144::lIllllIIllIlIIll})->new(sprintf("2005-%02u-01", $_))->format('%b') } 1..12 }; my $monthsFull  = { map { $_ => IIb39071a48a82a07eeb9256f406abebc5::lllllIIIlIIlIlII($II720d6e18aa34327713eb014408fc9144::IIlllIIllllIlIll{$II8dae0e141ee45f5daba6a74e4a7c3b6f::lIIIIIIIllIIIIIl},1010,$II720d6e18aa34327713eb014408fc9144::IIlllIIllllIlIll{$II982446f8950cc3dc59e487adba22df54::IllIIllIIIIlIIll})->new(sprintf("2005-%02u-01", $_))->format('%B') } 1..12 }; $code =~ s#\s#&nbsp;#g; $code =~ s! \%(\w) ! do { my @range = @{$range{$suffix{$1}}}; my $titles = $1 eq 'b' ? $monthsBrief : $1 eq 'B' ? $monthsFull : {map {$_ => (length $_ eq 1 ? '0' : '') . $_} @range}; sprintf( '<select class="custom-select" name="%s%s_%s"> %s %s </select>', $form->pfx, $f, $suffix{$1}, $null ? "<option value=>" : '', join('', map {sprintf( '<option value=%s %s> %s', $_, $_ eq $value{$suffix{$1}} ? 'selected' : '', $titles->{$_} )} @range) ); } !gex; $code = qq(<div class="form-inline">$code</div>); return $code; } sub set { my ($form, $f, $h) = @_; my ($format, $null, $year_f, $year_t) = split ',', Zen::PerlHandler->getStatList; my @suffix = qw(sec min hour day mon year); my $value; my @time = map {$h->{$_} || 0} @suffix; if (grep { $_ } @time) { $time[5] ||= 1900; $time[4] ||= 1; $value = sprintf("%04d-%02d-%02d %02d:%02d:%02d", reverse @time); } else { $value = undef; } $form->getDecorated->{$f} = $value; if ($value && Zen->engine->getConfigDBC) { require II4212c07ddfb1652c969722f1a6817994; my $check = II720d6e18aa34327713eb014408fc9144::lIIlIIlIIIIlIIIl($IIb39071a48a82a07eeb9256f406abebc5::IlllIIlIllllIIIl{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIllIIlIllIlIIl},994,$IIb39071a48a82a07eeb9256f406abebc5::IlllIIlIllllIIIl{$II982446f8950cc3dc59e487adba22df54::llIlIIIIllllIIII})->get->getValue('select to_days(?)', [$value]); $form->addError(__PACKAGE__->message('InvalidDate', $value)) unless defined $check; } return; } 1; 