FFZG stocknumber - use last year until 15th of january
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 1 Jan 2013 22:43:20 +0000 (23:43 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 4 Jan 2016 14:56:38 +0000 (15:56 +0100)
cataloguing/value_builder/ffzg-stocknumber.pl

index 8e27356..ac89d9f 100755 (executable)
@@ -22,6 +22,7 @@ use warnings;
 use C4::Auth;
 use CGI;
 use C4::Context;
+use DateTime;
 
 =head1 DESCRIPTION
 
@@ -94,9 +95,15 @@ sub plugin {
 
 
     my $code = $input->param('code');
-       my ( $year, $num ) = split(/-/,$code);
+    my ( $year, $num ) = split(/-/,$code);
 
-    $year = (localtime)[5] + 1900 unless $year;
+    if ( ! $year ) {
+       my $now = DateTime->now;
+       $year = $now->year;
+       if ( $now->month == 1 && $now->day <= 15 ) {
+               $year--;
+       }
+    }
 
 warn "XXX plugin code = $code";