Test plan: See Bugzilla.
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
use Carp;
use C4::Context;
use C4::Debug;
-use C4::Dates qw(format_date format_date_in_iso);
use C4::Suggestions;
use C4::Biblio;
use C4::Contract;
my $order_vendornote = $params->{order_vendornote};
my $dbh = C4::Context->dbh;
- $datereceived = C4::Dates->output('iso') unless $datereceived;
+ $datereceived = output_pref({ dt=>dt_from_string, dateonly=>1, dateformat=>'iso' }) unless $datereceived;
my $suggestionid = GetSuggestionFromBiblionumber( $biblionumber );
if ($suggestionid) {
ModSuggestion( {suggestionid=>$suggestionid,
Reopen an invoice
-Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => C4::Dates->new()->output('iso'))
+Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => output_pref({ dt=>dt_from_string, dateonly=>1, otputpref=>'iso' }))
=cut
use C4::Context;
use C4::Debug;
-use C4::Dates;
use C4::Barcodes::hbyymmincr;
use C4::Barcodes::annual;
use C4::Barcodes::incremental;
use C4::Context;
use C4::Debug;
-use C4::Dates;
+
+use Koha::DateUtils qw( output_pref dt_from_string );
use vars qw($VERSION @ISA);
use vars qw($debug $cgi_debug); # from C4::Debug, of course
my ($iso);
if (@_) {
my $input = shift;
- $iso = C4::Dates->new($input,'iso')->output('iso'); # try to set the date w/ 2nd arg
+ $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 = C4::Dates->new->output('iso'); # failover back to today
+ $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # failover back to today
}
} else {
- $iso = C4::Dates->new->output('iso');
+ $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
}
my $year = substr($iso,0,4); # YYYY
$sth->execute("$year-%");
sub initial () {
my $self = shift;
- return substr(C4::Dates->new->output('iso'),0,4) .'-'. sprintf('%'."$width.$width".'d', 1);
+ return substr(output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 0, 4 ) .'-'. sprintf('%'."$width.$width".'d', 1);
}
sub parse ($;$) {
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.
- return substr(C4::Dates->new->output('iso'),0,4) . '-'; # else get new YYYY-
+ return substr(output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 0, 4 ) . '-'; # else get new YYYY-
}
sub new_object {
use C4::Context;
use C4::Debug;
-use C4::Dates;
+
+use Koha::DateUtils qw( dt_from_string output_pref );
use vars qw($VERSION @ISA);
use vars qw($debug $cgi_debug); # from C4::Debug, of course
$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.
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);
}
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);
}
use Module::Load::Conditional qw(can_load);
use C4::Koha;
-use C4::Dates qw/format_date/;
use C4::Log; # logaction
use C4::Budgets;
use C4::ClassSource;
use C4::Circulation;
use C4::Members;
use C4::Biblio;
-use C4::Dates qw/format_date/;
use List::Util qw(shuffle);
use List::MoreUtils qw(any);
use C4::Context;
use C4::Koha;
use C4::Biblio;
-use C4::Dates qw/format_date format_date_in_iso/;
+use Koha::DateUtils;
use MARC::Record;
use C4::ClassSource;
use C4::Log;
sub ModDateLastSeen {
my ($itemnumber) = @_;
- my $today = C4::Dates->new();
- ModItem({ itemlost => 0, datelastseen => $today->output("iso") }, undef, $itemnumber);
+ my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
+ ModItem({ itemlost => 0, datelastseen => $today }, undef, $itemnumber);
}
=head2 DelItem
sub _set_defaults_for_add {
my $item = shift;
- $item->{dateaccessioned} ||= C4::Dates->new->output('iso');
+ $item->{dateaccessioned} ||= output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
$item->{$_} ||= 0 for (qw( notforloan damaged itemlost withdrawn));
}
notforloan = ?,
damaged = ?,
itemlost = ?,
- withdrawn = ?,
+ withdrawn = ?,
itemcallnumber = ?,
coded_location_qualifier = ?,
restricted = ?,
holdingbranch = ?,
paidfor = ?,
location = ?,
- permanent_location = ?,
+ permanent_location = ?,
onloan = ?,
issues = ?,
renewals = ?,
ccode = ?,
itype = ?,
materials = ?,
- uri = ?,
+ uri = ?,
enumchron = ?,
more_subfields_xml = ?,
copynumber = ?,
stocknumber = ?
";
my $sth = $dbh->prepare($query);
- my $today = C4::Dates->today('iso');
+ my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
$sth->execute(
$item->{'biblionumber'},
$item->{'biblioitemnumber'},
use warnings;
use C4::Context;
-use C4::Dates qw(format_date);
+use Koha::DateUtils;
use vars qw($VERSION @ISA @EXPORT);
my $object = shift;
my $info = shift;
- my $iso_datefrom = C4::Dates->new($datefrom,C4::Context->preference("dateformat"))->output('iso');
- my $iso_dateto = C4::Dates->new($dateto,C4::Context->preference("dateformat"))->output('iso');
+ my $iso_datefrom = output_pref({ dt => dt_from_string( $datefrom ), dateformat => 'iso', dateonly => 1 });
+ my $iso_dateto = output_pref({ dt => dt_from_string( $dateto ), dateformat => 'iso', dateonly => 1 });
my $dbh = C4::Context->dbh;
my $query = "
use Modern::Perl;
use C4::Context;
-use C4::Dates qw(format_date);
+use Koha::DateUtils;
use vars qw($VERSION @ISA @EXPORT);
$sth->execute($idnew);
my $data = $sth->fetchrow_hashref;
$data->{$data->{'lang'}} = 1 if defined $data->{lang};
- $data->{expirationdate} = format_date($data->{expirationdate});
- $data->{timestamp} = format_date($data->{timestamp});
+ $data->{expirationdate} = output_pref({ dt => dt_from_string( $data->{expirationdate} ), dateonly => 1 });
+ $data->{timestamp} = output_pref({ dt => dt_from_string( $data->{timestamp} ), dateonly => 1 }) ;
return $data;
}
$sth->execute($lang,$branch);
my @results;
while ( my $row = $sth->fetchrow_hashref ){
- $row->{newdate} = format_date($row->{newdate});
+ $row->{newdate} = output_pref({ dt => dt_from_string( $row->{newdate} ), dateonly => 1 });
push @results, $row;
}
return \@results;
use URI::Escape;
use C4::Context;
-use C4::Dates qw(format_date);
use C4::Templates;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use C4::Context;
use C4::Output;
-use C4::Dates qw(format_date format_date_in_iso);
use C4::Debug;
use C4::Letters;
-use Koha::DateUtils qw( dt_from_string );
+use Koha::DateUtils;
use List::MoreUtils qw(any);
-use C4::Dates qw(format_date_in_iso);
use base qw(Exporter);
our $VERSION = 3.07.00.049;
}
# filter on date fields
- my $today = C4::Dates->today('iso');
foreach my $field (qw( suggesteddate manageddate accepteddate )) {
my $from = $field . "_from";
my $to = $field . "_to";
if ( $suggestion->{$from} || $suggestion->{$to} ) {
push @query, qq{ AND suggestions.$field BETWEEN ? AND ? };
push @sql_params,
- format_date_in_iso( $suggestion->{$from} ) || '0000-00-00';
+ output_pref({ dt => dt_from_string( $suggestion->{$from} ), dateformat => 'iso', dateonly => 1 }) || '0000-00-00';
push @sql_params,
- format_date_in_iso( $suggestion->{$to} ) || $today;
+ output_pref({ dt => dt_from_string( $suggestion->{$to} ), dateformat => 'iso', dateonly => 1 }) || output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
}
}
use C4::Context;
use C4::Output;
-use C4::Dates;
use C4::Debug;
BEGIN {
use C4::Context;
use C4::Output;
-use C4::Dates;
=head1 NAME
use C4::Context;
require C4::Barcodes::ValueBuilder;
-require C4::Dates;
+use Koha::DateUtils;
use Algorithm::CheckDigits;
my %args;
# find today's date
- ($args{year}, $args{mon}, $args{day}) = split('-', C4::Dates->today('iso'));
+ ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }));
($args{tag},$args{subfield}) = GetMarcFromKohaField("items.barcode", '');
($args{loctag},$args{locsubfield}) = GetMarcFromKohaField("items.homebranch", '');
use C4::Context;
require C4::Barcodes::ValueBuilder;
-require C4::Dates;
+use Koha::DateUtils;
my $DEBUG = 0;
$args{dbh} = $dbh;
# find today's date
- ($args{year}, $args{mon}, $args{day}) = split('-', C4::Dates->today('iso'));
+ ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }));
($args{tag},$args{subfield}) = GetMarcFromKohaField("items.barcode", '');
($args{loctag},$args{locsubfield}) = GetMarcFromKohaField("items.homebranch", '');
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
-
+use Koha::DateUtils;
no warnings 'redefine';
sub plugin_javascript {
# my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
my $function_name = "dateaccessioned".(int(rand(100000))+1);
- require C4::Dates;
- my $date = C4::Dates->today('iso');
+ my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
# find the tag/subfield mapped to items.dateaccessioned
my ($tag,$subfield) = GetMarcFromKohaField("items.dateaccessioned","");
use C4::Output;
use C4::Branch; # GetBranches
use C4::Auth;
-use C4::Dates qw/format_date/;
+use Koha::DateUtils;
use C4::Biblio;
use C4::Circulation;
use C4::Members;
$template->param(
branchesloop => \@branchesloop,
- show_date => format_date(C4::Dates->today('iso')),
+ show_date => output_pref({ dt => dt_from_string, dateonly => 1 }),
TransfersMaxDaysWarning => C4::Context->preference('TransfersMaxDaysWarning'),
latetransfers => $latetransfers ? 1 : 0,
);
use C4::Output;
use C4::Branch; # GetBranchName
use C4::Auth;
-use C4::Dates qw/format_date/;
use C4::Circulation;
use C4::Members;
use C4::Biblio;
use C4::Items;
-
+use Koha::DateUtils;
use Date::Calc qw(
Today
Add_Delta_Days
reservecount => $reservcount,
overloop => \@overloop,
overcount => $overcount,
- show_date => format_date(C4::Dates->today('iso')),
+ show_date => output_pref({ dt => dt_from_string, dateonly => 1 }),
ReservesMaxPickUpDelay => C4::Context->preference('ReservesMaxPickUpDelay')
);
use C4::Letters;
use C4::Members::Attributes qw(GetBorrowerAttributes);
-use C4::Dates qw/format_date/;
my $input=new CGI;
use C4::Auth;
use C4::Output;
-use C4::Dates qw/format_date/;
+use Koha::DateUtils;
use CGI qw ( -utf8 );
use C4::Members;
use C4::Branch;
}
my %row = (
- 'date' => format_date( $accts->[$i]{'date'} ),
+ 'date' => output_pref({ dt => dt_from_string( $accts->[$i]{'date'}, 'iso' ), dateonly => 1 }),
'amountcredit' => $accts->[$i]{'amountcredit'},
'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'},
'toggle' => $accts->[$i]{'toggle'},
use C4::Branch qw(GetBranches);
use List::MoreUtils qw/any uniq/;
use Koha::DateUtils;
-
-use C4::Dates qw/format_date/;
use C4::Members::Attributes qw(GetBorrowerAttributes);
my $input = CGI->new;
# barcode export
if ( $op eq 'export_barcodes' ) {
- my $today = C4::Dates->new();
- $today = $today->output('iso');
+ my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
my @barcodes =
map { $_->{barcode} } grep { $_->{returndate} =~ m/^$today/o } @{$issues};
my $borrowercardnumber =
use C4::Koha;
use C4::Circulation;
use C4::Output;
-use C4::Dates qw/format_date/;
use C4::Members;
use C4::Members::Messaging;
use C4::Branch;
use C4::Circulation;
use C4::Members;
use C4::Output;
-use C4::Dates;
my $query = new CGI;
if ($show_priority) {
$res->{'priority'} ||= '';
}
- $res->{'suspend_until'} = C4::Dates->new( $res->{'suspend_until'}, "iso")->output("syspref") if ( $res->{'suspend_until'} );
+ if ( $res->{'suspend_until'} ) {
+ $res->{'suspend_until'} = output_pref({ dt => dt_from_string( $res->{'suspend_until'} , 'iso' ), dateonly => 1 });
+ }
}
# use Data::Dumper;
use C4::Auth qw(:DEFAULT check_cookie_auth);
use C4::Biblio;
use C4::Context;
-use C4::Dates qw(format_date);
use C4::Items;
use C4::Koha;
use C4::Tags qw(get_tags remove_tag get_tag_rows);
use C4::Auth;
use C4::Koha;
use C4::Context;
-use C4::Dates qw(format_date_in_iso);
use C4::Output;
use C4::NewsChannels;
use C4::Languages qw(getTranslatedLanguages);
use Date::Calc qw/Date_to_Days Today/;
use C4::Branch qw/GetBranches/;
+use Koha::DateUtils;
my $cgi = new CGI;
my $id = $cgi->param('id');
my $title = $cgi->param('title');
my $new = $cgi->param('new');
-my $expirationdate = format_date_in_iso($cgi->param('expirationdate'));
-my $timestamp = format_date_in_iso($cgi->param('timestamp'));
+my $expirationdate = output_pref({ dt => dt_from_string( $cgi->param('expirationdate') ), dateformat => 'iso', dateonly => 1 });
+my $timestamp = output_pref({ dt => dt_from_string( $cgi->param('timestamp') ), dateformat => 'iso', dateonly => 1 });
my $number = $cgi->param('number');
my $lang = $cgi->param('lang');
my $branchcode = $cgi->param('branch');
use C4::Auth;
use CGI qw ( -utf8 );
use C4::Output;
-use C4::Dates;
+use Koha::DateUtils;;
use vars qw($debug);
if ( $mode eq 'job_add' ) {
# Retrieving the date according to the dateformat syspref
- my $c4date = C4::Dates->new($input->param('startdate'));
+ my $c4date = output_pref({ dt => dt_from_string( $input->param('startdate') ), dateformat => 'iso', dateonly => 1 });
# Formatting it for Schedule::At
- my $startdate = join('', (split /-/, $c4date->output("iso")));
+ my $startdate = join('', (split /-/, $c4date));
my $starttime = $input->param('starttime');
$starttime =~ s/\://g;
use Text::CSV::Encoded;
use C4::Context;
use C4::Koha;
-use C4::Dates;
use C4::Output;
use C4::Log;
use C4::Items;