From: jeff Date: Thu, 16 Nov 2006 06:20:38 +0000 (+0000) Subject: switch birthdate to DateTime X-Git-Tag: TRIXBOX_2_6~861 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=7c1d5f4ce778b4ab56301a042076e7c1dce46152 switch birthdate to DateTime --- diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index 57d4dac5e..daddd8ece 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -172,7 +172,8 @@ 'birthdate', $cust_main->birthdate, 'Date of Birth', - $conf->config('date_format') || "%m/%d/%Y") + $conf->config('date_format') || "%m/%d/%Y", + 1) %> diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index 33f7bb895..d5d127b2d 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -54,7 +54,14 @@ %} % %if ( $cgi->param('birthdate') && $cgi->param('birthdate') =~ /^([ 0-9\-\/]{0,10})$/ ) { -% $new->setfield('birthdate', str2time($1)); +% eval "use DateTime::Format::Strptime;"; +% die $@ if $@; +% 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); %} % %$new->setfield('paid', $cgi->param('paid') ) diff --git a/httemplate/elements/tr-input-date-field.html b/httemplate/elements/tr-input-date-field.html index 0618fc965..1624df05c 100644 --- a/httemplate/elements/tr-input-date-field.html +++ b/httemplate/elements/tr-input-date-field.html @@ -7,7 +7,7 @@ <% $label %> - + @@ -23,10 +23,19 @@ <%init> -my($name, $value, $label, $format) = @_; +my($name, $value, $label, $format, $usedatetime) = @_; $format = "%m/%d/%Y" unless $format; $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); +}else{ + $value = time2str($format, $value); +} + diff --git a/httemplate/view/cust_main/misc.html b/httemplate/view/cust_main/misc.html index 414ef44a8..121c0522a 100644 --- a/httemplate/view/cust_main/misc.html +++ b/httemplate/view/cust_main/misc.html @@ -97,10 +97,15 @@ % if ( $conf->exists('cust_main-enable_birthdate') ) { +% eval "use DateTime;"; +% die $@ if $@; +% my $dt = DateTime->from_epoch(epoch => $cust_main->birthdate, +% time_zone=>'floating', +% ); Date of Birth - <% $cust_main->birthdate ? time2str($date_format, $cust_main->birthdate) : '' %> + <% $cust_main->birthdate ? $dt->strftime($date_format) : '' %> % }