From 357bb2b78cd6383345394027f4149c6cbe65bd14 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 --- C4/Serials.pm | 25 ++++++++++++++++++++ .../prog/en/modules/serials/subscription-add.tt | 3 +++ .../modules/serials/subscription-numberpatterns.tt | 15 ++++++++++++ 3 files changed, 43 insertions(+) diff --git a/C4/Serials.pm b/C4/Serials.pm index eca9b13..755fc93 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 d17eeaa..637c843 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 f960c5f..098cae1 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 -- 1.7.10.4