Lines 23-30
use Modern::Perl;
Link Here
|
23 |
use C4::Auth qw(haspermission); |
23 |
use C4::Auth qw(haspermission); |
24 |
use C4::Context; |
24 |
use C4::Context; |
25 |
use C4::Dates qw(format_date format_date_in_iso); |
25 |
use C4::Dates qw(format_date format_date_in_iso); |
|
|
26 |
use DateTime; |
26 |
use Date::Calc qw(:all); |
27 |
use Date::Calc qw(:all); |
27 |
use POSIX qw(strftime setlocale LC_TIME); |
28 |
use POSIX qw(strftime); |
28 |
use C4::Biblio; |
29 |
use C4::Biblio; |
29 |
use C4::Log; # logaction |
30 |
use C4::Log; # logaction |
30 |
use C4::Debug; |
31 |
use C4::Debug; |
Lines 2665-2708
num_type can take :
Link Here
|
2665 |
sub _numeration { |
2666 |
sub _numeration { |
2666 |
my ($value, $num_type, $locale) = @_; |
2667 |
my ($value, $num_type, $locale) = @_; |
2667 |
$value ||= 0; |
2668 |
$value ||= 0; |
2668 |
my $initlocale = setlocale(LC_TIME); |
|
|
2669 |
if($locale and $locale ne $initlocale) { |
2670 |
$locale = setlocale(LC_TIME, $locale); |
2671 |
} |
2672 |
$locale ||= $initlocale; |
2673 |
my $string; |
2674 |
$num_type //= ''; |
2669 |
$num_type //= ''; |
|
|
2670 |
$locale ||= 'en'; |
2671 |
my $string; |
2675 |
given ($num_type) { |
2672 |
given ($num_type) { |
2676 |
when (/^dayname$/) { |
2673 |
when (/^dayname$/) { |
2677 |
$value = $value % 7; |
2674 |
# 1970-06-01 was a monday |
2678 |
$string = POSIX::strftime("%A",0,0,0,0,0,0,$value); |
2675 |
$value = $value % 7; |
|
|
2676 |
my $dt = DateTime->new( |
2677 |
year => 1970, |
2678 |
month => 6, |
2679 |
day => $value + 1, |
2680 |
locale => $locale, |
2681 |
); |
2682 |
$string = $dt->strftime("%A"); |
2679 |
} |
2683 |
} |
2680 |
when (/^monthname$/) { |
2684 |
when (/^monthname$/) { |
2681 |
$value = $value % 12; |
2685 |
$value = $value % 12; |
2682 |
$string = POSIX::strftime("%B",0,0,0,1,$value,0,0,0,0); |
2686 |
my $dt = DateTime->new( |
|
|
2687 |
year => 1970, |
2688 |
month => $value + 1, |
2689 |
locale => $locale, |
2690 |
); |
2691 |
$string = $dt->strftime("%B"); |
2683 |
} |
2692 |
} |
2684 |
when (/^season$/) { |
2693 |
when (/^season$/) { |
2685 |
my $seasonlocale = ($locale) |
2694 |
my @seasons= qw( Spring Summer Fall Winter ); |
2686 |
? (substr $locale,0,2) |
|
|
2687 |
: "en"; |
2688 |
my %seasons=( |
2689 |
"en" => |
2690 |
[qw(Spring Summer Fall Winter)], |
2691 |
"fr"=> |
2692 |
[qw(Printemps Été Automne Hiver)], |
2693 |
); |
2694 |
$value = $value % 4; |
2695 |
$value = $value % 4; |
2695 |
$string = ($seasons{$seasonlocale}) |
2696 |
$string = $seasons[$value]; |
2696 |
? $seasons{$seasonlocale}->[$value] |
|
|
2697 |
: $seasons{'en'}->[$value]; |
2698 |
} |
2697 |
} |
2699 |
default { |
2698 |
default { |
2700 |
$string = $value; |
2699 |
$string = $value; |
2701 |
} |
2700 |
} |
2702 |
} |
2701 |
} |
2703 |
if($locale ne $initlocale) { |
|
|
2704 |
setlocale(LC_TIME, $initlocale); |
2705 |
} |
2706 |
return $string; |
2702 |
return $string; |
2707 |
} |
2703 |
} |
2708 |
|
2704 |
|