package II3562149e53818b6637b38680e87ba918::datepopup; use strict; use IIa67e09caf104f2e50322b7bc59b766fb; our $DefaultFormat = 'dd.mm.yyyy'; sub get { my ($form, $f) = @_; my ($format, $default_today) = split ',', Zen::PerlHandler->getStatList; $format ||= $DefaultFormat; my $code; my $value = $form->getDecorated->{$f} || ($default_today ? IIb39071a48a82a07eeb9256f406abebc5::lllllIlIIIIlIIlI($II8dae0e141ee45f5daba6a74e4a7c3b6f::IIlllIIIlIIIlIlI{$IIb39071a48a82a07eeb9256f406abebc5::llllIIIlllllIlII},1010,$II8dae0e141ee45f5daba6a74e4a7c3b6f::IIlllIIIlIIIlIlI{$IIb39071a48a82a07eeb9256f406abebc5::llIlIllllIIIlIIl})->new->date : ''); if ($value) { my ($y, $m, $d) = $value =~ /^(\d{4})\-(\d{2})\-(\d{2})/; die "failed to parse date [$value]" unless $y && $m && $d; $value = $format; $value =~ s/(\w+)/ $1 eq 'dd' ? $d : $1 eq 'mm' ? $m : $1 eq 'yyyy' ? $y : die "sorry, tag [$1] is not supported yet in format [$format]" /gex; } my $pfxf = $form->pfx . $f; $code .= qq(<input type="text" name="$pfxf" id="$pfxf" value="$value" class="form-control">); return $code; } sub set { my ($form, $f, $value) = @_; my ($format, undef) = split ',', Zen::PerlHandler->getStatList; $format ||= $DefaultFormat; my ($d, $m, $y); if ($value) { while ($format =~ /(\w+)/g) { if ($1 eq 'dd') { $d = substr $value, length($`), 2; } elsif ($1 eq 'mm') { $m = substr $value, length($`), 2; } elsif ($1 eq 'yyyy') { $y = substr $value, length($`), 4; } } $value = "$y-$m-$d"; } $form->getDecorated->{$f} = $value || undef; return; } 1; 