X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main_Mixin.pm;h=92dea284048adbda3004e22c1f169cf6f043f9df;hb=48fc9f425ec3454f4346089318994ae6c1e080a8;hp=f584b415eb98e66ec38dc47ae115b1a395e0099b;hpb=fbccadc20ceb30d90ef5ab8a2e135834a1aded31;p=freeside.git diff --git a/FS/FS/cust_main_Mixin.pm b/FS/FS/cust_main_Mixin.pm index f584b415e..92dea2840 100644 --- a/FS/FS/cust_main_Mixin.pm +++ b/FS/FS/cust_main_Mixin.pm @@ -582,6 +582,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