diff options
author | Mark Wells <mark@freeside.biz> | 2014-01-27 16:52:39 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2014-01-27 16:52:39 -0800 |
commit | 48fc9f425ec3454f4346089318994ae6c1e080a8 (patch) | |
tree | e8da5309d456ebc079acba378a0ff97217631293 /FS/FS/cust_main_Mixin.pm | |
parent | fbccadc20ceb30d90ef5ab8a2e135834a1aded31 (diff) |
localize dates that will appear on invoices, #24850
Diffstat (limited to 'FS/FS/cust_main_Mixin.pm')
-rw-r--r-- | FS/FS/cust_main_Mixin.pm | 22 |
1 files changed, 22 insertions, 0 deletions
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<Date::Language>) 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 |