% );
%}
%
-%if ( $cgi->param('birthdate') && $cgi->param('birthdate') =~ /^([ 0-9\-\/]{0,10})$/ ) {
+%if ( $cgi->param('birthdate') && $cgi->param('birthdate') =~ /^([ 0-9\-\/]{0,10})$/) {
% my $conf = new FS::Conf;
% my $format = $conf->config('date_format') || "%m/%d/%Y";
% my $parser = DateTime::Format::Strptime->new(pattern => $format,
% time_zone => 'floating',
% );
-% $new->setfield('birthdate', $parser->parse_datetime($1)->epoch);
+% my $dt = $parser->parse_datetime($1);
+% if ($dt) {
+% $new->setfield('birthdate', $dt->epoch);
+% $cgi->param('birthdate', $dt->epoch);
+% } else {
+%# $error ||= $cgi->param('birthdate') . " is an invalid birthdate:" . $parser->errmsg;
+% $error ||= "Invalid birthdate: " . $cgi->param('birthdate') . ".";
+% $cgi->param('birthdate', '');
+% }
%}
%
%$new->setfield('paid', $cgi->param('paid') )
$label = $name unless $label;
if ($usedatetime) {
- eval "use DateTime;";
- die $@ if $@;
my $dt = DateTime->from_epoch(epoch => $value, time_zone => 'floating');
- $value = $dt->strftime($format);
+ $value = $dt->strftime($format)
+ unless $value eq '';
}else{
$value = time2str($format, $value);
}
</TR>
% if ( $conf->exists('cust_main-enable_birthdate') ) {
-% eval "use DateTime;";
-% die $@ if $@;
% my $dt = DateTime->from_epoch(epoch => $cust_main->birthdate,
% time_zone=>'floating',
% );
<TR>
<TD ALIGN="right">Date of Birth</TD>
- <TD BGCOLOR="#ffffff"><% $cust_main->birthdate ? $dt->strftime($date_format) : '' %></TD>
+ <TD BGCOLOR="#ffffff"><% $cust_main->birthdate ne '' ? $dt->strftime($date_format) : '' %></TD>
</TR>
% }