Bug 16289: Abbreviated formatting for numbering patterns
authorKarl Holten <kholten@switchinc.org>
Mon, 18 Apr 2016 19:17:40 +0000 (14:17 -0500)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 10 Jun 2016 18:09:48 +0000 (18:09 +0000)
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 <sonia.bouis@univ-lyon3.fr>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

C4/Serials.pm
koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt
koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt

index eca9b13..755fc93 100644 (file)
@@ -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;
     }
index d17eeaa..637c843 100644 (file)
@@ -837,8 +837,11 @@ $(document).ready(function() {
                                                         <select disabled="disabled" id="[% name %]" name="[% name %]" />
                                                             <option value=""></option>
                                                             <option value="dayname">Name of day</option>
+                                                            <option value="dayabrv">Name of day (abbreviated)</option>
                                                             <option value="monthname">Name of month</option>
+                                                            <option value="monthabrv">Name of month (abbreviated)</option>
                                                             <option value="season">Name of season</option>
+                                                            <option value="seasonabrv">Name of season (abbreviated)</option>
                                                         </select>
                                                     [% END %]
                                                     <td>Formatting</td>
index f960c5f..098cae1 100644 (file)
@@ -180,16 +180,31 @@ $(document).ready(function(){
                         [% ELSE %]
                             <option value="dayname">Name of day</option>
                         [% END %]
+                        [% IF (value == "dayabrv") %]
+                            <option selected="selected" value="dayabrv">Name of day (abbreviated)</option>
+                        [% ELSE %]
+                            <option value="dayabrv">Name of day (abbreviated)</option>
+                        [% END %]
                         [% IF (value == "monthname") %]
                             <option selected="selected" value="monthname">Name of month</option>
                         [% ELSE %]
                             <option value="monthname">Name of month</option>
                         [% END %]
+                        [% IF (value == "monthabrv") %]
+                            <option selected="selected" value="monthabrv">Name of month (abbreviated)</option>
+                        [% ELSE %]
+                            <option value="monthabrv">Name of month (abbreviated)</option>
+                        [% END %]
                         [% IF (value == "season") %]
                             <option selected="selected" value="season">Name of season</option>
                         [% ELSE %]
                             <option value="season">Name of season</option>
                         [% END %]
+                        [% IF (value == "seasonabrv") %]
+                            <option selected="selected" value="seasonabrv">Name of season (abbreviated)</option>
+                        [% ELSE %]
+                            <option value="seasonabrv">Name of season (abbreviated)</option>
+                        [% END %]
                       </select>
                     [% END %]
                     <td>Formatting</td>