X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main_Mixin.pm;h=5a2eccd50ac6a33545d30003d2e331091b26fd80;hb=988ca5d2ed7121f00e11456e4919e42529d1aaec;hp=7fcb5b5c72b2d007cc4429ddc66b727ea1d87d4b;hpb=a0124adf19658d403f5b6ebb0cc0c7bb862d4c98;p=freeside.git diff --git a/FS/FS/cust_main_Mixin.pm b/FS/FS/cust_main_Mixin.pm index 7fcb5b5c7..5a2eccd50 100644 --- a/FS/FS/cust_main_Mixin.pm +++ b/FS/FS/cust_main_Mixin.pm @@ -410,6 +410,7 @@ sub email_search_result { } my $sql_query = $class->search($param->{'search'}); + $sql_query->{'select'} = $sql_query->{'table'} . '.*'; my $count_query = delete($sql_query->{'count_query'}); my $count_sth = dbh->prepare($count_query) @@ -577,6 +578,28 @@ sub mt { return $lh->maketext(@_); } +=item time2str_local FORMAT, TIME + +Localizes a date (see L) for the customer's locale. + +=cut + +sub time2str_local { + # renamed so that we don't have to change every single reference to + # time2str everywhere + my $self = shift; + if (!exists($self->{_dh})) { + my $cust_main = $self->cust_main; + my $locale = $cust_main->locale if $cust_main; + $locale ||= 'en_US'; + my %info = FS::Locales->locale_info($locale); + my $dh = eval { Date::Language->new($info{'name'}) } || + Date::Language->new(); # fall back to English + $self->{_dh} = $dh; + } + $self->{_dh}->time2str(@_); +} + =back =head1 BUGS