1 package SL::DB::Helpers::AttrDate;
10 my $attribute = shift;
13 $params{places} = 2 if !defined($params{places});
18 sub ${attribute}_as_date {
23 my (\$yy, \$mm, \$dd) = \$::locale->parse_date(\\\%::myconfig, \@_);
24 \$self->${attribute}(DateTime->new(year => \$yy, month => \$mm, day => \$dd));
26 \$self->${attribute}(undef);
30 return \$self->${attribute} ? \$::locale->reformat_date({ dateformat => 'yy-mm-dd' }, \$self->${attribute}->ymd, \$::myconfig{dateformat}) : undef;
37 croak "Defining '${attribute}_as_number' failed: $EVAL_ERROR" if $EVAL_ERROR;