From d753644c2f09f6500b3c1690593f1e41922f0677 Mon Sep 17 00:00:00 2001 From: Karl Holten Date: Mon, 18 Apr 2016 14:17:40 -0500 Subject: [PATCH] Bug 16289: Abbreviated formatting for numbering patterns To test: 1) Go to Serials -> Manage numbering patterns 2) Create .New Numbering Pattern. 3) Type in a name of 'Day, Month, Season' and a numbering formula of '{X} {Y} {Z}'. 4) Set up the X field as following: add 1, every 1, set back to 1, when more than 30. 5) Select the formatting for X. There should be six options available instead of the original three. Use the formatting 'Name of Day (abbreviated)'. 5) Set up the Y field to add 1 every 30 reset back to 1 when more than 12. Use the formatting option 'Name of month (abbreviated)'. 6) Set up the Z field to add 1 every 90 reset back to 1 when more than 4. Use the formatting option 'Name of season (abbreviated)'. 8) Select a frequency of 1/day. 9) Select a first issue publication date of Jan 1, 2016. 10) Set X to begin with 5 and have an inner counter of 5. Set Z to begin with 3 and have an inner counter of 10. 11) Click the 'Test Pattern' button. 12) Abbreviated versions of the day, month and season should appear in the test pattern. Signed-off-by: sonia bouis Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- C4/Serials.pm | 25 +++++++++++++++++++ .../en/modules/serials/subscription-add.tt | 3 +++ .../serials/subscription-numberpatterns.tt | 15 +++++++++++ 3 files changed, 43 insertions(+) diff --git a/C4/Serials.pm b/C4/Serials.pm index eca9b13db3..755fc93cf1 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -2483,8 +2483,11 @@ sub GetNextDate { _numeration returns the string corresponding to $value in the num_type num_type can take : -dayname + -dayabrv -monthname + -monthabrv -season + -seasonabrv =cut #' @@ -2505,6 +2508,16 @@ sub _numeration { locale => $locale, ); $string = $dt->strftime("%A"); + } elsif ( $num_type =~ /^dayabrv$/ ) { + # 1970-11-01 was a Sunday + $value = $value % 7; + my $dt = DateTime->new( + year => 1970, + month => 11, + day => $value + 1, + locale => $locale, + ); + $string = $dt->strftime("%a"); } elsif ( $num_type =~ /^monthname$/ ) { $value = $value % 12; my $dt = DateTime->new( @@ -2513,10 +2526,22 @@ sub _numeration { locale => $locale, ); $string = $dt->strftime("%B"); + } elsif ( $num_type =~ /^monthabrv$/ ) { + $value = $value % 12; + my $dt = DateTime->new( + year => 1970, + month => $value + 1, + locale => $locale, + ); + $string = $dt->strftime("%b"); } elsif ( $num_type =~ /^season$/ ) { my @seasons= qw( Spring Summer Fall Winter ); $value = $value % 4; $string = $seasons[$value]; + } elsif ( $num_type =~ /^seasonabrv$/ ) { + my @seasonsabrv= qw( Spr Sum Fal Win ); + $value = $value % 4; + $string = $seasonsabrv[$value]; } else { $string = $value; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt index d17eeaa23e..637c8437b7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -837,8 +837,11 @@ $(document).ready(function() { [% END %] Formatting diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt index f960c5fd3c..098cae1406 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt @@ -180,16 +180,31 @@ $(document).ready(function(){ [% ELSE %] [% END %] + [% IF (value == "dayabrv") %] + + [% ELSE %] + + [% END %] [% IF (value == "monthname") %] [% ELSE %] [% END %] + [% IF (value == "monthabrv") %] + + [% ELSE %] + + [% END %] [% IF (value == "season") %] [% ELSE %] [% END %] + [% IF (value == "seasonabrv") %] + + [% ELSE %] + + [% END %] [% END %] Formatting -- 2.39.5