From 48fc9f425ec3454f4346089318994ae6c1e080a8 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Mon, 27 Jan 2014 16:52:39 -0800 Subject: localize dates that will appear on invoices, #24850 --- FS/FS/cust_main_Mixin.pm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'FS/FS/cust_main_Mixin.pm') diff --git a/FS/FS/cust_main_Mixin.pm b/FS/FS/cust_main_Mixin.pm index f584b41..92dea28 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 -- cgit v1.1