summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xhttemplate/edit/cust_main.cgi3
-rwxr-xr-xhttemplate/edit/process/cust_main.cgi9
-rw-r--r--httemplate/elements/tr-input-date-field.html13
-rw-r--r--httemplate/view/cust_main/misc.html7
4 files changed, 27 insertions, 5 deletions
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)
%>
</TABLE>
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 @@
<TR>
<TD ALIGN="right"><% $label %></TD>
<TD>
- <INPUT TYPE="text" NAME="<% $name %>" ID="<% $name %>_text" VALUE="<% ($value eq '') ? '' : time2str($format, $value) %>">
+ <INPUT TYPE="text" NAME="<% $name %>" ID="<% $name %>_text" VALUE="<% $value %>">
<IMG SRC="../images/calendar.png" ID="<% $name %>_button" STYLE="cursor: pointer" TITLE="Select date">
</TD>
</TR>
@@ -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);
+}
+
</%init>
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 @@
</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 ? time2str($date_format, $cust_main->birthdate) : '' %></TD>
+ <TD BGCOLOR="#ffffff"><% $cust_main->birthdate ? $dt->strftime($date_format) : '' %></TD>
</TR>
% }