From e7b61d91bd7e305a17c039f44735aaea579e9d23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Fri, 13 Mar 2015 15:19:29 +0100 Subject: [PATCH] Bug 13813 - Remove C4::Dates from C4/Barcodes/hbyymmincr.pm To test: Set syspref autoBarcode to yymm0001 Edit items or add item, click in empty barcode field, verify that barcodes are filled in as appropriate. Amended following comment #58 /mv --- C4/Barcodes/hbyymmincr.pm | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/C4/Barcodes/hbyymmincr.pm b/C4/Barcodes/hbyymmincr.pm index 258a1a5..02ba7ae 100644 --- a/C4/Barcodes/hbyymmincr.pm +++ b/C4/Barcodes/hbyymmincr.pm @@ -24,7 +24,6 @@ use Carp; use C4::Context; use C4::Debug; -use C4::Dates; use vars qw($VERSION @ISA); use vars qw($debug $cgi_debug); # from C4::Debug, of course @@ -48,16 +47,16 @@ sub db_max { $debug and print STDERR "(hbyymmincr) db_max query: $query\n"; my $sth = C4::Context->dbh->prepare($query); my ($iso); - if (@_) { - my $input = shift; - $iso = C4::Dates->new($input,'iso')->output('iso'); # try to set the date w/ 2nd arg - unless ($iso) { - warn "Failed to create 'iso' Dates object with input '$input'. Reverting to today's date."; - $iso = C4::Dates->new->output('iso'); # failover back to today - } - } else { - $iso = C4::Dates->new->output('iso'); - } + if (@_) { + my $input = shift; + $iso = output_pref({ dt => dt_from_string( $input, 'iso' ), dateformat => 'iso', dateonly => 1 }); # try to set the date w/ 2nd arg + unless ($iso) { + warn "Failed to create 'iso' Dates object with input '$input'. Reverting to today's date."; + $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # failover back to today + } + } else { + $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); + } my $year = substr($iso,2,2); # i.e. "08" for 2008 my $andtwo = $width+2; $sth->execute("^[a-zA-Z]{1,}" . $year . "[0-9]{$andtwo}"); # the extra two digits are the month. we don't care what they are, just that they are there. @@ -74,7 +73,7 @@ sub db_max { sub initial { my $self = shift; # FIXME: populated branch? - my $iso = C4::Dates->new->output('iso'); # like "2008-07-02" + my $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # like "2008-07-02" return $self->branch . substr($iso,2,2) . substr($iso,5,2) . sprintf('%' . "$width.$width" . 'd',1); } @@ -104,7 +103,7 @@ sub process_head { # (self,head,whole,specific) my ($self,$head,$whole,$specific) = @_; $specific and return $head; # if this is built off an existing barcode, just return the head unchanged. $head =~ s/\d{4}$//; # else strip the old yymm - my $iso = C4::Dates->new->output('iso'); # like "2008-07-02" + my $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # like "2008-07-02" return $head . substr($iso,2,2) . substr($iso,5,2); } -- 1.7.10.4