View | Details | Raw Unified | Return to bug 28931
Collapse All | Expand All

(-)a/C4/Acquisition.pm (-2 / +2 lines)
Lines 1373-1379 sub ModReceiveOrder { Link Here
1373
    my $dbh = C4::Context->dbh;
1373
    my $dbh = C4::Context->dbh;
1374
    $datereceived = output_pref(
1374
    $datereceived = output_pref(
1375
        {
1375
        {
1376
            dt => ( $datereceived ? dt_from_string( $datereceived ) : dt_from_string ),
1376
            dt => ( $datereceived ? dt_from_string( $datereceived ) : dt_from_string() ),
1377
            dateformat => 'iso',
1377
            dateformat => 'iso',
1378
            dateonly => 1,
1378
            dateonly => 1,
1379
        }
1379
        }
Lines 2689-2695 sub CloseInvoice { Link Here
2689
2689
2690
Reopen an invoice
2690
Reopen an invoice
2691
2691
2692
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => output_pref({ dt=>dt_from_string, dateonly=>1, otputpref=>'iso' }))
2692
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => output_pref({ dt=>dt_from_string(), dateonly=>1, otputpref=>'iso' }))
2693
2693
2694
=cut
2694
=cut
2695
2695
(-)a/C4/Barcodes/annual.pm (-4 / +4 lines)
Lines 45-54 sub db_max { Link Here
45
        $iso = output_pref({ dt => dt_from_string( $input, 'iso' ), dateformat => 'iso', dateonly => 1 }); # try to set the date w/ 2nd arg
45
        $iso = output_pref({ dt => dt_from_string( $input, 'iso' ), dateformat => 'iso', dateonly => 1 }); # try to set the date w/ 2nd arg
46
		unless ($iso) {
46
		unless ($iso) {
47
			warn "Failed to create 'iso' Dates object with input '$input'.  Reverting to today's date.";
47
			warn "Failed to create 'iso' Dates object with input '$input'.  Reverting to today's date.";
48
            $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # failover back to today
48
            $iso = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); # failover back to today
49
		}
49
		}
50
	} else {
50
	} else {
51
        $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
51
        $iso = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 });
52
	}
52
	}
53
	my $year = substr($iso,0,4);	# YYYY
53
	my $year = substr($iso,0,4);	# YYYY
54
	$sth->execute("$year-%");
54
	$sth->execute("$year-%");
Lines 58-64 sub db_max { Link Here
58
58
59
sub initial () {
59
sub initial () {
60
	my $self = shift;
60
	my $self = shift;
61
    return substr(output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 0, 4 ) .'-'. sprintf('%'."$width.$width".'d', 1);
61
    return substr(output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }), 0, 4 ) .'-'. sprintf('%'."$width.$width".'d', 1);
62
}
62
}
63
63
64
sub parse {
64
sub parse {
Lines 78-84 sub width { Link Here
78
sub process_head {
78
sub process_head {
79
	my ($self,$head,$whole,$specific) = @_;
79
	my ($self,$head,$whole,$specific) = @_;
80
	$specific and return $head;	# if this is built off an existing barcode, just return the head unchanged.
80
	$specific and return $head;	# if this is built off an existing barcode, just return the head unchanged.
81
    return substr(output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 0, 4 ) . '-'; # else get new YYYY-
81
    return substr(output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }), 0, 4 ) . '-'; # else get new YYYY-
82
}
82
}
83
83
84
sub new_object {
84
sub new_object {
(-)a/C4/Barcodes/hbyymmincr.pm (-4 / +4 lines)
Lines 47-56 sub db_max { Link Here
47
                $iso = output_pref({ dt => dt_from_string( $input, 'iso' ), dateformat => 'iso', dateonly => 1 }); # try to set the date w/ 2nd arg
47
                $iso = output_pref({ dt => dt_from_string( $input, 'iso' ), dateformat => 'iso', dateonly => 1 }); # try to set the date w/ 2nd arg
48
                unless ($iso) {
48
                unless ($iso) {
49
                        warn "Failed to create 'iso' Dates object with input '$input'.  Reverting to today's date.";
49
                        warn "Failed to create 'iso' Dates object with input '$input'.  Reverting to today's date.";
50
                        $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });      # failover back to today
50
                        $iso = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 });      # failover back to today
51
                }
51
                }
52
        } else {
52
        } else {
53
                $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
53
                $iso = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 });
54
        }
54
        }
55
	my $year = substr($iso,2,2);    # i.e. "08" for 2008
55
	my $year = substr($iso,2,2);    # i.e. "08" for 2008
56
	my $andtwo = $width+2;
56
	my $andtwo = $width+2;
Lines 67-73 sub db_max { Link Here
67
sub initial {
67
sub initial {
68
	my $self = shift;
68
	my $self = shift;
69
	# FIXME: populated branch?
69
	# FIXME: populated branch?
70
    my $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # like "2008-07-02"
70
    my $iso = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); # like "2008-07-02"
71
    warn "HBYYMM Barcode was not passed a branch, default is blank" if ( $self->branch eq '' );
71
    warn "HBYYMM Barcode was not passed a branch, default is blank" if ( $self->branch eq '' );
72
    my $width = WIDTH;
72
    my $width = WIDTH;
73
	return $self->branch . substr($iso,2,2) . substr($iso,5,2) . sprintf('%' . "$width.$width" . 'd',1);
73
	return $self->branch . substr($iso,2,2) . substr($iso,5,2) . sprintf('%' . "$width.$width" . 'd',1);
Lines 101-107 sub process_head { # (self,head,whole,specific) Link Here
101
	my ($self,$head,$whole,$specific) = @_;
101
	my ($self,$head,$whole,$specific) = @_;
102
	$specific and return $head;	# if this is built off an existing barcode, just return the head unchanged.
102
	$specific and return $head;	# if this is built off an existing barcode, just return the head unchanged.
103
	$head =~ s/\d{4}$//;		# else strip the old yymm
103
	$head =~ s/\d{4}$//;		# else strip the old yymm
104
    my $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # like "2008-07-02"
104
    my $iso = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }); # like "2008-07-02"
105
	return $head . substr($iso,2,2) . substr($iso,5,2);
105
	return $head . substr($iso,2,2) . substr($iso,5,2);
106
}
106
}
107
107
(-)a/C4/Circulation.pm (-6 / +6 lines)
Lines 1502-1508 sub AddIssue { Link Here
1502
                # updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....)
1502
                # updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....)
1503
                $transfer->set(
1503
                $transfer->set(
1504
                    {
1504
                    {
1505
                        datearrived => dt_from_string,
1505
                        datearrived => dt_from_string(),
1506
                        tobranch    => C4::Context->userenv->{branch},
1506
                        tobranch    => C4::Context->userenv->{branch},
1507
                        comments    => 'Forced branchtransfer'
1507
                        comments    => 'Forced branchtransfer'
1508
                    }
1508
                    }
Lines 2802-2808 sub CanBookBeRenewed { Link Here
2802
                $maximum_renewal_date->add(
2802
                $maximum_renewal_date->add(
2803
                    $issuing_rule->{lengthunit} => $issuing_rule->{no_auto_renewal_after}
2803
                    $issuing_rule->{lengthunit} => $issuing_rule->{no_auto_renewal_after}
2804
                );
2804
                );
2805
                my $now = dt_from_string;
2805
                my $now = dt_from_string();
2806
                if ( $now >= $maximum_renewal_date ) {
2806
                if ( $now >= $maximum_renewal_date ) {
2807
                    return ( 0, "auto_too_late" );
2807
                    return ( 0, "auto_too_late" );
2808
                }
2808
                }
Lines 2810-2816 sub CanBookBeRenewed { Link Here
2810
            if ( defined $issuing_rule->{no_auto_renewal_after_hard_limit}
2810
            if ( defined $issuing_rule->{no_auto_renewal_after_hard_limit}
2811
                          and $issuing_rule->{no_auto_renewal_after_hard_limit} ne "" ) {
2811
                          and $issuing_rule->{no_auto_renewal_after_hard_limit} ne "" ) {
2812
                # If no_auto_renewal_after_hard_limit is >= today, it's also too late for renewal
2812
                # If no_auto_renewal_after_hard_limit is >= today, it's also too late for renewal
2813
                if ( dt_from_string >= dt_from_string( $issuing_rule->{no_auto_renewal_after_hard_limit} ) ) {
2813
                if ( dt_from_string() >= dt_from_string( $issuing_rule->{no_auto_renewal_after_hard_limit} ) ) {
2814
                    return ( 0, "auto_too_late" );
2814
                    return ( 0, "auto_too_late" );
2815
                }
2815
                }
2816
            }
2816
            }
Lines 2854-2860 sub CanBookBeRenewed { Link Here
2854
        # Fallback for automatic renewals:
2854
        # Fallback for automatic renewals:
2855
        # If norenewalbefore is undef, don't renew before due date.
2855
        # If norenewalbefore is undef, don't renew before due date.
2856
        if ( $issue->auto_renew && $auto_renew eq "no" && $patron->autorenew_checkouts ) {
2856
        if ( $issue->auto_renew && $auto_renew eq "no" && $patron->autorenew_checkouts ) {
2857
            my $now = dt_from_string;
2857
            my $now = dt_from_string();
2858
            if ( $now >= dt_from_string( $issue->date_due, 'sql' ) ){
2858
            if ( $now >= dt_from_string( $issue->date_due, 'sql' ) ){
2859
                $auto_renew = "ok";
2859
                $auto_renew = "ok";
2860
            } else {
2860
            } else {
Lines 3245-3251 sub GetSoonestRenewDate { Link Here
3245
        }
3245
        }
3246
    );
3246
    );
3247
3247
3248
    my $now = dt_from_string;
3248
    my $now = dt_from_string();
3249
    return $now unless $issuing_rule;
3249
    return $now unless $issuing_rule;
3250
3250
3251
    if ( defined $issuing_rule->{norenewalbefore}
3251
    if ( defined $issuing_rule->{norenewalbefore}
Lines 3586-3592 sub updateWrongTransfer { Link Here
3586
    # first step: cancel the original transfer
3586
    # first step: cancel the original transfer
3587
    my $item = Koha::Items->find($itemNumber);
3587
    my $item = Koha::Items->find($itemNumber);
3588
    my $transfer = $item->get_transfer;
3588
    my $transfer = $item->get_transfer;
3589
    $transfer->set({ datecancelled => dt_from_string, cancellation_reason => 'WrongTransfer' })->store();
3589
    $transfer->set({ datecancelled => dt_from_string(), cancellation_reason => 'WrongTransfer' })->store();
3590
3590
3591
    # second step: create a new transfer to the right location
3591
    # second step: create a new transfer to the right location
3592
    my $new_transfer = $item->request_transfer(
3592
    my $new_transfer = $item->request_transfer(
(-)a/C4/Items.pm (-2 / +2 lines)
Lines 395-401 The last optional parameter allows for passing skip_record_index through to the Link Here
395
sub ModDateLastSeen {
395
sub ModDateLastSeen {
396
    my ( $itemnumber, $leave_item_lost, $params ) = @_;
396
    my ( $itemnumber, $leave_item_lost, $params ) = @_;
397
397
398
    my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
398
    my $today = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 });
399
399
400
    my $item = Koha::Items->find($itemnumber);
400
    my $item = Koha::Items->find($itemnumber);
401
    $item->datelastseen($today);
401
    $item->datelastseen($today);
Lines 1610-1616 sub PrepareItemrecordDisplay { Link Here
1610
                } else {
1610
                } else {
1611
                    $defaultvalue =~ s/"/"/g;
1611
                    $defaultvalue =~ s/"/"/g;
1612
                    # get today date & replace <<YYYY>>, <<MM>>, <<DD>> if provided in the default value
1612
                    # get today date & replace <<YYYY>>, <<MM>>, <<DD>> if provided in the default value
1613
                    my $today_dt = dt_from_string;
1613
                    my $today_dt = dt_from_string();
1614
                    my $year     = $today_dt->strftime('%Y');
1614
                    my $year     = $today_dt->strftime('%Y');
1615
                    my $shortyear     = $today_dt->strftime('%y');
1615
                    my $shortyear     = $today_dt->strftime('%y');
1616
                    my $month    = $today_dt->strftime('%m');
1616
                    my $month    = $today_dt->strftime('%m');
(-)a/C4/Letters.pm (-1 / +1 lines)
Lines 1820-1826 sub _get_tt_params { Link Here
1820
        }
1820
        }
1821
    }
1821
    }
1822
1822
1823
    $params->{today} = output_pref({ dt => dt_from_string, dateformat => 'iso' });
1823
    $params->{today} = output_pref({ dt => dt_from_string(), dateformat => 'iso' });
1824
1824
1825
    return $params;
1825
    return $params;
1826
}
1826
}
(-)a/C4/Members.pm (-1 / +1 lines)
Lines 557-563 sub IssueSlip { Link Here
557
        );
557
        );
558
    }
558
    }
559
    else {
559
    else {
560
        my $today = Koha::Database->new->schema->storage->datetime_parser->format_datetime( dt_from_string );
560
        my $today = Koha::Database->new->schema->storage->datetime_parser->format_datetime( dt_from_string() );
561
        # Checkouts due in the future
561
        # Checkouts due in the future
562
        my $checkouts = $pending_checkouts->search({ date_due => { '>' => $today } });
562
        my $checkouts = $pending_checkouts->search({ date_due => { '>' => $today } });
563
        my @checkouts; my @overdues;
563
        my @checkouts; my @overdues;
(-)a/C4/Reports/Guided.pm (-2 / +2 lines)
Lines 624-630 sub save_report { Link Here
624
    my $public = $fields->{public};
624
    my $public = $fields->{public};
625
625
626
    $sql =~ s/(\s*\;\s*)$//;    # removes trailing whitespace and /;/
626
    $sql =~ s/(\s*\;\s*)$//;    # removes trailing whitespace and /;/
627
    my $now = dt_from_string;
627
    my $now = dt_from_string();
628
    my $report = Koha::Report->new(
628
    my $report = Koha::Report->new(
629
        {
629
        {
630
            borrowernumber  => $borrowernumber,
630
            borrowernumber  => $borrowernumber,
Lines 658-664 sub update_sql { Link Here
658
658
659
    $sql =~ s/(\s*\;\s*)$//;    # removes trailing whitespace and /;/
659
    $sql =~ s/(\s*\;\s*)$//;    # removes trailing whitespace and /;/
660
    my $report = Koha::Reports->find($id);
660
    my $report = Koha::Reports->find($id);
661
    $report->last_modified(dt_from_string);
661
    $report->last_modified(dt_from_string());
662
    $report->savedsql($sql);
662
    $report->savedsql($sql);
663
    $report->report_name($name);
663
    $report->report_name($name);
664
    $report->notes($notes);
664
    $report->notes($notes);
(-)a/C4/Reserves.pm (-1 / +1 lines)
Lines 195-201 sub AddReserve { Link Here
195
    my $non_priority   = $params->{non_priority};
195
    my $non_priority   = $params->{non_priority};
196
196
197
    $resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' })
197
    $resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' })
198
        or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
198
        or output_pref({ dt => dt_from_string(), dateonly => 1, dateformat => 'iso' });
199
199
200
    $expdate = output_pref({ str => $expdate, dateonly => 1, dateformat => 'iso' });
200
    $expdate = output_pref({ str => $expdate, dateonly => 1, dateformat => 'iso' });
201
201
(-)a/C4/Search/History.pm (-1 / +1 lines)
Lines 43-49 sub add_to_session { Link Here
43
    my $type       = $params->{type}                              || 'biblio';
43
    my $type       = $params->{type}                              || 'biblio';
44
44
45
    # To a cookie (the user is not logged in)
45
    # To a cookie (the user is not logged in)
46
    my $now = dt_from_string;
46
    my $now = dt_from_string();
47
    my $id = $now->year . $now->month . $now->day . $now->hour . $now->minute . $now->second . int(rand(100));
47
    my $id = $now->year . $now->month . $now->day . $now->hour . $now->minute . $now->second . int(rand(100));
48
    my @recent_searches = get_from_session( { cgi => $cgi } );
48
    my @recent_searches = get_from_session( { cgi => $cgi } );
49
    push @recent_searches, {
49
    push @recent_searches, {
(-)a/C4/Stats.pm (-1 / +1 lines)
Lines 127-133 sub UpdateStats { Link Here
127
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
127
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
128
    my $statistic = Koha::Statistic->new(
128
    my $statistic = Koha::Statistic->new(
129
        {
129
        {
130
            datetime       => $dtf->format_datetime( dt_from_string ),
130
            datetime       => $dtf->format_datetime( dt_from_string() ),
131
            branch         => $branch,
131
            branch         => $branch,
132
            type           => $type,
132
            type           => $type,
133
            value          => $amount,
133
            value          => $amount,
(-)a/C4/Suggestions.pm (-1 / +1 lines)
Lines 397-403 sub NewSuggestion { Link Here
397
397
398
    $suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS};
398
    $suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS};
399
399
400
    $suggestion->{suggesteddate} = dt_from_string unless $suggestion->{suggesteddate};
400
    $suggestion->{suggesteddate} = dt_from_string() unless $suggestion->{suggesteddate};
401
401
402
    delete $suggestion->{branchcode} if $suggestion->{branchcode} eq '';
402
    delete $suggestion->{branchcode} if $suggestion->{branchcode} eq '';
403
403
(-)a/Koha/Account/Line.pm (-2 / +2 lines)
Lines 1068-1074 sub store { Link Here
1068
            $max //= 0;
1068
            $max //= 0;
1069
            $self->credit_number($max + 1);
1069
            $self->credit_number($max + 1);
1070
        } elsif ($AutoCreditNumber eq 'annual') {
1070
        } elsif ($AutoCreditNumber eq 'annual') {
1071
            my $now = dt_from_string;
1071
            my $now = dt_from_string();
1072
            my $prefix = sprintf('%d-', $now->year);
1072
            my $prefix = sprintf('%d-', $now->year);
1073
            my $max = $rs->search({
1073
            my $max = $rs->search({
1074
                -and => [
1074
                -and => [
Lines 1083-1089 sub store { Link Here
1083
            my $userenv = C4::Context->userenv;
1083
            my $userenv = C4::Context->userenv;
1084
            if ($userenv) {
1084
            if ($userenv) {
1085
                my $branch = $userenv->{branch};
1085
                my $branch = $userenv->{branch};
1086
                my $now = dt_from_string;
1086
                my $now = dt_from_string();
1087
                my $prefix = sprintf('%s%d%02d', $branch, $now->year, $now->month);
1087
                my $prefix = sprintf('%s%d%02d', $branch, $now->year, $now->month);
1088
                my $pattern = $prefix;
1088
                my $pattern = $prefix;
1089
                $pattern =~ s/([\?%_])/\\$1/g;
1089
                $pattern =~ s/([\?%_])/\\$1/g;
(-)a/Koha/Acquisition/Order.pm (-3 / +3 lines)
Lines 87-93 sub store { Link Here
87
    }
87
    }
88
88
89
    $self->quantityreceived(0) unless $self->quantityreceived;
89
    $self->quantityreceived(0) unless $self->quantityreceived;
90
    $self->entrydate(dt_from_string) unless $self->entrydate;
90
    $self->entrydate(dt_from_string()) unless $self->entrydate;
91
91
92
    $self->ordernumber(undef) unless $self->ordernumber;
92
    $self->ordernumber(undef) unless $self->ordernumber;
93
    $self = $self->SUPER::store( $self );
93
    $self = $self->SUPER::store( $self );
Lines 428-435 sub duplicate_to { Link Here
428
            {
428
            {
429
                undef $order_info->{$field};
429
                undef $order_info->{$field};
430
            }
430
            }
431
            $order_info->{placed_on}        = dt_from_string;
431
            $order_info->{placed_on}        = dt_from_string();
432
            $order_info->{entrydate}        = dt_from_string;
432
            $order_info->{entrydate}        = dt_from_string();
433
            $order_info->{orderstatus}      = 'new';
433
            $order_info->{orderstatus}      = 'new';
434
            $order_info->{quantityreceived} = 0;
434
            $order_info->{quantityreceived} = 0;
435
            while ( my ( $field, $value ) = each %$default_values ) {
435
            while ( my ( $field, $value ) = each %$default_values ) {
(-)a/Koha/Acquisition/Orders.pm (-1 / +1 lines)
Lines 79-85 sub filter_by_lates { Link Here
79
        push @delivery_time_conditions, \[ "$date_add <= ?", $dtf->format_date($estimated_to) ];
79
        push @delivery_time_conditions, \[ "$date_add <= ?", $dtf->format_date($estimated_to) ];
80
    }
80
    }
81
    if ( defined $estimated_from and not defined $estimated_to ) {
81
    if ( defined $estimated_from and not defined $estimated_to ) {
82
        push @delivery_time_conditions, \[ "$date_add <= ?", $dtf->format_date(dt_from_string) ];
82
        push @delivery_time_conditions, \[ "$date_add <= ?", $dtf->format_date(dt_from_string()) ];
83
    }
83
    }
84
84
85
    $self->search(
85
    $self->search(
(-)a/Koha/Authority/MergeRequests.pm (-2 / +2 lines)
Lines 62-75 sub cron_cleanup { Link Here
62
    my $remove_days = $params->{remove_days} || 30;
62
    my $remove_days = $params->{remove_days} || 30;
63
    my $parser = Koha::Database->new->schema->storage->datetime_parser;
63
    my $parser = Koha::Database->new->schema->storage->datetime_parser;
64
64
65
    my $dt = dt_from_string;
65
    my $dt = dt_from_string();
66
    $dt->subtract( hours => $reset_hours );
66
    $dt->subtract( hours => $reset_hours );
67
    $class_or_self->search({
67
    $class_or_self->search({
68
        done => 2,
68
        done => 2,
69
        timestamp => { '<' => $parser->format_datetime($dt) },
69
        timestamp => { '<' => $parser->format_datetime($dt) },
70
    })->update({ done => 0 });
70
    })->update({ done => 0 });
71
71
72
    $dt = dt_from_string;
72
    $dt = dt_from_string();
73
    $dt->subtract( days => $remove_days );
73
    $dt->subtract( days => $remove_days );
74
    $class_or_self->search({
74
    $class_or_self->search({
75
        done => 1,
75
        done => 1,
(-)a/Koha/BackgroundJob.pm (-1 / +1 lines)
Lines 110-116 sub enqueue { Link Here
110
                    type           => $job_type,
110
                    type           => $job_type,
111
                    size           => $job_size,
111
                    size           => $job_size,
112
                    data           => $json_args,
112
                    data           => $json_args,
113
                    enqueued_on    => dt_from_string,
113
                    enqueued_on    => dt_from_string(),
114
                    borrowernumber => $borrowernumber,
114
                    borrowernumber => $borrowernumber,
115
                }
115
                }
116
            )->store;
116
            )->store;
(-)a/Koha/BackgroundJob/BatchUpdateAuthority.pm (-2 / +2 lines)
Lines 62-68 sub process { Link Here
62
    }
62
    }
63
63
64
    my $job_progress = 0;
64
    my $job_progress = 0;
65
    $job->started_on(dt_from_string)
65
    $job->started_on(dt_from_string())
66
        ->progress($job_progress)
66
        ->progress($job_progress)
67
        ->status('started')
67
        ->status('started')
68
        ->store;
68
        ->store;
Lines 107-113 sub process { Link Here
107
    $job_data->{messages} = \@messages;
107
    $job_data->{messages} = \@messages;
108
    $job_data->{report} = $report;
108
    $job_data->{report} = $report;
109
109
110
    $job->ended_on(dt_from_string)
110
    $job->ended_on(dt_from_string())
111
        ->data(encode_json $job_data);
111
        ->data(encode_json $job_data);
112
    $job->status('finished') if $job->status ne 'cancelled';
112
    $job->status('finished') if $job->status ne 'cancelled';
113
    $job->store;
113
    $job->store;
(-)a/Koha/BackgroundJob/BatchUpdateBiblio.pm (-2 / +2 lines)
Lines 64-70 sub process { Link Here
64
    # Then we will start from scratch and so double process the same records
64
    # Then we will start from scratch and so double process the same records
65
65
66
    my $job_progress = 0;
66
    my $job_progress = 0;
67
    $job->started_on(dt_from_string)
67
    $job->started_on(dt_from_string())
68
        ->progress($job_progress)
68
        ->progress($job_progress)
69
        ->status('started')
69
        ->status('started')
70
        ->store;
70
        ->store;
Lines 112-118 sub process { Link Here
112
    $job_data->{messages} = \@messages;
112
    $job_data->{messages} = \@messages;
113
    $job_data->{report} = $report;
113
    $job_data->{report} = $report;
114
114
115
    $job->ended_on(dt_from_string)
115
    $job->ended_on(dt_from_string())
116
        ->data(encode_json $job_data);
116
        ->data(encode_json $job_data);
117
    $job->status('finished') if $job->status ne 'cancelled';
117
    $job->status('finished') if $job->status ne 'cancelled';
118
    $job->store;
118
    $job->store;
(-)a/Koha/Biblio.pm (-2 / +2 lines)
Lines 61-67 Overloaded I<store> method to set default values Link Here
61
sub store {
61
sub store {
62
    my ( $self ) = @_;
62
    my ( $self ) = @_;
63
63
64
    $self->datecreated( dt_from_string ) unless $self->datecreated;
64
    $self->datecreated( dt_from_string() ) unless $self->datecreated;
65
65
66
    return $self->SUPER::store;
66
    return $self->SUPER::store;
67
}
67
}
Lines 461-467 sub current_holds { Link Here
461
    my ($self) = @_;
461
    my ($self) = @_;
462
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
462
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
463
    return $self->holds(
463
    return $self->holds(
464
        { reservedate => { '<=' => $dtf->format_date(dt_from_string) } } );
464
        { reservedate => { '<=' => $dtf->format_date(dt_from_string()) } } );
465
}
465
}
466
466
467
=head3 biblioitem
467
=head3 biblioitem
(-)a/Koha/Checkout.pm (-1 / +1 lines)
Lines 174-180 sub claim_returned { Link Here
174
                        borrowernumber => $self->borrowernumber,
174
                        borrowernumber => $self->borrowernumber,
175
                        notes          => $params->{notes},
175
                        notes          => $params->{notes},
176
                        created_by     => $params->{created_by},
176
                        created_by     => $params->{created_by},
177
                        created_on     => dt_from_string,
177
                        created_on     => dt_from_string(),
178
                    }
178
                    }
179
                )->store();
179
                )->store();
180
180
(-)a/Koha/Checkouts.pm (-2 / +2 lines)
Lines 56-62 sub calculate_dropbox_date { Link Here
56
        }
56
        }
57
    );
57
    );
58
    my $calendar     = Koha::Calendar->new( branchcode => $branchcode, days_mode => $daysmode );
58
    my $calendar     = Koha::Calendar->new( branchcode => $branchcode, days_mode => $daysmode );
59
    my $today        = dt_from_string;
59
    my $today        = dt_from_string();
60
    my $dropbox_date = $calendar->addDuration( $today, -1 );
60
    my $dropbox_date = $calendar->addDuration( $today, -1 );
61
61
62
    return $dropbox_date;
62
    return $dropbox_date;
Lines 73-79 Checks in every due issue which itemtype has automatic_checkin enabled Link Here
73
sub automatic_checkin {
73
sub automatic_checkin {
74
    my ($self, $params) = @_;
74
    my ($self, $params) = @_;
75
75
76
    my $current_date = dt_from_string;
76
    my $current_date = dt_from_string();
77
77
78
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
78
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
79
    my $due_checkouts = $self->search(
79
    my $due_checkouts = $self->search(
(-)a/Koha/Club/Enrollment.pm (-1 / +1 lines)
Lines 82-88 sub is_canceled { Link Here
82
    my ( $self ) = @_;
82
    my ( $self ) = @_;
83
83
84
    return 0 unless $self->date_canceled;
84
    return 0 unless $self->date_canceled;
85
    my $today = dt_from_string;
85
    my $today = dt_from_string();
86
    my $date_canceled = dt_from_string( $self->date_canceled );
86
    my $date_canceled = dt_from_string( $self->date_canceled );
87
87
88
    return DateTime->compare($date_canceled, $today) < 1;
88
    return DateTime->compare($date_canceled, $today) < 1;
(-)a/Koha/DateUtils.pm (-5 / +11 lines)
Lines 21-31 use DateTime; Link Here
21
use C4::Context;
21
use C4::Context;
22
use Koha::Exceptions;
22
use Koha::Exceptions;
23
23
24
use base 'Exporter';
24
use vars qw(@ISA @EXPORT_OK);
25
25
BEGIN {
26
our @EXPORT = (
26
    require Exporter;
27
    qw( dt_from_string output_pref format_sqldatetime )
27
    @ISA = qw(Exporter);
28
);
28
29
    @EXPORT_OK = qw(
30
        dt_from_string
31
        output_pref
32
        format_sqldatetime
33
    );
34
}
29
35
30
=head1 DateUtils
36
=head1 DateUtils
31
37
(-)a/Koha/Hold.pm (-1 / +1 lines)
Lines 62-68 my $age = $hold->age( $use_calendar ); Link Here
62
sub age {
62
sub age {
63
    my ( $self, $use_calendar ) = @_;
63
    my ( $self, $use_calendar ) = @_;
64
64
65
    my $today = dt_from_string;
65
    my $today = dt_from_string();
66
    my $age;
66
    my $age;
67
67
68
    if ( $use_calendar ) {
68
    if ( $use_calendar ) {
(-)a/Koha/Item.pm (-3 / +3 lines)
Lines 89-95 sub store { Link Here
89
        $self->itype($self->biblio->biblioitem->itemtype);
89
        $self->itype($self->biblio->biblioitem->itemtype);
90
    }
90
    }
91
91
92
    my $today  = dt_from_string;
92
    my $today  = dt_from_string();
93
    my $action = 'create';
93
    my $action = 'create';
94
94
95
    unless ( $self->in_storage ) { #AddItem
95
    unless ( $self->in_storage ) { #AddItem
Lines 461-467 sub request_transfer { Link Here
461
    my $transfer = Koha::Item::Transfer->new(
461
    my $transfer = Koha::Item::Transfer->new(
462
        {
462
        {
463
            itemnumber    => $self->itemnumber,
463
            itemnumber    => $self->itemnumber,
464
            daterequested => dt_from_string,
464
            daterequested => dt_from_string(),
465
            frombranch    => $self->holdingbranch,
465
            frombranch    => $self->holdingbranch,
466
            tobranch      => $params->{to}->branchcode,
466
            tobranch      => $params->{to}->branchcode,
467
            reason        => $params->{reason},
467
            reason        => $params->{reason},
Lines 793-799 sub current_holds { Link Here
793
        itemnumber => $self->itemnumber,
793
        itemnumber => $self->itemnumber,
794
        suspend => 0,
794
        suspend => 0,
795
        -or => [
795
        -or => [
796
            reservedate => { '<=' => $dtf->format_date(dt_from_string) },
796
            reservedate => { '<=' => $dtf->format_date(dt_from_string()) },
797
            waitingdate => { '!=' => undef },
797
            waitingdate => { '!=' => undef },
798
        ],
798
        ],
799
    };
799
    };
(-)a/Koha/Item/Transfer.pm (-3 / +3 lines)
Lines 103-109 sub transit { Link Here
103
    $self->set(
103
    $self->set(
104
        {
104
        {
105
            frombranch => $self->item->holdingbranch,
105
            frombranch => $self->item->holdingbranch,
106
            datesent   => dt_from_string,
106
            datesent   => dt_from_string(),
107
        }
107
        }
108
    )->store;
108
    )->store;
109
109
Lines 139-145 sub receive { Link Here
139
    Koha::Exceptions::Item::Transfer::OnLoan->throw() if ($self->item->checkout);
139
    Koha::Exceptions::Item::Transfer::OnLoan->throw() if ($self->item->checkout);
140
140
141
    # Update the arrived date
141
    # Update the arrived date
142
    $self->set({ datearrived => dt_from_string })->store;
142
    $self->set({ datearrived => dt_from_string() })->store;
143
143
144
    ModDateLastSeen( $self->item->itemnumber );
144
    ModDateLastSeen( $self->item->itemnumber );
145
    return $self;
145
    return $self;
Lines 165-171 sub cancel { Link Here
165
165
166
    # Update the cancelled date
166
    # Update the cancelled date
167
    $self->set(
167
    $self->set(
168
        { datecancelled => dt_from_string, cancellation_reason => $params->{reason} } )
168
        { datecancelled => dt_from_string(), cancellation_reason => $params->{reason} } )
169
      ->store;
169
      ->store;
170
170
171
    return $self;
171
    return $self;
(-)a/Koha/Objects.pm (-1 / +1 lines)
Lines 276-282 sub filter_by_last_update { Link Here
276
276
277
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
277
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
278
    if ( exists $params->{days} ) {
278
    if ( exists $params->{days} ) {
279
        my $dt = Koha::DateUtils::dt_from_string();
279
        my $dt = dt_from_string();
280
        my $operator = $days_inclusive ? '<=' : '<';
280
        my $operator = $days_inclusive ? '<=' : '<';
281
        $conditions->{$operator} = $dtf->format_date( $dt->subtract( days => $params->{days} ) );
281
        $conditions->{$operator} = $dtf->format_date( $dt->subtract( days => $params->{days} ) );
282
    }
282
    }
(-)a/Koha/Old/Checkouts.pm (-1 / +1 lines)
Lines 27-33 sub filter_by_todays_checkins { Link Here
27
    my ( $self ) = @_;
27
    my ( $self ) = @_;
28
28
29
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
29
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
30
    my $today = dt_from_string;
30
    my $today = dt_from_string();
31
    my $today_start = $today->clone->set( hour =>  0, minute =>  0, second =>  0 );
31
    my $today_start = $today->clone->set( hour =>  0, minute =>  0, second =>  0 );
32
    my $today_end   = $today->clone->set( hour => 23, minute => 59, second => 59 );
32
    my $today_end   = $today->clone->set( hour => 23, minute => 59, second => 59 );
33
    $today_start = $dtf->format_datetime( $today_start );
33
    $today_start = $dtf->format_datetime( $today_start );
(-)a/Koha/Patron.pm (-8 / +8 lines)
Lines 218-224 sub store { Link Here
218
218
219
                # Add enrollment date if it isn't already there
219
                # Add enrollment date if it isn't already there
220
                unless ( $self->dateenrolled ) {
220
                unless ( $self->dateenrolled ) {
221
                    $self->dateenrolled(dt_from_string);
221
                    $self->dateenrolled(dt_from_string());
222
                }
222
                }
223
223
224
                # Set the privacy depending on the patron's category
224
                # Set the privacy depending on the patron's category
Lines 747-753 sub is_debarred { Link Here
747
    return unless $self->debarred;
747
    return unless $self->debarred;
748
    return $self->debarred
748
    return $self->debarred
749
      if $self->debarred =~ '^9999'
749
      if $self->debarred =~ '^9999'
750
      or dt_from_string( $self->debarred ) > dt_from_string;
750
      or dt_from_string( $self->debarred ) > dt_from_string();
751
    return;
751
    return;
752
}
752
}
753
753
Lines 890-901 sub renew_account { Link Here
890
    my ($self) = @_;
890
    my ($self) = @_;
891
    my $date;
891
    my $date;
892
    if ( C4::Context->preference('BorrowerRenewalPeriodBase') eq 'combination' ) {
892
    if ( C4::Context->preference('BorrowerRenewalPeriodBase') eq 'combination' ) {
893
        $date = ( dt_from_string gt dt_from_string( $self->dateexpiry ) ) ? dt_from_string : dt_from_string( $self->dateexpiry );
893
        $date = ( dt_from_string() gt dt_from_string( $self->dateexpiry ) ) ? dt_from_string() : dt_from_string( $self->dateexpiry );
894
    } else {
894
    } else {
895
        $date =
895
        $date =
896
            C4::Context->preference('BorrowerRenewalPeriodBase') eq 'dateexpiry'
896
            C4::Context->preference('BorrowerRenewalPeriodBase') eq 'dateexpiry'
897
            ? dt_from_string( $self->dateexpiry )
897
            ? dt_from_string( $self->dateexpiry )
898
            : dt_from_string;
898
            : dt_from_string();
899
    }
899
    }
900
    my $expiry_date = $self->category->get_expiry_date($date);
900
    my $expiry_date = $self->category->get_expiry_date($date);
901
901
Lines 1120-1126 sub get_overdues { Link Here
1120
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
1120
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
1121
    return $self->checkouts->search(
1121
    return $self->checkouts->search(
1122
        {
1122
        {
1123
            'me.date_due' => { '<' => $dtf->format_datetime(dt_from_string) },
1123
            'me.date_due' => { '<' => $dtf->format_datetime(dt_from_string()) },
1124
        },
1124
        },
1125
        {
1125
        {
1126
            prefetch => { item => { biblio => 'biblioitems' } },
1126
            prefetch => { item => { biblio => 'biblioitems' } },
Lines 1152-1158 Return the age of the patron Link Here
1152
1152
1153
sub get_age {
1153
sub get_age {
1154
    my ($self)    = @_;
1154
    my ($self)    = @_;
1155
    my $today_str = dt_from_string->strftime("%Y-%m-%d");
1155
    my $today_str = dt_from_string()->strftime("%Y-%m-%d");
1156
    return unless $self->dateofbirth;
1156
    return unless $self->dateofbirth;
1157
    my $dob_str   = dt_from_string( $self->dateofbirth )->strftime("%Y-%m-%d");
1157
    my $dob_str   = dt_from_string( $self->dateofbirth )->strftime("%Y-%m-%d");
1158
1158
Lines 1648-1654 sub lock { Link Here
1648
    my ( $self, $params ) = @_;
1648
    my ( $self, $params ) = @_;
1649
    $self->login_attempts( ADMINISTRATIVE_LOCKOUT );
1649
    $self->login_attempts( ADMINISTRATIVE_LOCKOUT );
1650
    if( $params->{expire} ) {
1650
    if( $params->{expire} ) {
1651
        $self->dateexpiry( dt_from_string->subtract(days => 1) );
1651
        $self->dateexpiry( dt_from_string()->subtract(days => 1) );
1652
    }
1652
    }
1653
    $self->store;
1653
    $self->store;
1654
    if( $params->{remove} ) {
1654
    if( $params->{remove} ) {
Lines 1703-1709 sub _anonymize_column { Link Here
1703
    } elsif( $type =~ /integer|int$|float|dec|double/ ) {
1703
    } elsif( $type =~ /integer|int$|float|dec|double/ ) {
1704
        $val = $nullable ? undef : 0;
1704
        $val = $nullable ? undef : 0;
1705
    } elsif( $type =~ /date|time/ ) {
1705
    } elsif( $type =~ /date|time/ ) {
1706
        $val = $nullable ? undef : dt_from_string;
1706
        $val = $nullable ? undef : dt_from_string();
1707
    }
1707
    }
1708
    $self->$col($val);
1708
    $self->$col($val);
1709
}
1709
}
(-)a/Koha/Patron/Category.pm (-1 / +1 lines)
Lines 105-111 sub default_messaging { Link Here
105
sub get_expiry_date {
105
sub get_expiry_date {
106
    my ($self, $date ) = @_;
106
    my ($self, $date ) = @_;
107
    if ( $self->enrolmentperiod ) {
107
    if ( $self->enrolmentperiod ) {
108
        $date ||= dt_from_string;
108
        $date ||= dt_from_string();
109
        $date = dt_from_string( $date ) unless ref $date;
109
        $date = dt_from_string( $date ) unless ref $date;
110
        return $date->add( months => $self->enrolmentperiod, end_of_month => 'limit' );
110
        return $date->add( months => $self->enrolmentperiod, end_of_month => 'limit' );
111
    } else {
111
    } else {
(-)a/Koha/Patron/Discharge.pm (-3 / +3 lines)
Lines 66-72 sub request { Link Here
66
    my $rs = Koha::Database->new->schema->resultset('Discharge');
66
    my $rs = Koha::Database->new->schema->resultset('Discharge');
67
    return $rs->create({
67
    return $rs->create({
68
        borrower => $borrowernumber,
68
        borrower => $borrowernumber,
69
        needed   => dt_from_string,
69
        needed   => dt_from_string(),
70
    });
70
    });
71
}
71
}
72
72
Lines 92-103 sub discharge { Link Here
92
    my $rs = Koha::Database->new->schema->resultset('Discharge');
92
    my $rs = Koha::Database->new->schema->resultset('Discharge');
93
    my $discharge = $rs->search({ borrower => $borrowernumber }, { order_by => { -desc => 'needed' }, rows => 1 });
93
    my $discharge = $rs->search({ borrower => $borrowernumber }, { order_by => { -desc => 'needed' }, rows => 1 });
94
    if( $discharge->count > 0 ) {
94
    if( $discharge->count > 0 ) {
95
        $discharge->update({ validated => dt_from_string });
95
        $discharge->update({ validated => dt_from_string() });
96
    }
96
    }
97
    else {
97
    else {
98
        $rs->create({
98
        $rs->create({
99
            borrower  => $borrowernumber,
99
            borrower  => $borrowernumber,
100
            validated => dt_from_string,
100
            validated => dt_from_string(),
101
        });
101
        });
102
    }
102
    }
103
}
103
}
(-)a/Koha/Patrons.pm (-4 / +4 lines)
Lines 112-119 sub search_upcoming_membership_expires { Link Here
112
    delete $params->{after};
112
    delete $params->{after};
113
113
114
    my $days = C4::Context->preference("MembershipExpiryDaysNotice") || 0;
114
    my $days = C4::Context->preference("MembershipExpiryDaysNotice") || 0;
115
    my $date_before = dt_from_string->add( days => $days - $before );
115
    my $date_before = dt_from_string()->add( days => $days - $before );
116
    my $date_after = dt_from_string->add( days => $days + $after );
116
    my $date_after = dt_from_string()->add( days => $days + $after );
117
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
117
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
118
118
119
    $params->{dateexpiry} = {
119
    $params->{dateexpiry} = {
Lines 137-143 sub search_patrons_to_anonymise { Link Here
137
    my ( $class, $params ) = @_;
137
    my ( $class, $params ) = @_;
138
    my $older_than_date = $params->{before};
138
    my $older_than_date = $params->{before};
139
    my $library         = $params->{library};
139
    my $library         = $params->{library};
140
    $older_than_date = $older_than_date ? dt_from_string($older_than_date) : dt_from_string;
140
    $older_than_date = $older_than_date ? dt_from_string($older_than_date) : dt_from_string();
141
    $library ||=
141
    $library ||=
142
      ( C4::Context->preference('IndependentBranches') && C4::Context->userenv && !C4::Context->IsSuperLibrarian() && C4::Context->userenv->{branch} )
142
      ( C4::Context->preference('IndependentBranches') && C4::Context->userenv && !C4::Context->IsSuperLibrarian() && C4::Context->userenv->{branch} )
143
      ? C4::Context->userenv->{branch}
143
      ? C4::Context->userenv->{branch}
Lines 174-180 sub anonymise_issue_history { Link Here
174
174
175
    my $older_than_date = $params->{before};
175
    my $older_than_date = $params->{before};
176
176
177
    $older_than_date = dt_from_string $older_than_date if $older_than_date;
177
    $older_than_date = dt_from_string( $older_than_date ) if $older_than_date;
178
178
179
    # The default of 0 does not work due to foreign key constraints
179
    # The default of 0 does not work due to foreign key constraints
180
    # The anonymisation should not fail quietly if AnonymousPatron is not a valid entry
180
    # The anonymisation should not fail quietly if AnonymousPatron is not a valid entry
(-)a/Koha/Quotes.pm (-1 / +1 lines)
Lines 69-75 sub get_daily_quote { Link Here
69
        # Fall through... we also return a random quote as a catch-all if all else fails
69
        # Fall through... we also return a random quote as a catch-all if all else fails
70
    }
70
    }
71
    else {
71
    else {
72
        my $dt = $dtf->format_date(dt_from_string);
72
        my $dt = $dtf->format_date(dt_from_string());
73
        $quote = $self->search(
73
        $quote = $self->search(
74
            {
74
            {
75
                timestamp => { -between => => [ "$dt 00:00:00", "$dt 23:59:59" ] },
75
                timestamp => { -between => => [ "$dt 00:00:00", "$dt 23:59:59" ] },
(-)a/Koha/StockRotationItem.pm (-1 / +1 lines)
Lines 312-318 sub toggle_indemand { Link Here
312
            $item->homebranch($new_stage->branchcode_id)->store; # Revert update homebranch
312
            $item->homebranch($new_stage->branchcode_id)->store; # Revert update homebranch
313
            $new_indemand = 0;                                   # Reset indemand
313
            $new_indemand = 0;                                   # Reset indemand
314
            $transfer->tobranch($new_stage->branchcode_id);      # Reset StockrotationAdvance
314
            $transfer->tobranch($new_stage->branchcode_id);      # Reset StockrotationAdvance
315
            $transfer->datearrived(dt_from_string);              # Reset StockrotationAdvance
315
            $transfer->datearrived(dt_from_string());              # Reset StockrotationAdvance
316
            $transfer->store;
316
            $transfer->store;
317
        }
317
        }
318
    }
318
    }
(-)a/Koha/Virtualshelf.pm (-3 / +3 lines)
Lines 64-70 sub store { Link Here
64
    $self->allow_change_from_others( 0 )
64
    $self->allow_change_from_others( 0 )
65
        unless defined $self->allow_change_from_others;
65
        unless defined $self->allow_change_from_others;
66
66
67
    $self->created_on( dt_from_string )
67
    $self->created_on( dt_from_string() )
68
        unless defined $self->created_on;
68
        unless defined $self->created_on;
69
69
70
    return $self->SUPER::store( $self );
70
    return $self->SUPER::store( $self );
Lines 135-141 sub share { Link Here
135
        {
135
        {
136
            shelfnumber => $self->shelfnumber,
136
            shelfnumber => $self->shelfnumber,
137
            invitekey => $key,
137
            invitekey => $key,
138
            sharedate => dt_from_string,
138
            sharedate => dt_from_string(),
139
        }
139
        }
140
    )->store;
140
    )->store;
141
}
141
}
Lines 193-199 sub add_biblio { Link Here
193
            borrowernumber => $borrowernumber,
193
            borrowernumber => $borrowernumber,
194
        }
194
        }
195
    )->store;
195
    )->store;
196
    $self->lastmodified(dt_from_string);
196
    $self->lastmodified(dt_from_string());
197
    $self->store;
197
    $self->store;
198
198
199
    return $content;
199
    return $content;
(-)a/Koha/Virtualshelfshare.pm (-2 / +2 lines)
Lines 59-65 sub accept { Link Here
59
        return $search->next;
59
        return $search->next;
60
    } else {
60
    } else {
61
        $self->invitekey(undef);
61
        $self->invitekey(undef);
62
        $self->sharedate(dt_from_string);
62
        $self->sharedate(dt_from_string());
63
        $self->borrowernumber($borrowernumber);
63
        $self->borrowernumber($borrowernumber);
64
        $self->store;
64
        $self->store;
65
        return $self;
65
        return $self;
Lines 69-75 sub accept { Link Here
69
sub has_expired {
69
sub has_expired {
70
    my ($self) = @_;
70
    my ($self) = @_;
71
    my $dt_sharedate     = dt_from_string( $self->sharedate, 'sql' );
71
    my $dt_sharedate     = dt_from_string( $self->sharedate, 'sql' );
72
    my $today            = dt_from_string;
72
    my $today            = dt_from_string();
73
    my $expiration_delay = DateTime::Duration->new( days => SHARE_INVITATION_EXPIRY_DAYS );
73
    my $expiration_delay = DateTime::Duration->new( days => SHARE_INVITATION_EXPIRY_DAYS );
74
    my $has_expired = DateTime->compare( $today, $dt_sharedate->add_duration($expiration_delay) );
74
    my $has_expired = DateTime->compare( $today, $dt_sharedate->add_duration($expiration_delay) );
75
    # Note: has_expired = 0 if the share expires today
75
    # Note: has_expired = 0 if the share expires today
(-)a/Koha/pdfformat/layout2pages.pm (-1 / +1 lines)
Lines 164-170 sub printhead { Link Here
164
    $text->text($basketgroup->{'id'});
164
    $text->text($basketgroup->{'id'});
165
    
165
    
166
    # print the date
166
    # print the date
167
    my $today = output_pref({ dt => dt_from_string, dateonly => 1 });
167
    my $today = output_pref({ dt => dt_from_string(), dateonly => 1 });
168
    $text->translate(130/mm,  ($height-5-48)/mm);
168
    $text->translate(130/mm,  ($height-5-48)/mm);
169
    $text->text($today);
169
    $text->text($today);
170
    
170
    
(-)a/Koha/pdfformat/layout2pagesde.pm (-1 / +1 lines)
Lines 163-169 sub printhead { Link Here
163
    $text->text($basketgroup->{'id'});
163
    $text->text($basketgroup->{'id'});
164
    
164
    
165
    # print the date
165
    # print the date
166
    my $today = output_pref({ dt => dt_from_string, dateonly => 1 });
166
    my $today = output_pref({ dt => dt_from_string(), dateonly => 1 });
167
    $text->translate(130/mm,  ($height-5-48)/mm);
167
    $text->translate(130/mm,  ($height-5-48)/mm);
168
    $text->text($today);
168
    $text->text($today);
169
    
169
    
(-)a/Koha/pdfformat/layout3pages.pm (-1 / +1 lines)
Lines 331-337 sub printhead { Link Here
331
    $text->text($basketgroup->{'id'});
331
    $text->text($basketgroup->{'id'});
332
    
332
    
333
    # print the date
333
    # print the date
334
    my $today = output_pref({ dt => dt_from_string, dateonly => 1 });
334
    my $today = output_pref({ dt => dt_from_string(), dateonly => 1 });
335
    $text->translate(130/mm,  ($height-5-48)/mm);
335
    $text->translate(130/mm,  ($height-5-48)/mm);
336
    $text->text($today);
336
    $text->text($today);
337
    
337
    
(-)a/Koha/pdfformat/layout3pagesfr.pm (-1 / +1 lines)
Lines 333-339 sub printhead { Link Here
333
    $text->text($basketgroup->{'id'});
333
    $text->text($basketgroup->{'id'});
334
334
335
    # print the date
335
    # print the date
336
    my $today = output_pref({ dt => dt_from_string, dateonly => 1 });
336
    my $today = output_pref({ dt => dt_from_string(), dateonly => 1 });
337
    $text->translate(130/mm,  ($height-5-48)/mm);
337
    $text->translate(130/mm,  ($height-5-48)/mm);
338
    $text->text($today);
338
    $text->text($today);
339
339
(-)a/acqui/duplicate_orders.pl (-2 / +2 lines)
Lines 68-76 my $filters = { Link Here
68
};
68
};
69
69
70
my $from_placed_on =
70
my $from_placed_on =
71
  eval { dt_from_string( scalar $input->param('from') ) } || dt_from_string;
71
  eval { dt_from_string( scalar $input->param('from') ) } || dt_from_string();
72
my $to_placed_on =
72
my $to_placed_on =
73
  eval { dt_from_string( scalar $input->param('to') )   } || dt_from_string;
73
  eval { dt_from_string( scalar $input->param('to') )   } || dt_from_string();
74
74
75
unless ( $input->param('from') ) {
75
unless ( $input->param('from') ) {
76
    # Fill the form with year-1
76
    # Fill the form with year-1
(-)a/acqui/histsearch.pl (-2 / +2 lines)
Lines 89-96 my $filters = { Link Here
89
    managing_library        => scalar $input->param('managing_library'),
89
    managing_library        => scalar $input->param('managing_library'),
90
};
90
};
91
91
92
my $from_placed_on = eval { dt_from_string( scalar $input->param('from') ) } || dt_from_string;
92
my $from_placed_on = eval { dt_from_string( scalar $input->param('from') ) } || dt_from_string();
93
my $to_placed_on   = eval { dt_from_string( scalar $input->param('to')   ) } || dt_from_string;
93
my $to_placed_on   = eval { dt_from_string( scalar $input->param('to')   ) } || dt_from_string();
94
unless ( $input->param('from') ) {
94
unless ( $input->param('from') ) {
95
    # Fill the form with year-1
95
    # Fill the form with year-1
96
    $from_placed_on->set_time_zone('floating')->subtract( years => 1 );
96
    $from_placed_on->set_time_zone('floating')->subtract( years => 1 );
(-)a/acqui/neworderempty.pl (-1 / +1 lines)
Lines 245-251 if ( not $ordernumber ) { # create order Link Here
245
                if ( $value ) {
245
                if ( $value ) {
246
246
247
                    # get today date & replace <<YYYY>>, <<YY>>, <<MM>>, <<DD>> if provided in the default value
247
                    # get today date & replace <<YYYY>>, <<YY>>, <<MM>>, <<DD>> if provided in the default value
248
                    my $today_dt = dt_from_string;
248
                    my $today_dt = dt_from_string();
249
                    my $year     = $today_dt->strftime('%Y');
249
                    my $year     = $today_dt->strftime('%Y');
250
                    my $shortyear = $today_dt->strftime('%y');
250
                    my $shortyear = $today_dt->strftime('%y');
251
                    my $month    = $today_dt->strftime('%m');
251
                    my $month    = $today_dt->strftime('%m');
(-)a/acqui/orderreceive.pl (-1 / +1 lines)
Lines 119-125 my $creator = Koha::Patrons->find( $order->created_by ); Link Here
119
119
120
my $budget = GetBudget( $order->budget_id );
120
my $budget = GetBudget( $order->budget_id );
121
121
122
my $datereceived = $order->datereceived ? dt_from_string( $order->datereceived ) : dt_from_string;
122
my $datereceived = $order->datereceived ? dt_from_string( $order->datereceived ) : dt_from_string();
123
123
124
# get option values for TaxRates syspref
124
# get option values for TaxRates syspref
125
my @gst_values = map {
125
my @gst_values = map {
(-)a/acqui/parcels.pl (-2 / +2 lines)
Lines 75-81 use C4::Acquisition qw( GetInvoices GetInvoice AddInvoice ); Link Here
75
use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget );
75
use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget );
76
76
77
use Koha::Acquisition::Booksellers;
77
use Koha::Acquisition::Booksellers;
78
use Koha::DateUtils qw( output_pref dt_from_string );
78
use Koha::DateUtils qw( output_pref dt_from_string() );
79
79
80
my $input          = CGI->new;
80
my $input          = CGI->new;
81
my $booksellerid     = $input->param('booksellerid');
81
my $booksellerid     = $input->param('booksellerid');
Lines 198-204 $template->param( Link Here
198
    dateto                   => $dateto,
198
    dateto                   => $dateto,
199
    resultsperpage           => $resultsperpage,
199
    resultsperpage           => $resultsperpage,
200
    name                     => $bookseller->name,
200
    name                     => $bookseller->name,
201
    shipmentdate_today       => dt_from_string,
201
    shipmentdate_today       => dt_from_string(),
202
    booksellerid             => $booksellerid,
202
    booksellerid             => $booksellerid,
203
    GST                      => C4::Context->preference('TaxRates'),
203
    GST                      => C4::Context->preference('TaxRates'),
204
    budgets                  => $budget_loop,
204
    budgets                  => $budget_loop,
(-)a/admin/aqbudgetperiods.pl (-2 / +2 lines)
Lines 167-174 elsif ( $op eq 'duplicate_form'){ Link Here
167
elsif ( $op eq 'duplicate_budget' ){
167
elsif ( $op eq 'duplicate_budget' ){
168
    die "please specify a budget period id\n" if( !defined $budget_period_id || $budget_period_id eq '' );
168
    die "please specify a budget period id\n" if( !defined $budget_period_id || $budget_period_id eq '' );
169
169
170
    my $budget_period_startdate = dt_from_string scalar $input->param('budget_period_startdate');
170
    my $budget_period_startdate = dt_from_string() scalar $input->param('budget_period_startdate');
171
    my $budget_period_enddate   = dt_from_string scalar $input->param('budget_period_enddate');
171
    my $budget_period_enddate   = dt_from_string() scalar $input->param('budget_period_enddate');
172
    my $budget_period_description = $input->param('budget_period_description');
172
    my $budget_period_description = $input->param('budget_period_description');
173
    my $amount_change_percentage = $input->param('amount_change_percentage');
173
    my $amount_change_percentage = $input->param('amount_change_percentage');
174
    my $amount_change_round_increment = $input->param('amount_change_round_increment');
174
    my $amount_change_round_increment = $input->param('amount_change_round_increment');
(-)a/admin/aqcontract.pl (-1 / +1 lines)
Lines 99-105 elsif ( $op eq 'add_validate' ) { Link Here
99
    my $contractstart_dt = eval { dt_from_string( scalar $input->param('contractstartdate') ); };
99
    my $contractstart_dt = eval { dt_from_string( scalar $input->param('contractstartdate') ); };
100
    my $contractend_dt = eval { dt_from_string( scalar $input->param('contractenddate') ); };
100
    my $contractend_dt = eval { dt_from_string( scalar $input->param('contractenddate') ); };
101
    unless ( $contractstart_dt and $contractend_dt ) {
101
    unless ( $contractstart_dt and $contractend_dt ) {
102
        my $today = dt_from_string;
102
        my $today = dt_from_string();
103
        $contractstart_dt ||= $today;
103
        $contractstart_dt ||= $today;
104
        $contractend_dt   ||= $today;
104
        $contractend_dt   ||= $today;
105
    }
105
    }
(-)a/cataloguing/addbiblio.pl (-1 / +1 lines)
Lines 292-298 sub create_input { Link Here
292
        $value = $tagslib->{$tag}->{$subfield}->{defaultvalue} // q{};
292
        $value = $tagslib->{$tag}->{$subfield}->{defaultvalue} // q{};
293
293
294
        # get today date & replace <<YYYY>>, <<YY>>, <<MM>>, <<DD>> if provided in the default value
294
        # get today date & replace <<YYYY>>, <<YY>>, <<MM>>, <<DD>> if provided in the default value
295
        my $today_dt = dt_from_string;
295
        my $today_dt = dt_from_string();
296
        my $year = $today_dt->strftime('%Y');
296
        my $year = $today_dt->strftime('%Y');
297
        my $shortyear = $today_dt->strftime('%y');
297
        my $shortyear = $today_dt->strftime('%y');
298
        my $month = $today_dt->strftime('%m');
298
        my $month = $today_dt->strftime('%m');
(-)a/cataloguing/additem.pl (-1 / +1 lines)
Lines 132-138 sub generate_subfield_form { Link Here
132
            $value = $subfieldlib->{defaultvalue};
132
            $value = $subfieldlib->{defaultvalue};
133
            if ( $value ) {
133
            if ( $value ) {
134
                # get today date & replace <<YYYY>>, <<YY>>, <<MM>>, <<DD>> if provided in the default value
134
                # get today date & replace <<YYYY>>, <<YY>>, <<MM>>, <<DD>> if provided in the default value
135
                my $today_dt = dt_from_string;
135
                my $today_dt = dt_from_string();
136
                my $year = $today_dt->strftime('%Y');
136
                my $year = $today_dt->strftime('%Y');
137
                my $shortyear = $today_dt->strftime('%y');
137
                my $shortyear = $today_dt->strftime('%y');
138
                my $month = $today_dt->strftime('%m');
138
                my $month = $today_dt->strftime('%m');
(-)a/cataloguing/value_builder/barcode.pl (-1 / +1 lines)
Lines 35-41 my $builder = sub { Link Here
35
    my %args;
35
    my %args;
36
36
37
	# find today's date
37
	# find today's date
38
    ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }));
38
    ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }));
39
    ($args{tag},$args{subfield})       =  GetMarcFromKohaField( "items.barcode" );
39
    ($args{tag},$args{subfield})       =  GetMarcFromKohaField( "items.barcode" );
40
    ($args{loctag},$args{locsubfield}) =  GetMarcFromKohaField( "items.homebranch" );
40
    ($args{loctag},$args{locsubfield}) =  GetMarcFromKohaField( "items.homebranch" );
41
41
(-)a/cataloguing/value_builder/barcode_manual.pl (-1 / +1 lines)
Lines 36-42 my $builder = sub { Link Here
36
    $args{dbh} = $dbh;
36
    $args{dbh} = $dbh;
37
37
38
# find today's date
38
# find today's date
39
    ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }));
39
    ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }));
40
    ($args{tag},$args{subfield})       =  GetMarcFromKohaField( "items.barcode" );
40
    ($args{tag},$args{subfield})       =  GetMarcFromKohaField( "items.barcode" );
41
    ($args{loctag},$args{locsubfield}) =  GetMarcFromKohaField( "items.homebranch" );
41
    ($args{loctag},$args{locsubfield}) =  GetMarcFromKohaField( "items.homebranch" );
42
42
(-)a/cataloguing/value_builder/dateaccessioned.pl (-1 / +1 lines)
Lines 27-33 my $builder = sub { Link Here
27
    my ( $params ) = @_;
27
    my ( $params ) = @_;
28
    my $function_name = $params->{id};
28
    my $function_name = $params->{id};
29
29
30
    my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
30
    my $date = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 });
31
31
32
    my $res  = <<END_OF_JS;
32
    my $res  = <<END_OF_JS;
33
<script>
33
<script>
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 194-200 my ($datedue,$invalidduedate); Link Here
194
194
195
my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
195
my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
196
if( $onsite_checkout && !$duedatespec_allow ) {
196
if( $onsite_checkout && !$duedatespec_allow ) {
197
    $datedue = output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
197
    $datedue = output_pref({ dt => dt_from_string(), dateonly => 1, dateformat => 'iso' });
198
    $datedue .= ' 23:59:00';
198
    $datedue .= ' 23:59:00';
199
} elsif( $duedatespec_allow ) {
199
} elsif( $duedatespec_allow ) {
200
    if ( $duedatespec ) {
200
    if ( $duedatespec ) {
(-)a/circ/pendingreserves.pl (-1 / +1 lines)
Lines 130-136 if ( $op eq 'cancel_reserve' and $reserve_id ) { Link Here
130
}
130
}
131
131
132
132
133
my $today = dt_from_string;
133
my $today = dt_from_string();
134
134
135
if ( $startdate ) {
135
if ( $startdate ) {
136
    $startdate =~ s/^\s+//;
136
    $startdate =~ s/^\s+//;
(-)a/circ/reserveratios.pl (-1 / +1 lines)
Lines 65-71 if ( $basketno ){ Link Here
65
$startdate = eval { dt_from_string( $startdate ) } if $startdate;
65
$startdate = eval { dt_from_string( $startdate ) } if $startdate;
66
$enddate = eval { dt_from_string( $enddate ) } if $enddate;
66
$enddate = eval { dt_from_string( $enddate ) } if $enddate;
67
67
68
my $todaysdate = dt_from_string;
68
my $todaysdate = dt_from_string();
69
69
70
#    A default of the prior years's holds is a reasonable way to pull holds
70
#    A default of the prior years's holds is a reasonable way to pull holds
71
$enddate = $todaysdate unless $enddate;
71
$enddate = $todaysdate unless $enddate;
(-)a/circ/transferstoreceive.pl (-1 / +1 lines)
Lines 120-126 while ( my $library = $libraries->next ) { Link Here
120
120
121
$template->param(
121
$template->param(
122
    branchesloop => \@branchesloop,
122
    branchesloop => \@branchesloop,
123
    show_date    => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }),
123
    show_date    => output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }),
124
    TransfersMaxDaysWarning => C4::Context->preference('TransfersMaxDaysWarning'),
124
    TransfersMaxDaysWarning => C4::Context->preference('TransfersMaxDaysWarning'),
125
    latetransfers => $latetransfers ? 1 : 0,
125
    latetransfers => $latetransfers ? 1 : 0,
126
);
126
);
(-)a/circ/waitingreserves.pl (-1 / +1 lines)
Lines 106-112 $template->param( Link Here
106
    reservecount => scalar @reserve_loop,
106
    reservecount => scalar @reserve_loop,
107
    overloop    => \@over_loop,
107
    overloop    => \@over_loop,
108
    overcount   => scalar @over_loop,
108
    overcount   => scalar @over_loop,
109
    show_date   => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }),
109
    show_date   => output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }),
110
    tab => $tab,
110
    tab => $tab,
111
);
111
);
112
112
(-)a/members/memberentry.pl (-2 / +2 lines)
Lines 770-779 if ($nok) { Link Here
770
  #Formatting data for display    
770
  #Formatting data for display    
771
  
771
  
772
if (!defined($data{'dateenrolled'}) or $data{'dateenrolled'} eq ''){
772
if (!defined($data{'dateenrolled'}) or $data{'dateenrolled'} eq ''){
773
  $data{'dateenrolled'} = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
773
  $data{'dateenrolled'} = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 });
774
}
774
}
775
if ( $op eq 'duplicate' ) {
775
if ( $op eq 'duplicate' ) {
776
    $data{'dateenrolled'} = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
776
    $data{'dateenrolled'} = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 });
777
    my $patron_category = Koha::Patron::Categories->find( $data{categorycode} );
777
    my $patron_category = Koha::Patron::Categories->find( $data{categorycode} );
778
    $data{dateexpiry} = $patron_category->get_expiry_date( $data{dateenrolled} );
778
    $data{dateexpiry} = $patron_category->get_expiry_date( $data{dateenrolled} );
779
}
779
}
(-)a/misc/add_date_fields_to_marc_records.pl (-1 / +1 lines)
Lines 47-53 pod2usage(1) if $help; Link Here
47
pod2usage("Parameter field is mandatory") unless @fields;
47
pod2usage("Parameter field is mandatory") unless @fields;
48
48
49
my @fields_to_add;
49
my @fields_to_add;
50
my $dt = dt_from_string;    # Could be an option of the script
50
my $dt = dt_from_string();    # Could be an option of the script
51
for my $field (@fields) {
51
for my $field (@fields) {
52
    my ( $f_sf, $value )    = split '=',  $field;
52
    my ( $f_sf, $value )    = split '=',  $field;
53
    my ( $tag,  $subfield ) = split '\$', $f_sf;
53
    my ( $tag,  $subfield ) = split '\$', $f_sf;
(-)a/misc/cronjobs/archive_purchase_suggestions.pl (-1 / +1 lines)
Lines 75-81 else { Link Here
75
    $age_date_field = 'manageddate';
75
    $age_date_field = 'manageddate';
76
}
76
}
77
77
78
my $date = dt_from_string;
78
my $date = dt_from_string();
79
if ($age) {
79
if ($age) {
80
    if ( $age =~ m|^(\d)$| || $age =~ m|^days:(\d+)$| ) {
80
    if ( $age =~ m|^(\d)$| || $age =~ m|^days:(\d+)$| ) {
81
        $date->subtract( days => $1 );
81
        $date->subtract( days => $1 );
(-)a/misc/cronjobs/gather_print_notices.pl (-2 / +2 lines)
Lines 80-87 $delimiter ||= q|,|; Link Here
80
80
81
cronlogaction();
81
cronlogaction();
82
82
83
my $today_iso     = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ) ;
83
my $today_iso     = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ) ;
84
my $today_syspref = output_pref( { dt => dt_from_string, dateonly => 1 } );
84
my $today_syspref = output_pref( { dt => dt_from_string(), dateonly => 1 } );
85
85
86
my @all_messages = @{ GetPrintMessages() };
86
my @all_messages = @{ GetPrintMessages() };
87
87
(-)a/misc/cronjobs/serialsUpdate.pl (-1 / +1 lines)
Lines 121-127 while ( my $issue = $sth->fetchrow_hashref ) { Link Here
121
    if ( $subscription && $publisheddate ) {
121
    if ( $subscription && $publisheddate ) {
122
        my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'});
122
        my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'});
123
        my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $freqdata );
123
        my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $freqdata );
124
        my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
124
        my $today = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 });
125
125
126
        if ( $nextpublisheddate && $today ) {
126
        if ( $nextpublisheddate && $today ) {
127
            my ( $year,  $month,  $day )  = split( /-/, $nextpublisheddate );
127
            my ( $year,  $month,  $day )  = split( /-/, $nextpublisheddate );
(-)a/misc/cronjobs/staticfines.pl (-1 / +1 lines)
Lines 133-139 if (defined $borrowernumberlimit) { Link Here
133
}
133
}
134
my $overdueItemsCounted = 0;
134
my $overdueItemsCounted = 0;
135
my %calendars           = ();
135
my %calendars           = ();
136
$today      = dt_from_string;
136
$today      = dt_from_string();
137
$today_iso  = output_pref( { dt => $today, dateonly => 1, dateformat => 'iso' } );
137
$today_iso  = output_pref( { dt => $today, dateonly => 1, dateformat => 'iso' } );
138
my ($tyear, $tmonth, $tday) = split( /-/, $today_iso );
138
my ($tyear, $tmonth, $tday) = split( /-/, $today_iso );
139
$today_days = Date_to_Days( $tyear, $tmonth, $tday );
139
$today_days = Date_to_Days( $tyear, $tmonth, $tday );
(-)a/opac/opac-memberentry.pl (-1 / +1 lines)
Lines 520-526 sub ParseCgiForBorrower { Link Here
520
    }
520
    }
521
521
522
    # Replace checkbox 'agreed' by datetime in gdpr_proc_consent
522
    # Replace checkbox 'agreed' by datetime in gdpr_proc_consent
523
    $borrower{gdpr_proc_consent} = dt_from_string if  $borrower{gdpr_proc_consent} && $borrower{gdpr_proc_consent} eq 'agreed';
523
    $borrower{gdpr_proc_consent} = dt_from_string() if  $borrower{gdpr_proc_consent} && $borrower{gdpr_proc_consent} eq 'agreed';
524
524
525
    return %borrower;
525
    return %borrower;
526
}
526
}
(-)a/opac/opac-showreviews.pl (-2 / +2 lines)
Lines 59-65 my ( $template, $borrowernumber, $cookie ) = &get_template_and_user( Link Here
59
);
59
);
60
60
61
if($format eq "rss"){
61
if($format eq "rss"){
62
    my $lastbuilddate = dt_from_string;
62
    my $lastbuilddate = dt_from_string();
63
    my $lastbuilddate_output = $lastbuilddate->strftime("%a, %d %b %Y %H:%M:%S %z");
63
    my $lastbuilddate_output = $lastbuilddate->strftime("%a, %d %b %Y %H:%M:%S %z");
64
    $template->param(
64
    $template->param(
65
        rss => 1,
65
        rss => 1,
Lines 131-137 for my $result (@$reviews){ Link Here
131
131
132
    if($format eq "rss"){
132
    if($format eq "rss"){
133
        my $rsstimestamp = eval { dt_from_string( $result->{datereviewed} ); };
133
        my $rsstimestamp = eval { dt_from_string( $result->{datereviewed} ); };
134
        $rsstimestamp = dt_from_string unless ( $rsstimestamp ); #default to today if something went wrong
134
        $rsstimestamp = dt_from_string() unless ( $rsstimestamp ); #default to today if something went wrong
135
        my $rsstimestamp_output = $rsstimestamp->strftime("%a, %d %b %Y %H:%M:%S %z");
135
        my $rsstimestamp_output = $rsstimestamp->strftime("%a, %d %b %Y %H:%M:%S %z");
136
        $result->{timestamp} = $rsstimestamp_output;
136
        $result->{timestamp} = $rsstimestamp_output;
137
    }
137
    }
(-)a/opac/opac-suggestions.pl (-1 / +1 lines)
Lines 175-181 if ( $op eq "add_confirm" ) { Link Here
175
            $suggestion->{$suggest} = Encode::encode( "utf8",
175
            $suggestion->{$suggest} = Encode::encode( "utf8",
176
                $scrubber->scrub( $suggestion->{$suggest} ) );
176
                $scrubber->scrub( $suggestion->{$suggest} ) );
177
        }
177
        }
178
        $suggestion->{suggesteddate} = dt_from_string;
178
        $suggestion->{suggesteddate} = dt_from_string();
179
        $suggestion->{branchcode} = $input->param('branchcode') || C4::Context->userenv->{"branch"};
179
        $suggestion->{branchcode} = $input->param('branchcode') || C4::Context->userenv->{"branch"};
180
180
181
        &NewSuggestion($suggestion);
181
        &NewSuggestion($suggestion);
(-)a/opac/sco/sco-main.pl (-1 / +1 lines)
Lines 242-248 elsif ( $patron && ( $op eq 'checkout' ) ) { Link Here
242
                            borrowernumber  => $borrower->{borrowernumber},
242
                            borrowernumber  => $borrower->{borrowernumber},
243
                            debit_type_code => 'RESERVE',
243
                            debit_type_code => 'RESERVE',
244
                            description     => $item->biblio->title,
244
                            description     => $item->biblio->title,
245
                            date            => $dtf->format_date(dt_from_string)
245
                            date            => $dtf->format_date(dt_from_string())
246
                        }
246
                        }
247
                      )->count,
247
                      )->count,
248
                );
248
                );
(-)a/reports/cash_register_stats.pl (-4 / +4 lines)
Lines 51-58 $template->param( Link Here
51
);
51
);
52
52
53
#Initialize date pickers to today
53
#Initialize date pickers to today
54
my $fromDate = dt_from_string;
54
my $fromDate = dt_from_string();
55
my $toDate   = dt_from_string;
55
my $toDate   = dt_from_string();
56
56
57
my @debit_types =
57
my @debit_types =
58
  Koha::Account::DebitTypes->search()->as_list;
58
  Koha::Account::DebitTypes->search()->as_list;
Lines 62-70 my $registerid; Link Here
62
62
63
if ($do_it) {
63
if ($do_it) {
64
64
65
    $fromDate = output_pref({ dt => eval { dt_from_string(scalar $input->param("from")) } || dt_from_string,
65
    $fromDate = output_pref({ dt => eval { dt_from_string(scalar $input->param("from")) } || dt_from_string(),
66
            dateformat => 'sql', dateonly => 1 }); #for sql query
66
            dateformat => 'sql', dateonly => 1 }); #for sql query
67
    $toDate   = output_pref({ dt => eval { dt_from_string(scalar $input->param("to")) } || dt_from_string,
67
    $toDate   = output_pref({ dt => eval { dt_from_string(scalar $input->param("to")) } || dt_from_string(),
68
            dateformat => 'sql', dateonly => 1 }); #for sql query
68
            dateformat => 'sql', dateonly => 1 }); #for sql query
69
69
70
    my $whereTType = q{};
70
    my $whereTType = q{};
(-)a/reserve/request.pl (-1 / +1 lines)
Lines 84-90 my $messages; Link Here
84
my $exceeded_maxreserves;
84
my $exceeded_maxreserves;
85
my $exceeded_holds_per_record;
85
my $exceeded_holds_per_record;
86
86
87
my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
87
my $date = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 });
88
my $action = $input->param('action');
88
my $action = $input->param('action');
89
$action ||= q{};
89
$action ||= q{};
90
90
(-)a/serials/serials-collection.pl (-2 / +2 lines)
Lines 66-72 if($op eq 'gennext' && @subscriptionid){ Link Here
66
        $sth->execute($subscriptionid);
66
        $sth->execute($subscriptionid);
67
        # modify actual expected issue, to generate the next
67
        # modify actual expected issue, to generate the next
68
        if ( my $issue = $sth->fetchrow_hashref ) {
68
        if ( my $issue = $sth->fetchrow_hashref ) {
69
            my $planneddate = $date_received_today ? dt_from_string : $issue->{planneddate};
69
            my $planneddate = $date_received_today ? dt_from_string() : $issue->{planneddate};
70
            ModSerialStatus( $issue->{serialid}, $issue->{serialseq},
70
            ModSerialStatus( $issue->{serialid}, $issue->{serialseq},
71
                    $planneddate, $issue->{publisheddate},
71
                    $planneddate, $issue->{publisheddate},
72
                    $issue->{publisheddatetext}, $status, "" );
72
                    $issue->{publisheddatetext}, $status, "" );
Lines 83-89 if($op eq 'gennext' && @subscriptionid){ Link Here
83
83
84
             ## We generate the next publication date
84
             ## We generate the next publication date
85
             my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, $frequency, 1);
85
             my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, $frequency, 1);
86
             my $planneddate = $date_received_today ? dt_from_string : $nextpublisheddate;
86
             my $planneddate = $date_received_today ? dt_from_string() : $nextpublisheddate;
87
             ## Creating the new issue
87
             ## Creating the new issue
88
             NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'},
88
             NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'},
89
                     1, $planneddate, $nextpublisheddate, undef,
89
                     1, $planneddate, $nextpublisheddate, undef,
(-)a/serials/serials-edit.pl (-1 / +1 lines)
Lines 128-134 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
128
my @serialdatalist;
128
my @serialdatalist;
129
my %processedserialid;
129
my %processedserialid;
130
130
131
my $today = output_pref( { dt => dt_from_string, dateonly => 1 } );
131
my $today = output_pref( { dt => dt_from_string(), dateonly => 1 } );
132
132
133
foreach my $serialid (@serialids) {
133
foreach my $serialid (@serialids) {
134
134
(-)a/serials/showpredictionpattern.pl (-1 / +1 lines)
Lines 91-97 my %pattern = ( Link Here
91
);
91
);
92
92
93
$firstacquidate = eval { output_pref( { str => $firstacquidate, dateonly => 1, dateformat => 'iso' } ); }
93
$firstacquidate = eval { output_pref( { str => $firstacquidate, dateonly => 1, dateformat => 'iso' } ); }
94
    or output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } );
94
    or output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } );
95
95
96
$enddate = eval { output_pref( { str => $enddate, dateonly => 1, dateformat => 'iso' } ); };
96
$enddate = eval { output_pref( { str => $enddate, dateonly => 1, dateformat => 'iso' } ); };
97
97
(-)a/serials/subscription-renew.pl (-1 / +1 lines)
Lines 120-126 if ( $op eq "renew" ) { Link Here
120
    }
120
    }
121
121
122
    my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } )
122
    my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } )
123
        or output_pref( { dt => dt_from_string, dateonly => 1 } );
123
        or output_pref( { dt => dt_from_string(), dateonly => 1 } );
124
124
125
    $template->param(
125
    $template->param(
126
        startdate      => $newstartdate,
126
        startdate      => $newstartdate,
(-)a/suggestion/suggestion.pl (-8 / +8 lines)
Lines 40-51 sub Init{ Link Here
40
    # "Managed by" is used only when a suggestion is being edited (not when created)
40
    # "Managed by" is used only when a suggestion is being edited (not when created)
41
    if ($suggestion->{'suggesteddate'} eq "") {
41
    if ($suggestion->{'suggesteddate'} eq "") {
42
        # new suggestion
42
        # new suggestion
43
        $suggestion->{suggesteddate} = dt_from_string;
43
        $suggestion->{suggesteddate} = dt_from_string();
44
        $suggestion->{'suggestedby'} = C4::Context->userenv->{"number"} unless ($suggestion->{'suggestedby'});
44
        $suggestion->{'suggestedby'} = C4::Context->userenv->{"number"} unless ($suggestion->{'suggestedby'});
45
    }
45
    }
46
    else {
46
    else {
47
        # editing of an existing suggestion
47
        # editing of an existing suggestion
48
        $suggestion->{manageddate} = dt_from_string;
48
        $suggestion->{manageddate} = dt_from_string();
49
        $suggestion->{'managedby'} = C4::Context->userenv->{"number"} unless ($suggestion->{'managedby'});
49
        $suggestion->{'managedby'} = C4::Context->userenv->{"number"} unless ($suggestion->{'managedby'});
50
    }
50
    }
51
    $suggestion->{'branchcode'}=C4::Context->userenv->{"branch"} unless ($suggestion->{'branchcode'});
51
    $suggestion->{'branchcode'}=C4::Context->userenv->{"branch"} unless ($suggestion->{'branchcode'});
Lines 164-173 if ( $op =~ /save/i ) { Link Here
164
164
165
        if ( $suggestion_only->{"STATUS"} ) {
165
        if ( $suggestion_only->{"STATUS"} ) {
166
            if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) {
166
            if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) {
167
                $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string;
167
                $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string();
168
                $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" }   = C4::Context->userenv->{number};
168
                $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" }   = C4::Context->userenv->{number};
169
            }
169
            }
170
            $suggestion_only->{manageddate} = dt_from_string;
170
            $suggestion_only->{manageddate} = dt_from_string();
171
            $suggestion_only->{"managedby"} ||= C4::Context->userenv->{number};
171
            $suggestion_only->{"managedby"} ||= C4::Context->userenv->{number};
172
        }
172
        }
173
173
Lines 178-184 if ( $op =~ /save/i ) { Link Here
178
178
179
        if ( $suggestion_only->{'suggestionid'} > 0 ) {
179
        if ( $suggestion_only->{'suggestionid'} > 0 ) {
180
180
181
            $suggestion_only->{lastmodificationdate} = dt_from_string;
181
            $suggestion_only->{lastmodificationdate} = dt_from_string();
182
            $suggestion_only->{lastmodificationby}   = C4::Context->userenv->{number};
182
            $suggestion_only->{lastmodificationby}   = C4::Context->userenv->{number};
183
183
184
            &ModSuggestion($suggestion_only);
184
            &ModSuggestion($suggestion_only);
Lines 263-280 elsif ($op eq "update_status" ) { Link Here
263
    my $accepted_by = $input->param('acceptedby');
263
    my $accepted_by = $input->param('acceptedby');
264
    if ( $STATUS eq "ACCEPTED" ) {
264
    if ( $STATUS eq "ACCEPTED" ) {
265
        $suggestion = {
265
        $suggestion = {
266
            accepteddate => dt_from_string,
266
            accepteddate => dt_from_string(),
267
            acceptedby => C4::Context->userenv->{number},
267
            acceptedby => C4::Context->userenv->{number},
268
        };
268
        };
269
    }
269
    }
270
    elsif ( $STATUS eq "REJECTED" ) {
270
    elsif ( $STATUS eq "REJECTED" ) {
271
        $suggestion = {
271
        $suggestion = {
272
            rejecteddate => dt_from_string,
272
            rejecteddate => dt_from_string(),
273
            rejectedby   => C4::Context->userenv->{number},
273
            rejectedby   => C4::Context->userenv->{number},
274
        };
274
        };
275
    }
275
    }
276
    if ($STATUS) {
276
    if ($STATUS) {
277
        $suggestion->{manageddate} = dt_from_string;
277
        $suggestion->{manageddate} = dt_from_string();
278
        $suggestion->{managedby}   = C4::Context->userenv->{number};
278
        $suggestion->{managedby}   = C4::Context->userenv->{number};
279
        $suggestion->{STATUS}      = $STATUS;
279
        $suggestion->{STATUS}      = $STATUS;
280
    }
280
    }
(-)a/svc/hold/resume (-1 / +1 lines)
Lines 25-31 use JSON qw(to_json); Link Here
25
use C4::Context;
25
use C4::Context;
26
use C4::Output qw(output_with_http_headers);
26
use C4::Output qw(output_with_http_headers);
27
use C4::Auth qw(check_cookie_auth);
27
use C4::Auth qw(check_cookie_auth);
28
use Koha::DateUtils qw(dt_from_string);
28
use Koha::DateUtils qw(dt_from_string());
29
use Koha::Holds;
29
use Koha::Holds;
30
30
31
my $input = CGI->new;
31
my $input = CGI->new;
(-)a/svc/hold/suspend (-1 / +1 lines)
Lines 25-31 use JSON qw(to_json); Link Here
25
use C4::Context;
25
use C4::Context;
26
use C4::Output qw(output_with_http_headers);
26
use C4::Output qw(output_with_http_headers);
27
use C4::Auth qw(check_cookie_auth);
27
use C4::Auth qw(check_cookie_auth);
28
use Koha::DateUtils qw(dt_from_string);
28
use Koha::DateUtils qw(dt_from_string());
29
use Koha::Holds;
29
use Koha::Holds;
30
30
31
my $input = CGI->new;
31
my $input = CGI->new;
(-)a/svc/members/search (-1 / +1 lines)
Lines 24-30 use C4::Auth qw( get_template_and_user haspermission get_user_subpermissions ); Link Here
24
use C4::Output qw( output_with_http_headers );
24
use C4::Output qw( output_with_http_headers );
25
use C4::Utils::DataTables qw( dt_get_params );
25
use C4::Utils::DataTables qw( dt_get_params );
26
use C4::Utils::DataTables::Members qw( search );
26
use C4::Utils::DataTables::Members qw( search );
27
use Koha::DateUtils qw( output_pref dt_from_string );
27
use Koha::DateUtils qw( output_pref dt_from_string() );
28
use Koha::Patrons;
28
use Koha::Patrons;
29
29
30
my $input = CGI->new;
30
my $input = CGI->new;
(-)a/svc/renew (-1 / +1 lines)
Lines 27-33 use C4::Circulation qw( AddRenewal CanBookBeRenewed ); Link Here
27
use C4::Context;
27
use C4::Context;
28
use C4::Auth qw(check_cookie_auth);
28
use C4::Auth qw(check_cookie_auth);
29
29
30
use Koha::DateUtils qw(output_pref dt_from_string);
30
use Koha::DateUtils qw(output_pref dt_from_string());
31
31
32
my $input = CGI->new;
32
my $input = CGI->new;
33
33
(-)a/t/DateUtils.t (-1 / +1 lines)
Lines 186-192 $date_string = output_pref({ dt => $dt, dateformat => 'us', timeformat => '12hr' Link Here
186
cmp_ok $date_string, 'eq', '12/11/2013 06:35 PM', 'as_due_date with hours and timeformat 12hr (non-midnight time)';
186
cmp_ok $date_string, 'eq', '12/11/2013 06:35 PM', 'as_due_date with hours and timeformat 12hr (non-midnight time)';
187
187
188
my $now = DateTime->now;
188
my $now = DateTime->now;
189
is( dt_from_string, $now, "Without parameter, dt_from_string should return today" );
189
is( dt_from_string(), $now, "Without parameter, dt_from_string should return today" );
190
190
191
my $module_context = Test::MockModule->new('C4::Context');
191
my $module_context = Test::MockModule->new('C4::Context');
192
$module_context->mock(
192
$module_context->mock(
(-)a/t/db_dependent/Acquisition/NewOrder.t (-1 / +1 lines)
Lines 89-95 $order = Koha::Acquisition::Order->new( Link Here
89
my $ordernumber = $order->ordernumber;
89
my $ordernumber = $order->ordernumber;
90
$order = Koha::Acquisition::Orders->find( $ordernumber );
90
$order = Koha::Acquisition::Orders->find( $ordernumber );
91
is( $order->quantityreceived, 0, 'Koha::Acquisition::Order->insert set quantityreceivedto 0 if undef is given' );
91
is( $order->quantityreceived, 0, 'Koha::Acquisition::Order->insert set quantityreceivedto 0 if undef is given' );
92
is( $order->entrydate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 'Koha::Acquisition::Order->store set entrydate to today' );
92
is( $order->entrydate, output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }), 'Koha::Acquisition::Order->store set entrydate to today' );
93
is( $order->created_by, $logged_in_user->borrowernumber, 'Koha::Acquisition::Order->store set created_by to logged in user if not given' );
93
is( $order->created_by, $logged_in_user->borrowernumber, 'Koha::Acquisition::Order->store set created_by to logged in user if not given' );
94
94
95
$schema->storage->txn_rollback();
95
$schema->storage->txn_rollback();
(-)a/t/db_dependent/Authority/MergeRequests.t (-1 / +1 lines)
Lines 14-20 $schema->storage->txn_begin; Link Here
14
subtest "Tests for cron_cleanup" => sub {
14
subtest "Tests for cron_cleanup" => sub {
15
    plan tests => 3;
15
    plan tests => 3;
16
16
17
    my $dt = dt_from_string;
17
    my $dt = dt_from_string();
18
    $dt->subtract( hours => 2 );
18
    $dt->subtract( hours => 2 );
19
    my $req1 = Koha::Authority::MergeRequest->new({
19
    my $req1 = Koha::Authority::MergeRequest->new({
20
        authid => 1,
20
        authid => 1,
(-)a/t/db_dependent/Circulation.t (-17 / +17 lines)
Lines 71-78 sub test_debarment_on_checkout { Link Here
71
    my $item     = $params->{item};
71
    my $item     = $params->{item};
72
    my $library  = $params->{library};
72
    my $library  = $params->{library};
73
    my $patron   = $params->{patron};
73
    my $patron   = $params->{patron};
74
    my $due_date = $params->{due_date} || dt_from_string;
74
    my $due_date = $params->{due_date} || dt_from_string();
75
    my $return_date = $params->{return_date} || dt_from_string;
75
    my $return_date = $params->{return_date} || dt_from_string();
76
    my $expected_expiration_date = $params->{expiration_date};
76
    my $expected_expiration_date = $params->{expiration_date};
77
77
78
    $expected_expiration_date = output_pref(
78
    $expected_expiration_date = output_pref(
Lines 105-111 my $builder = t::lib::TestBuilder->new; Link Here
105
my $dbh = C4::Context->dbh;
105
my $dbh = C4::Context->dbh;
106
106
107
# Prevent random failures by mocking ->now
107
# Prevent random failures by mocking ->now
108
my $now_value       = dt_from_string;
108
my $now_value       = dt_from_string();
109
my $mocked_datetime = Test::MockModule->new('DateTime');
109
my $mocked_datetime = Test::MockModule->new('DateTime');
110
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
110
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
111
111
Lines 2218-2224 subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { Link Here
2218
    );
2218
    );
2219
2219
2220
    # Patron cannot issue item_1, they have overdues
2220
    # Patron cannot issue item_1, they have overdues
2221
    my $now = dt_from_string;
2221
    my $now = dt_from_string();
2222
    my $five_days_ago = $now->clone->subtract( days => 5 );
2222
    my $five_days_ago = $now->clone->subtract( days => 5 );
2223
    my $ten_days_ago  = $now->clone->subtract( days => 10 );
2223
    my $ten_days_ago  = $now->clone->subtract( days => 10 );
2224
    AddIssue( $patron, $item_1->barcode, $five_days_ago );    # Add an overdue
2224
    AddIssue( $patron, $item_1->barcode, $five_days_ago );    # Add an overdue
Lines 2324-2330 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2324
        }
2324
        }
2325
    );
2325
    );
2326
2326
2327
    my $now = dt_from_string;
2327
    my $now = dt_from_string();
2328
    my $five_days_ago = $now->clone->subtract( days => 5 );
2328
    my $five_days_ago = $now->clone->subtract( days => 5 );
2329
    # We want to charge 2 days every day, without grace
2329
    # We want to charge 2 days every day, without grace
2330
    # With 5 days of overdue: 5 * Z
2330
    # With 5 days of overdue: 5 * Z
Lines 2356-2362 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2356
        }
2356
        }
2357
    );
2357
    );
2358
    {
2358
    {
2359
    my $now = dt_from_string;
2359
    my $now = dt_from_string();
2360
    my $five_days_ago = $now->clone->subtract( days => 5 );
2360
    my $five_days_ago = $now->clone->subtract( days => 5 );
2361
    # We want to charge 2 days every day, without grace
2361
    # We want to charge 2 days every day, without grace
2362
    # With 5 days of overdue: 5 * Z
2362
    # With 5 days of overdue: 5 * Z
Lines 2603-2609 subtest 'AddReturn | is_overdue' => sub { Link Here
2603
        }
2603
        }
2604
    );
2604
    );
2605
2605
2606
    my $now   = dt_from_string;
2606
    my $now   = dt_from_string();
2607
    my $one_day_ago   = $now->clone->subtract( days => 1 );
2607
    my $one_day_ago   = $now->clone->subtract( days => 1 );
2608
    my $two_days_ago  = $now->clone->subtract( days => 2 );
2608
    my $two_days_ago  = $now->clone->subtract( days => 2 );
2609
    my $five_days_ago = $now->clone->subtract( days => 5 );
2609
    my $five_days_ago = $now->clone->subtract( days => 5 );
Lines 2799-2805 subtest 'AddReturn | is_overdue' => sub { Link Here
2799
2799
2800
        t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 );
2800
        t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 );
2801
2801
2802
        my $due_date = dt_from_string;
2802
        my $due_date = dt_from_string();
2803
        my $issue = AddIssue( $patron->unblessed, $item->barcode, $due_date );
2803
        my $issue = AddIssue( $patron->unblessed, $item->barcode, $due_date );
2804
2804
2805
        # Add fine
2805
        # Add fine
Lines 3569-3575 subtest 'CanBookBeIssued | is_overdue' => sub { Link Here
3569
        }
3569
        }
3570
    );
3570
    );
3571
3571
3572
    my $now   = dt_from_string;
3572
    my $now   = dt_from_string();
3573
    my $five_days_go = output_pref({ dt => $now->clone->add( days => 5 ), dateonly => 1});
3573
    my $five_days_go = output_pref({ dt => $now->clone->add( days => 5 ), dateonly => 1});
3574
    my $ten_days_go  = output_pref({ dt => $now->clone->add( days => 10), dateonly => 1 });
3574
    my $ten_days_go  = output_pref({ dt => $now->clone->add( days => 10), dateonly => 1 });
3575
    my $library = $builder->build( { source => 'Branch' } );
3575
    my $library = $builder->build( { source => 'Branch' } );
Lines 3946-3952 subtest 'AddRenewal and AddIssuingCharge tests' => sub { Link Here
3946
    $context = Test::MockModule->new('C4::Context');
3946
    $context = Test::MockModule->new('C4::Context');
3947
    $context->mock( userenv => { branch => undef, interface => 'CRON'} ); #Test statistical logging of renewal via cron (atuo_renew)
3947
    $context->mock( userenv => { branch => undef, interface => 'CRON'} ); #Test statistical logging of renewal via cron (atuo_renew)
3948
3948
3949
    my $now = dt_from_string;
3949
    my $now = dt_from_string();
3950
    $date = output_pref( { dt => $now, dateonly => 1, dateformat => 'iso' } );
3950
    $date = output_pref( { dt => $now, dateonly => 1, dateformat => 'iso' } );
3951
    $old_log_size = Koha::ActionLogs->count( \%params_renewal );
3951
    $old_log_size = Koha::ActionLogs->count( \%params_renewal );
3952
    my $sth = $dbh->prepare("SELECT COUNT(*) FROM statistics WHERE itemnumber = ? AND branch = ?");
3952
    my $sth = $dbh->prepare("SELECT COUNT(*) FROM statistics WHERE itemnumber = ? AND branch = ?");
Lines 4036-4042 subtest 'Incremented fee tests' => sub { Link Here
4036
    is( $item->effective_itemtype, $itemtype->id,
4036
    is( $item->effective_itemtype, $itemtype->id,
4037
        "Itemtype set correctly for item" );
4037
        "Itemtype set correctly for item" );
4038
4038
4039
    my $now         = dt_from_string;
4039
    my $now         = dt_from_string();
4040
    my $dt_from     = $now->clone;
4040
    my $dt_from     = $now->clone;
4041
    my $dt_to       = $now->clone->add( days => 7 );
4041
    my $dt_to       = $now->clone->add( days => 7 );
4042
    my $dt_to_renew = $now->clone->add( days => 13 );
4042
    my $dt_to_renew = $now->clone->add( days => 13 );
Lines 4412-4418 subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub { Link Here
4412
        )->next;
4412
        )->next;
4413
        ok( $a, "Found accountline for lost fee" );
4413
        ok( $a, "Found accountline for lost fee" );
4414
        is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" );
4414
        is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" );
4415
        my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string );
4415
        my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string() );
4416
        $a = $a->get_from_storage;
4416
        $a = $a->get_from_storage;
4417
        is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" );
4417
        is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" );
4418
        $a->delete;
4418
        $a->delete;
Lines 4447-4453 subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub { Link Here
4447
        )->next;
4447
        )->next;
4448
        ok( $a, "Found accountline for lost fee" );
4448
        ok( $a, "Found accountline for lost fee" );
4449
        is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" );
4449
        is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" );
4450
        my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string );
4450
        my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string() );
4451
        $a = $a->get_from_storage;
4451
        $a = $a->get_from_storage;
4452
        is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" );
4452
        is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" );
4453
        $a->delete;
4453
        $a->delete;
Lines 4482-4488 subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub { Link Here
4482
        )->next;
4482
        )->next;
4483
        ok( $a, "Found accountline for lost fee" );
4483
        ok( $a, "Found accountline for lost fee" );
4484
        is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" );
4484
        is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" );
4485
        my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string );
4485
        my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string() );
4486
        $a = $a->get_from_storage;
4486
        $a = $a->get_from_storage;
4487
        is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" );
4487
        is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" );
4488
        $a->delete;
4488
        $a->delete;
Lines 4518-4524 subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub { Link Here
4518
        $a = $a->next;
4518
        $a = $a->next;
4519
        ok( $a, "Found accountline for lost fee" );
4519
        ok( $a, "Found accountline for lost fee" );
4520
        is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" );
4520
        is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" );
4521
        my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string );
4521
        my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string() );
4522
        $a = $a->get_from_storage;
4522
        $a = $a->get_from_storage;
4523
        is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" );
4523
        is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" );
4524
        $a->delete;
4524
        $a->delete;
Lines 4897-4904 subtest "updateWrongTransfer tests" => sub { Link Here
4897
                itemnumber    => $item->itemnumber,
4897
                itemnumber    => $item->itemnumber,
4898
                frombranch    => $library2->branchcode,
4898
                frombranch    => $library2->branchcode,
4899
                tobranch      => $library1->branchcode,
4899
                tobranch      => $library1->branchcode,
4900
                daterequested => dt_from_string,
4900
                daterequested => dt_from_string(),
4901
                datesent      => dt_from_string,
4901
                datesent      => dt_from_string(),
4902
                datecancelled => undef,
4902
                datecancelled => undef,
4903
                datearrived   => undef,
4903
                datearrived   => undef,
4904
                reason        => 'Manual'
4904
                reason        => 'Manual'
(-)a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t (-2 / +2 lines)
Lines 126-132 subtest "suspension_chargeperiod" => sub { Link Here
126
    my $item = $builder->build_sample_item;
126
    my $item = $builder->build_sample_item;
127
127
128
    my $last_year = dt_from_string->clone->subtract( years => 1 );
128
    my $last_year = dt_from_string->clone->subtract( years => 1 );
129
    my $today = dt_from_string;
129
    my $today = dt_from_string();
130
    my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, $last_year, $today );
130
    my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, $last_year, $today );
131
    is( $new_debar_dt->truncate( to => 'day' ),
131
    is( $new_debar_dt->truncate( to => 'day' ),
132
        $today->clone->add( days => 365 / 15 * 7 )->truncate( to => 'day' ) );
132
        $today->clone->add( days => 365 / 15 * 7 )->truncate( to => 'day' ) );
Lines 152-158 subtest "maxsuspensiondays" => sub { Link Here
152
    my $item = $builder->build_sample_item;
152
    my $item = $builder->build_sample_item;
153
153
154
    my $last_year = dt_from_string->clone->subtract( years => 1 );
154
    my $last_year = dt_from_string->clone->subtract( years => 1 );
155
    my $today = dt_from_string;
155
    my $today = dt_from_string();
156
    my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, $last_year, $today );
156
    my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, $last_year, $today );
157
    is( $new_debar_dt->truncate( to => 'day' ),
157
    is( $new_debar_dt->truncate( to => 'day' ),
158
        $today->clone->add( days => 333 )->truncate( to => 'day' ) );
158
        $today->clone->add( days => 333 )->truncate( to => 'day' ) );
(-)a/t/db_dependent/Circulation/MarkIssueReturned.t (-1 / +1 lines)
Lines 27-33 use C4::Circulation qw( MarkIssueReturned AddIssue ); Link Here
27
use C4::Context;
27
use C4::Context;
28
use Koha::Checkouts;
28
use Koha::Checkouts;
29
use Koha::Database;
29
use Koha::Database;
30
use Koha::DateUtils qw(dt_from_string);
30
use Koha::DateUtils qw(dt_from_string());
31
use Koha::Old::Checkouts;
31
use Koha::Old::Checkouts;
32
use Koha::Patrons;
32
use Koha::Patrons;
33
use Koha::Patron::Debarments;
33
use Koha::Patron::Debarments;
(-)a/t/db_dependent/Circulation/Returns.t (-1 / +1 lines)
Lines 268-274 subtest 'Handle ids duplication' => sub { Link Here
268
    my ($doreturn, $messages, $new_checkout, $borrower);
268
    my ($doreturn, $messages, $new_checkout, $borrower);
269
    warning_like {
269
    warning_like {
270
        ( $doreturn, $messages, $new_checkout, $borrower ) =
270
        ( $doreturn, $messages, $new_checkout, $borrower ) =
271
          AddReturn( $item->barcode, undef, undef, undef, dt_from_string );
271
          AddReturn( $item->barcode, undef, undef, undef, dt_from_string() );
272
    }
272
    }
273
    [
273
    [
274
        qr{.*DBD::mysql::st execute failed: Duplicate entry.*},
274
        qr{.*DBD::mysql::st execute failed: Duplicate entry.*},
(-)a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t (-2 / +2 lines)
Lines 85-91 t::lib::Mocks::mock_userenv({ patron => $patron }); Link Here
85
t::lib::Mocks::mock_preference('AllowTooManyOverride', 0);
85
t::lib::Mocks::mock_preference('AllowTooManyOverride', 0);
86
86
87
# Add onsite checkout
87
# Add onsite checkout
88
C4::Circulation::AddIssue( $patron_unblessed, $item->barcode, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } );
88
C4::Circulation::AddIssue( $patron_unblessed, $item->barcode, dt_from_string(), undef, dt_from_string, undef, { onsite_checkout => 1 } );
89
89
90
my ( $impossible, $messages );
90
my ( $impossible, $messages );
91
t::lib::Mocks::mock_preference('SwitchOnSiteCheckouts', 0);
91
t::lib::Mocks::mock_preference('SwitchOnSiteCheckouts', 0);
Lines 111-117 my $another_item = $builder->build_sample_item( Link Here
111
    }
111
    }
112
);
112
);
113
113
114
C4::Circulation::AddIssue( $patron_unblessed, $another_item->barcode, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } );
114
C4::Circulation::AddIssue( $patron_unblessed, $another_item->barcode, dt_from_string(), undef, dt_from_string, undef, { onsite_checkout => 1 } );
115
( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->barcode );
115
( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->barcode );
116
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'Specific case 1 - Switch is allowed' );
116
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'Specific case 1 - Switch is allowed' );
117
is( exists $impossible->{TOO_MANY}, '', 'Specific case 1 - Switch is allowed' );
117
is( exists $impossible->{TOO_MANY}, '', 'Specific case 1 - Switch is allowed' );
(-)a/t/db_dependent/Circulation/issue.t (-3 / +3 lines)
Lines 102-108 Koha::CirculationRules->set_rules( Link Here
102
);
102
);
103
103
104
# Add Dates
104
# Add Dates
105
my $dt_today = dt_from_string;
105
my $dt_today = dt_from_string();
106
my $today    = output_pref(
106
my $today    = output_pref(
107
    {   dt         => $dt_today,
107
    {   dt         => $dt_today,
108
        dateformat => 'iso',
108
        dateformat => 'iso',
Lines 111-117 my $today = output_pref( Link Here
111
    }
111
    }
112
);
112
);
113
113
114
my $dt_today2 = dt_from_string;
114
my $dt_today2 = dt_from_string();
115
my $dur10 = DateTime::Duration->new( days => -10 );
115
my $dur10 = DateTime::Duration->new( days => -10 );
116
$dt_today2->add_duration($dur10);
116
$dt_today2->add_duration($dur10);
117
my $daysago10 = output_pref(
117
my $daysago10 = output_pref(
Lines 482-488 my $reserve_id = AddReserve( Link Here
482
    }
482
    }
483
);
483
);
484
ok( $reserve_id, 'The reserve should have been inserted' );
484
ok( $reserve_id, 'The reserve should have been inserted' );
485
AddIssue( $borrower_2, $barcode_1, dt_from_string, 'cancel' );
485
AddIssue( $borrower_2, $barcode_1, dt_from_string(), 'cancel' );
486
my $hold = Koha::Holds->find( $reserve_id );
486
my $hold = Koha::Holds->find( $reserve_id );
487
is( $hold, undef, 'The reserve should have been correctly cancelled' );
487
is( $hold, undef, 'The reserve should have been correctly cancelled' );
488
488
(-)a/t/db_dependent/Circulation/transfers.t (-3 / +3 lines)
Lines 21-27 use C4::Circulation qw( CreateBranchTransferLimit DeleteBranchTransferLimits Get Link Here
21
use C4::Biblio qw( AddBiblio );
21
use C4::Biblio qw( AddBiblio );
22
use C4::Items qw( ModItemTransfer );
22
use C4::Items qw( ModItemTransfer );
23
use Koha::Database;
23
use Koha::Database;
24
use Koha::DateUtils;
24
use Koha::DateUtils qw( dt_from_string );
25
use DateTime::Duration;
25
use DateTime::Duration;
26
use Koha::Item::Transfers;
26
use Koha::Item::Transfers;
27
27
Lines 136-142 ModItemTransfer( Link Here
136
    $trigger
136
    $trigger
137
);
137
);
138
my $transfer_requested = Koha::Item::Transfers->search( { itemnumber => $item_id3 }, { rows => 1 })->single;
138
my $transfer_requested = Koha::Item::Transfers->search( { itemnumber => $item_id3 }, { rows => 1 })->single;
139
$transfer_requested->set({ daterequested => dt_from_string, datesent => undef })->store;
139
$transfer_requested->set({ daterequested => dt_from_string(), datesent => undef })->store;
140
140
141
# Add a "cancelled" transfer for tests
141
# Add a "cancelled" transfer for tests
142
ModItemTransfer(
142
ModItemTransfer(
Lines 146-152 ModItemTransfer( Link Here
146
    $trigger
146
    $trigger
147
);
147
);
148
my $transfer_cancelled = Koha::Item::Transfers->search( { itemnumber => $item_id4 }, { rows => 1 })->single;
148
my $transfer_cancelled = Koha::Item::Transfers->search( { itemnumber => $item_id4 }, { rows => 1 })->single;
149
$transfer_cancelled->set( { daterequested => dt_from_string, datesent => undef, datecancelled => dt_from_string } )->store;
149
$transfer_cancelled->set( { daterequested => dt_from_string(), datesent => undef, datecancelled => dt_from_string() } )->store;
150
150
151
#Begin Tests
151
#Begin Tests
152
#Test CreateBranchTransferLimit
152
#Test CreateBranchTransferLimit
(-)a/t/db_dependent/Contract.t (-1 / +1 lines)
Lines 77-83 is( $contract->{contractname}, $my_contract1->{contractname}, 'AddContract store Link Here
77
is( $contract->{contractdescription}, $my_contract1->{contractdescription}, 'AddContract stores the contract description correctly.' );
77
is( $contract->{contractdescription}, $my_contract1->{contractdescription}, 'AddContract stores the contract description correctly.' );
78
is( $contract->{booksellerid}, $my_contract1->{booksellerid}, 'AddContract stores the bookseller id correctly.' );
78
is( $contract->{booksellerid}, $my_contract1->{booksellerid}, 'AddContract stores the bookseller id correctly.' );
79
79
80
my $now = dt_from_string;
80
my $now = dt_from_string();
81
my $three_more_days = $now + DateTime::Duration->new( days => 3 );
81
my $three_more_days = $now + DateTime::Duration->new( days => 3 );
82
82
83
$my_contract1 = {
83
$my_contract1 = {
(-)a/t/db_dependent/Hold.t (-1 / +1 lines)
Lines 79-85 $hold->store(); Link Here
79
79
80
my $b1_cal = C4::Calendar->new( branchcode => $branches[1]->{branchcode} );
80
my $b1_cal = C4::Calendar->new( branchcode => $branches[1]->{branchcode} );
81
$b1_cal->insert_single_holiday( day => 2, month => 1, year => 2017, title => "Morty Day", description => "Rick" ); #Add a holiday
81
$b1_cal->insert_single_holiday( day => 2, month => 1, year => 2017, title => "Morty Day", description => "Rick" ); #Add a holiday
82
my $today = dt_from_string;
82
my $today = dt_from_string();
83
is( $hold->age(), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days')  , "Age of hold is days from reservedate to now if calendar ignored");
83
is( $hold->age(), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days')  , "Age of hold is days from reservedate to now if calendar ignored");
84
is( $hold->age(1), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days' ) - 1 , "Age of hold is days from reservedate to now minus 1 if calendar used");
84
is( $hold->age(1), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days' ) - 1 , "Age of hold is days from reservedate to now minus 1 if calendar used");
85
85
(-)a/t/db_dependent/Holds.t (-2 / +2 lines)
Lines 102-108 my $reservedate = $first_hold->reservedate; Link Here
102
my $borrowernumber = $first_hold->borrowernumber;
102
my $borrowernumber = $first_hold->borrowernumber;
103
my $branch_1code = $first_hold->branchcode;
103
my $branch_1code = $first_hold->branchcode;
104
my $reserve_id = $first_hold->reserve_id;
104
my $reserve_id = $first_hold->reserve_id;
105
is( $reservedate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), "holds_placed_today should return a valid reserve date");
105
is( $reservedate, output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }), "holds_placed_today should return a valid reserve date");
106
is( $borrowernumber, $borrowernumbers[0], "holds_placed_today should return a valid borrowernumber");
106
is( $borrowernumber, $borrowernumbers[0], "holds_placed_today should return a valid borrowernumber");
107
is( $branch_1code, $branch_1, "holds_placed_today should return a valid branchcode");
107
is( $branch_1code, $branch_1, "holds_placed_today should return a valid branchcode");
108
ok($reserve_id, "Test holds_placed_today()");
108
ok($reserve_id, "Test holds_placed_today()");
Lines 358-364 $hold = Koha::Hold->new( Link Here
358
        biblionumber   => $biblio->biblionumber,
358
        biblionumber   => $biblio->biblionumber,
359
        found          => undef,
359
        found          => undef,
360
        priority       => 1,
360
        priority       => 1,
361
        reservedate    => dt_from_string,
361
        reservedate    => dt_from_string(),
362
        branchcode     => $branch_1,
362
        branchcode     => $branch_1,
363
    }
363
    }
364
)->store();
364
)->store();
(-)a/t/db_dependent/HoldsQueue.t (-2 / +2 lines)
Lines 1690-1696 subtest 'Remove holds on check-in match' => sub { Link Here
1690
1690
1691
    t::lib::Mocks::mock_userenv( { branchcode => $lib->branchcode } );
1691
    t::lib::Mocks::mock_userenv( { branchcode => $lib->branchcode } );
1692
1692
1693
    AddIssue( $patron1->unblessed, $item->barcode, dt_from_string );
1693
    AddIssue( $patron1->unblessed, $item->barcode, dt_from_string() );
1694
1694
1695
    my $hold_id = AddReserve(
1695
    my $hold_id = AddReserve(
1696
        {
1696
        {
Lines 1724-1730 subtest 'Remove holds on check-in match' => sub { Link Here
1724
1724
1725
    is( $count_1, 1, "Holds queue has one element" );
1725
    is( $count_1, 1, "Holds queue has one element" );
1726
1726
1727
    AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string );
1727
    AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string() );
1728
1728
1729
    ModReserveAffect( $item->itemnumber, $hold->borrowernumber, 0,
1729
    ModReserveAffect( $item->itemnumber, $hold->borrowernumber, 0,
1730
        $hold->reserve_id );
1730
        $hold->reserve_id );
(-)a/t/db_dependent/ILSDI_Services.t (-1 / +1 lines)
Lines 88-94 subtest 'AuthenticatePatron test' => sub { Link Here
88
    t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' );
88
    t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' );
89
    $query->param( 'username', uc( $borrower->{userid} ));
89
    $query->param( 'username', uc( $borrower->{userid} ));
90
    $reply = C4::ILSDI::Services::AuthenticatePatron( $query );
90
    $reply = C4::ILSDI::Services::AuthenticatePatron( $query );
91
    my $now = dt_from_string;
91
    my $now = dt_from_string();
92
    is( $reply->{id}, $borrower->{borrowernumber}, "userid is not case sensitive - Patron authenticated" );
92
    is( $reply->{id}, $borrower->{borrowernumber}, "userid is not case sensitive - Patron authenticated" );
93
    is( $reply->{code}, undef, "Error code undef");
93
    is( $reply->{code}, undef, "Error code undef");
94
    $seen_patron = Koha::Patrons->find({ borrowernumber => $reply->{id} });
94
    $seen_patron = Koha::Patrons->find({ borrowernumber => $reply->{id} });
(-)a/t/db_dependent/Items.t (-1 / +1 lines)
Lines 374-380 subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub { Link Here
374
374
375
    my $biblio = $schema->resultset('Biblio')->create({
375
    my $biblio = $schema->resultset('Biblio')->create({
376
        title       => "Test title",
376
        title       => "Test title",
377
        datecreated => dt_from_string,
377
        datecreated => dt_from_string(),
378
        biblioitems => [ { itemtype => 'BIB_LEVEL' } ],
378
        biblioitems => [ { itemtype => 'BIB_LEVEL' } ],
379
    });
379
    });
380
    my $biblioitem = $biblio->biblioitems->first;
380
    my $biblioitem = $biblio->biblioitems->first;
(-)a/t/db_dependent/Items/AutomaticItemModificationByAge.t (-1 / +1 lines)
Lines 121-127 $marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); Link Here
121
is( $marc_item->subfield($tagfield, $new_tagfield), 'updated_value', q|ToggleNewStatus: The new_status value is not updated| );
121
is( $marc_item->subfield($tagfield, $new_tagfield), 'updated_value', q|ToggleNewStatus: The new_status value is not updated| );
122
122
123
# Play with age
123
# Play with age
124
my $dt_today = dt_from_string;
124
my $dt_today = dt_from_string();
125
my $days5ago = $dt_today->add_duration( DateTime::Duration->new( days => -5 ) );
125
my $days5ago = $dt_today->add_duration( DateTime::Duration->new( days => -5 ) );
126
126
127
$modified_item->dateaccessioned($days5ago)->store;
127
$modified_item->dateaccessioned($days5ago)->store;
(-)a/t/db_dependent/Koha/Account.t (-1 / +1 lines)
Lines 1125-1131 subtest 'Koha::Account::pay() generates credit number (Koha::Account::Line->stor Link Here
1125
    my $context = Test::MockModule->new('C4::Context');
1125
    my $context = Test::MockModule->new('C4::Context');
1126
    $context->mock( 'userenv', { branch => $library->id } );
1126
    $context->mock( 'userenv', { branch => $library->id } );
1127
1127
1128
    my $now = dt_from_string;
1128
    my $now = dt_from_string();
1129
    my $year = $now->year;
1129
    my $year = $now->year;
1130
    my $month = $now->month;
1130
    my $month = $now->month;
1131
    my ($accountlines_id, $accountline);
1131
    my ($accountlines_id, $accountline);
(-)a/t/db_dependent/Koha/Acquisition/Basket.t (-4 / +4 lines)
Lines 27-33 use t::lib::Mocks; Link Here
27
27
28
use C4::Acquisition qw( NewBasket ModBasket ModBasketHeader );
28
use C4::Acquisition qw( NewBasket ModBasket ModBasketHeader );
29
use Koha::Database;
29
use Koha::Database;
30
use Koha::DateUtils qw(dt_from_string);
30
use Koha::DateUtils qw(dt_from_string());
31
31
32
use_ok('Koha::Acquisition::Basket');
32
use_ok('Koha::Acquisition::Basket');
33
use_ok('Koha::Acquisition::Baskets');
33
use_ok('Koha::Acquisition::Baskets');
Lines 161-167 subtest 'to_api() tests' => sub { Link Here
161
    ok( defined $closed, 'closed is defined' );
161
    ok( defined $closed, 'closed is defined' );
162
    ok( !$closed, 'closedate is undef, closed evaluates to false' );
162
    ok( !$closed, 'closedate is undef, closed evaluates to false' );
163
163
164
    $basket->closedate( dt_from_string )->store->discard_changes;
164
    $basket->closedate( dt_from_string() )->store->discard_changes;
165
    $closed = $basket->to_api->{closed};
165
    $closed = $basket->to_api->{closed};
166
    ok( defined $closed, 'closed is defined' );
166
    ok( defined $closed, 'closed is defined' );
167
    ok( $closed, 'closedate is defined, closed evaluates to true' );
167
    ok( $closed, 'closedate is defined, closed evaluates to true' );
Lines 197-203 subtest 'estimated_delivery_date' => sub { Link Here
197
        }
197
        }
198
    );
198
    );
199
199
200
    my $now = dt_from_string;
200
    my $now = dt_from_string();
201
    is( $basket->estimated_delivery_date,
201
    is( $basket->estimated_delivery_date,
202
        undef, 'return undef if closedate and deliverytime are not defined' );
202
        undef, 'return undef if closedate and deliverytime are not defined' );
203
203
Lines 232-238 subtest 'late_since_days' => sub { Link Here
232
        }
232
        }
233
    );
233
    );
234
234
235
    my $now = dt_from_string;
235
    my $now = dt_from_string();
236
    $basket->closedate(undef)->store; # Basket is open
236
    $basket->closedate(undef)->store; # Basket is open
237
    is( $basket->late_since_days, undef, 'return undef if basket is still open');
237
    is( $basket->late_since_days, undef, 'return undef if basket is still open');
238
238
(-)a/t/db_dependent/Koha/Acquisition/Booksellers.t (-2 / +2 lines)
Lines 65-75 subtest '->subscriptions() tests' => sub { Link Here
65
    my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } );
65
    my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } );
66
    is( $vendor->subscriptions->count, 0, 'Vendor has no subscriptions' );
66
    is( $vendor->subscriptions->count, 0, 'Vendor has no subscriptions' );
67
67
68
    my $dt_today = dt_from_string;
68
    my $dt_today = dt_from_string();
69
    my $today    = output_pref(
69
    my $today    = output_pref(
70
        { dt => $dt_today, dateformat => 'iso', timeformat => '24hr', dateonly => 1 } );
70
        { dt => $dt_today, dateformat => 'iso', timeformat => '24hr', dateonly => 1 } );
71
71
72
    my $dt_today1 = dt_from_string;
72
    my $dt_today1 = dt_from_string();
73
    my $dur5 = DateTime::Duration->new( days => -5 );
73
    my $dur5 = DateTime::Duration->new( days => -5 );
74
    $dt_today1->add_duration($dur5);
74
    $dt_today1->add_duration($dur5);
75
    my $daysago5 = output_pref(
75
    my $daysago5 = output_pref(
(-)a/t/db_dependent/Koha/Acquisition/Budgets.t (-1 / +1 lines)
Lines 32-38 $schema->storage->txn_begin; Link Here
32
32
33
my $builder = t::lib::TestBuilder->new;
33
my $builder = t::lib::TestBuilder->new;
34
my $nb_of_budgets= Koha::Acquisition::Budgets->search->count;
34
my $nb_of_budgets= Koha::Acquisition::Budgets->search->count;
35
my $now = dt_from_string;
35
my $now = dt_from_string();
36
my $new_budget = Koha::Acquisition::Budget->new({
36
my $new_budget = Koha::Acquisition::Budget->new({
37
    budget_period_startdate => $now,
37
    budget_period_startdate => $now,
38
    budget_period_enddate => $now,
38
    budget_period_enddate => $now,
(-)a/t/db_dependent/Koha/Acquisition/Invoice.t (-2 / +2 lines)
Lines 25-31 use Test::MockModule; Link Here
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
26
26
27
use Koha::Database;
27
use Koha::Database;
28
use Koha::DateUtils qw(dt_from_string);
28
use Koha::DateUtils qw(dt_from_string());
29
29
30
use_ok('Koha::Acquisition::Invoice');
30
use_ok('Koha::Acquisition::Invoice');
31
31
Lines 57-63 subtest 'to_api() tests' => sub { Link Here
57
    ok( defined $closed, 'closed is defined' );
57
    ok( defined $closed, 'closed is defined' );
58
    ok( !$closed, 'closedate is undef, closed evaluates to false' );
58
    ok( !$closed, 'closedate is undef, closed evaluates to false' );
59
59
60
    $invoice->closedate( dt_from_string )->store->discard_changes;
60
    $invoice->closedate( dt_from_string() )->store->discard_changes;
61
    $closed = $invoice->to_api->{closed};
61
    $closed = $invoice->to_api->{closed};
62
    ok( defined $closed, 'closed is defined' );
62
    ok( defined $closed, 'closed is defined' );
63
    ok( $closed, 'closedate is defined, closed evaluates to true' );
63
    ok( $closed, 'closedate is defined, closed evaluates to true' );
(-)a/t/db_dependent/Koha/Acquisition/Order.t (-5 / +5 lines)
Lines 29-35 use C4::Circulation qw( AddIssue AddReturn ); Link Here
29
29
30
use Koha::Biblios;
30
use Koha::Biblios;
31
use Koha::Database;
31
use Koha::Database;
32
use Koha::DateUtils qw(dt_from_string);
32
use Koha::DateUtils qw(dt_from_string());
33
use Koha::Items;
33
use Koha::Items;
34
34
35
my $schema  = Koha::Database->schema;
35
my $schema  = Koha::Database->schema;
Lines 370-376 subtest 'claim*' => sub { Link Here
370
        }
370
        }
371
    );
371
    );
372
372
373
    my $now = dt_from_string;
373
    my $now = dt_from_string();
374
    is( $order->claims->count, 0, 'No claim yet, ->claims should return an empty set');
374
    is( $order->claims->count, 0, 'No claim yet, ->claims should return an empty set');
375
    is( $order->claims_count, 0, 'No claim yet, ->claims_count should return 0');
375
    is( $order->claims_count, 0, 'No claim yet, ->claims_count should return 0');
376
    is( $order->claimed_date, undef, 'No claim yet, ->claimed_date should return undef');
376
    is( $order->claimed_date, undef, 'No claim yet, ->claimed_date should return undef');
Lines 392-398 subtest 'filter_by_late' => sub { Link Here
392
    plan tests => 16;
392
    plan tests => 16;
393
393
394
    $schema->storage->txn_begin;
394
    $schema->storage->txn_begin;
395
    my $now        = dt_from_string;
395
    my $now        = dt_from_string();
396
    my $bookseller = $builder->build_object(
396
    my $bookseller = $builder->build_object(
397
        {
397
        {
398
            class => 'Koha::Acquisition::Booksellers',
398
            class => 'Koha::Acquisition::Booksellers',
Lines 546-552 subtest 'filter_by_current & filter_by_cancelled' => sub { Link Here
546
    plan tests => 2;
546
    plan tests => 2;
547
547
548
    $schema->storage->txn_begin;
548
    $schema->storage->txn_begin;
549
    my $now        = dt_from_string;
549
    my $now        = dt_from_string();
550
    my $order_1 = $builder->build_object(
550
    my $order_1 = $builder->build_object(
551
        {
551
        {
552
            class => 'Koha::Acquisition::Orders',
552
            class => 'Koha::Acquisition::Orders',
Lines 567-573 subtest 'filter_by_current & filter_by_cancelled' => sub { Link Here
567
        {
567
        {
568
            class => 'Koha::Acquisition::Orders',
568
            class => 'Koha::Acquisition::Orders',
569
            value => {
569
            value => {
570
                datecancellationprinted => dt_from_string,
570
                datecancellationprinted => dt_from_string(),
571
            }
571
            }
572
        }
572
        }
573
    );
573
    );
(-)a/t/db_dependent/Koha/AdditionalContents.t (-2 / +2 lines)
Lines 79-85 subtest '->is_expired' => sub { Link Here
79
79
80
    $schema->storage->txn_begin;
80
    $schema->storage->txn_begin;
81
81
82
    my $today = dt_from_string;
82
    my $today = dt_from_string();
83
    my $yesterday = dt_from_string->add( days => -1 );
83
    my $yesterday = dt_from_string->add( days => -1 );
84
    my $tomorrow = dt_from_string->add( days => 1 );
84
    my $tomorrow = dt_from_string->add( days => 1 );
85
    my $new_today = $builder->build_object({
85
    my $new_today = $builder->build_object({
Lines 163-169 subtest '->search_for_display' => sub { Link Here
163
163
164
    Koha::AdditionalContents->search->delete;
164
    Koha::AdditionalContents->search->delete;
165
165
166
    my $today = dt_from_string;
166
    my $today = dt_from_string();
167
    my $yesterday = dt_from_string->add( days => -1 );
167
    my $yesterday = dt_from_string->add( days => -1 );
168
    my $tomorrow = dt_from_string->add( days => 1 );
168
    my $tomorrow = dt_from_string->add( days => 1 );
169
    my $library1 = $builder->build_object({ class => 'Koha::Libraries' });
169
    my $library1 = $builder->build_object({ class => 'Koha::Libraries' });
(-)a/t/db_dependent/Koha/BackgroundJobs.t (-1 / +1 lines)
Lines 54-60 my $new_job = Koha::BackgroundJobs->find($job_id); Link Here
54
ok( $new_job, 'New job correctly enqueued' );
54
ok( $new_job, 'New job correctly enqueued' );
55
is_deeply( decode_json( $new_job->data ),
55
is_deeply( decode_json( $new_job->data ),
56
    $data, 'data retrieved and json encoded correctly' );
56
    $data, 'data retrieved and json encoded correctly' );
57
is( t::lib::Dates::compare( $new_job->enqueued_on, dt_from_string ),
57
is( t::lib::Dates::compare( $new_job->enqueued_on, dt_from_string() ),
58
    0, 'enqueued_on correctly filled with now()' );
58
    0, 'enqueued_on correctly filled with now()' );
59
is( $new_job->size,   $job_size,    'job size retrieved correctly' );
59
is( $new_job->size,   $job_size,    'job size retrieved correctly' );
60
is( $new_job->status, "new",        'job has not started yet, status is new' );
60
is( $new_job->status, "new",        'job has not started yet, status is new' );
(-)a/t/db_dependent/Koha/Biblios.t (-1 / +1 lines)
Lines 59-65 subtest 'store' => sub { Link Here
59
    is(
59
    is(
60
        Koha::Biblios->find( $biblio->biblionumber )->datecreated,
60
        Koha::Biblios->find( $biblio->biblionumber )->datecreated,
61
        output_pref(
61
        output_pref(
62
            { dt => dt_from_string, dateformat => 'iso', dateonly => 1 }
62
            { dt => dt_from_string(), dateformat => 'iso', dateonly => 1 }
63
        ),
63
        ),
64
        "datecreated must be set to today if not passed to the constructor"
64
        "datecreated must be set to today if not passed to the constructor"
65
    );
65
    );
(-)a/t/db_dependent/Koha/Charges/Fees.t (-1 / +1 lines)
Lines 29-35 use t::lib::Dates; Link Here
29
29
30
use Time::Fake;
30
use Time::Fake;
31
use C4::Calendar qw( new insert_week_day_holiday delete_holiday );
31
use C4::Calendar qw( new insert_week_day_holiday delete_holiday );
32
use Koha::DateUtils qw(dt_from_string);
32
use Koha::DateUtils qw(dt_from_string());
33
33
34
BEGIN {
34
BEGIN {
35
    use_ok('Koha::Charges::Fees');
35
    use_ok('Koha::Charges::Fees');
(-)a/t/db_dependent/Koha/Checkouts.t (-2 / +2 lines)
Lines 239-245 subtest 'Koha::Old::Checkouts->filter_by_todays_checkins' => sub { Link Here
239
        );
239
        );
240
    }
240
    }
241
    # Checkin 4 today
241
    # Checkin 4 today
242
    my $today = dt_from_string;
242
    my $today = dt_from_string();
243
    for my $i ( 3 .. 6 ) {
243
    for my $i ( 3 .. 6 ) {
244
        my $checkout = $checkouts[$i];
244
        my $checkout = $checkouts[$i];
245
        C4::Circulation::AddReturn(
245
        C4::Circulation::AddReturn(
Lines 287-293 subtest 'automatic_checkin' => sub { Link Here
287
    $ac_item->itemtype->automatic_checkin(1)->store;
287
    $ac_item->itemtype->automatic_checkin(1)->store;
288
    $normal_item->itemtype->automatic_checkin(0)->store;
288
    $normal_item->itemtype->automatic_checkin(0)->store;
289
289
290
    my $today     = dt_from_string;
290
    my $today     = dt_from_string();
291
    my $tomorrow  = dt_from_string->add( days => 1 );
291
    my $tomorrow  = dt_from_string->add( days => 1 );
292
    my $yesterday = dt_from_string->subtract( days => 1 );
292
    my $yesterday = dt_from_string->subtract( days => 1 );
293
293
(-)a/t/db_dependent/Koha/Checkouts/ReturnClaim.t (-1 / +1 lines)
Lines 208-214 subtest "resolve() tests" => sub { Link Here
208
        close STDERR;
208
        close STDERR;
209
    }
209
    }
210
210
211
    my $today    = dt_from_string;
211
    my $today    = dt_from_string();
212
    my $tomorrow = dt_from_string->add( days => 1 );
212
    my $tomorrow = dt_from_string->add( days => 1 );
213
213
214
    $claim->resolve(
214
    $claim->resolve(
(-)a/t/db_dependent/Koha/Club/Enrollment.t (-1 / +1 lines)
Lines 24-30 use Test::Exception; Link Here
24
24
25
use Koha::Patron;
25
use Koha::Patron;
26
use Koha::Database;
26
use Koha::Database;
27
use Koha::DateUtils qw(dt_from_string);
27
use Koha::DateUtils qw(dt_from_string());
28
28
29
use t::lib::TestBuilder;
29
use t::lib::TestBuilder;
30
30
(-)a/t/db_dependent/Koha/Club/Hold.t (-2 / +2 lines)
Lines 27-33 use Koha::Club::Hold; Link Here
27
use Koha::Club::Hold::PatronHolds;
27
use Koha::Club::Hold::PatronHolds;
28
use Koha::Holds;
28
use Koha::Holds;
29
use Koha::Database;
29
use Koha::Database;
30
use Koha::DateUtils qw(dt_from_string);
30
use Koha::DateUtils qw(dt_from_string());
31
use Scalar::Util qw(blessed);
31
use Scalar::Util qw(blessed);
32
32
33
use t::lib::TestBuilder;
33
use t::lib::TestBuilder;
Lines 109-115 subtest 'add' => sub { Link Here
109
109
110
    is(blessed($club_hold), 'Koha::Club::Hold', 'add returns a Koha::Club::Hold');
110
    is(blessed($club_hold), 'Koha::Club::Hold', 'add returns a Koha::Club::Hold');
111
111
112
    $e->date_canceled(dt_from_string)->store;
112
    $e->date_canceled(dt_from_string())->store;
113
113
114
    throws_ok {
114
    throws_ok {
115
        Koha::Club::Hold::add(
115
        Koha::Club::Hold::add(
(-)a/t/db_dependent/Koha/Item.t (-2 / +2 lines)
Lines 522-528 subtest 'request_transfer' => sub { Link Here
522
    is($transfers->count, 2, "There are now 2 live transfers in the queue");
522
    is($transfers->count, 2, "There are now 2 live transfers in the queue");
523
    $transfer = $transfer->get_from_storage;
523
    $transfer = $transfer->get_from_storage;
524
    is_deeply($transfer->unblessed, $original_transfer->unblessed, "Original transfer unchanged");
524
    is_deeply($transfer->unblessed, $original_transfer->unblessed, "Original transfer unchanged");
525
    $queued_transfer->datearrived(dt_from_string)->store();
525
    $queued_transfer->datearrived(dt_from_string())->store();
526
526
527
    # Replace transfer
527
    # Replace transfer
528
    my $replaced_transfer = $item->request_transfer(
528
    my $replaced_transfer = $item->request_transfer(
Lines 533-539 subtest 'request_transfer' => sub { Link Here
533
    ok($original_transfer->datecancelled, "Original transfer cancelled");
533
    ok($original_transfer->datecancelled, "Original transfer cancelled");
534
    $transfers = $item->get_transfers;
534
    $transfers = $item->get_transfers;
535
    is($transfers->count, 1, "There is only 1 live transfer in the queue");
535
    is($transfers->count, 1, "There is only 1 live transfer in the queue");
536
    $replaced_transfer->datearrived(dt_from_string)->store();
536
    $replaced_transfer->datearrived(dt_from_string())->store();
537
537
538
    # BranchTransferLimits
538
    # BranchTransferLimits
539
    t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1);
539
    t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1);
(-)a/t/db_dependent/Koha/Item/Transfer.t (-5 / +5 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::DateUtils;
23
use Koha::DateUtils qw( dt_from_string );
24
24
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
26
26
Lines 235-253 subtest 'in_transit tests' => sub { Link Here
235
            itemnumber    => $item->itemnumber,
235
            itemnumber    => $item->itemnumber,
236
            frombranch    => $library_from->branchcode,
236
            frombranch    => $library_from->branchcode,
237
            tobranch      => $library_to->branchcode,
237
            tobranch      => $library_to->branchcode,
238
            daterequested => dt_from_string,
238
            daterequested => dt_from_string(),
239
        }
239
        }
240
    )->store;
240
    )->store;
241
241
242
    ok( !$transfer->in_transit, 'in_transit returns false when only daterequested is defined' );
242
    ok( !$transfer->in_transit, 'in_transit returns false when only daterequested is defined' );
243
243
244
    $transfer->datesent(dt_from_string)->store;
244
    $transfer->datesent(dt_from_string())->store;
245
    ok( $transfer->in_transit, 'in_transit returns true when datesent is defined');
245
    ok( $transfer->in_transit, 'in_transit returns true when datesent is defined');
246
246
247
    $transfer->datearrived(dt_from_string)->store;
247
    $transfer->datearrived(dt_from_string())->store;
248
    ok( !$transfer->in_transit, 'in_transit returns false when datearrived is defined');
248
    ok( !$transfer->in_transit, 'in_transit returns false when datearrived is defined');
249
249
250
    $transfer->set( { datearrived => undef, datecancelled => dt_from_string } )->store;
250
    $transfer->set( { datearrived => undef, datecancelled => dt_from_string() } )->store;
251
    ok( !$transfer->in_transit, 'in_transit returns false when datecancelled is defined');
251
    ok( !$transfer->in_transit, 'in_transit returns false when datecancelled is defined');
252
252
253
    $schema->storage->txn_rollback;
253
    $schema->storage->txn_rollback;
(-)a/t/db_dependent/Koha/Item/Transfers.t (-4 / +4 lines)
Lines 47-54 my $new_transfer_1 = Koha::Item::Transfer->new( Link Here
47
    {   itemnumber  => $item->itemnumber,
47
    {   itemnumber  => $item->itemnumber,
48
        frombranch  => $library_from->{branchcode},
48
        frombranch  => $library_from->{branchcode},
49
        tobranch    => $library_to->{branchcode},
49
        tobranch    => $library_to->{branchcode},
50
        datearrived => dt_from_string,
50
        datearrived => dt_from_string(),
51
        datesent    => dt_from_string,
51
        datesent    => dt_from_string(),
52
    }
52
    }
53
)->store;
53
)->store;
54
my $new_transfer_2 = Koha::Item::Transfer->new(
54
my $new_transfer_2 = Koha::Item::Transfer->new(
Lines 56-62 my $new_transfer_2 = Koha::Item::Transfer->new( Link Here
56
        frombranch  => $library_from->{branchcode},
56
        frombranch  => $library_from->{branchcode},
57
        tobranch    => $library_to->{branchcode},
57
        tobranch    => $library_to->{branchcode},
58
        datearrived => undef,
58
        datearrived => undef,
59
        datesent    => dt_from_string,
59
        datesent    => dt_from_string(),
60
    }
60
    }
61
)->store;
61
)->store;
62
62
Lines 86-92 subtest 'daterequested tests' => sub { Link Here
86
        }
86
        }
87
    );
87
    );
88
88
89
    my $now = dt_from_string;
89
    my $now = dt_from_string();
90
    my $transfer = Koha::Item::Transfer->new(
90
    my $transfer = Koha::Item::Transfer->new(
91
        {
91
        {
92
            itemnumber => $item->itemnumber,
92
            itemnumber => $item->itemnumber,
(-)a/t/db_dependent/Koha/ItemTypes.t (-1 / +1 lines)
Lines 29-35 use C4::Calendar qw( new ); Link Here
29
use Koha::Biblioitems;
29
use Koha::Biblioitems;
30
use Koha::Libraries;
30
use Koha::Libraries;
31
use Koha::Database;
31
use Koha::Database;
32
use Koha::DateUtils qw(dt_from_string);;
32
use Koha::DateUtils qw(dt_from_string());;
33
use Koha::Items;
33
use Koha::Items;
34
34
35
BEGIN {
35
BEGIN {
(-)a/t/db_dependent/Koha/Object.t (-1 / +1 lines)
Lines 154-160 subtest 'discard_changes' => sub { Link Here
154
154
155
    my $patron = $builder->build( { source => 'Borrower' } );
155
    my $patron = $builder->build( { source => 'Borrower' } );
156
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
156
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
157
    $patron->dateexpiry(dt_from_string);
157
    $patron->dateexpiry(dt_from_string());
158
    $patron->discard_changes;
158
    $patron->discard_changes;
159
    is(
159
    is(
160
        dt_from_string( $patron->dateexpiry ),
160
        dt_from_string( $patron->dateexpiry ),
(-)a/t/db_dependent/Koha/Objects.t (-1 / +1 lines)
Lines 1070-1076 subtest "filter_by_last_update" => sub { Link Here
1070
1070
1071
    $schema->storage->txn_begin;
1071
    $schema->storage->txn_begin;
1072
1072
1073
    my $now = dt_from_string->truncate( to => 'day' );
1073
    my $now = dt_from_string()->truncate( to => 'day' );
1074
    my @borrowernumbers;
1074
    my @borrowernumbers;
1075
    # Building 6 patrons that have been created today, yesterday, ... 1 per day
1075
    # Building 6 patrons that have been created today, yesterday, ... 1 per day
1076
    for my $i ( 0 .. 5 ) {
1076
    for my $i ( 0 .. 5 ) {
(-)a/t/db_dependent/Koha/Patron.t (-1 / +1 lines)
Lines 24-30 use Test::Exception; Link Here
24
use Test::Warn;
24
use Test::Warn;
25
25
26
use Koha::Database;
26
use Koha::Database;
27
use Koha::DateUtils qw(dt_from_string);
27
use Koha::DateUtils qw(dt_from_string());
28
use Koha::Patrons;
28
use Koha::Patrons;
29
use Koha::Patron::Relationships;
29
use Koha::Patron::Relationships;
30
30
(-)a/t/db_dependent/Koha/Patron/Consents.t (-1 / +1 lines)
Lines 38-44 subtest 'Basic tests for Koha::Patron::Consent' => sub { Link Here
38
    my $consent1 = Koha::Patron::Consent->new({
38
    my $consent1 = Koha::Patron::Consent->new({
39
        borrowernumber => $patron1->borrowernumber,
39
        borrowernumber => $patron1->borrowernumber,
40
        type => 'GDPR_PROCESSING',
40
        type => 'GDPR_PROCESSING',
41
        given_on => dt_from_string,
41
        given_on => dt_from_string(),
42
    })->store;
42
    })->store;
43
    is( Koha::Patron::Consents->search({ borrowernumber => $patron1->borrowernumber })->count, 1, 'One consent for new borrower' );
43
    is( Koha::Patron::Consents->search({ borrowernumber => $patron1->borrowernumber })->count, 1, 'One consent for new borrower' );
44
    $consent1->delete;
44
    $consent1->delete;
(-)a/t/db_dependent/Koha/Patrons.t (-4 / +4 lines)
Lines 42-48 use Koha::Patron::Attribute::Types; Link Here
42
use Koha::Patron::Categories;
42
use Koha::Patron::Categories;
43
use Koha::Patron::Relationship;
43
use Koha::Patron::Relationship;
44
use Koha::Database;
44
use Koha::Database;
45
use Koha::DateUtils;
45
use Koha::DateUtils qw( dt_from_string );
46
use Koha::Virtualshelves;
46
use Koha::Virtualshelves;
47
use Koha::Notice::Messages;
47
use Koha::Notice::Messages;
48
48
Lines 293-299 subtest 'is_expired' => sub { Link Here
293
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
293
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
294
    $patron->dateexpiry( undef )->store->discard_changes;
294
    $patron->dateexpiry( undef )->store->discard_changes;
295
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not set');
295
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not set');
296
    $patron->dateexpiry( dt_from_string )->store->discard_changes;
296
    $patron->dateexpiry( dt_from_string() )->store->discard_changes;
297
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is today');
297
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is today');
298
    $patron->dateexpiry( dt_from_string->add( days => 1 ) )->store->discard_changes;
298
    $patron->dateexpiry( dt_from_string->add( days => 1 ) )->store->discard_changes;
299
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is tomorrow');
299
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is tomorrow');
Lines 1935-1941 subtest 'search_unsubscribed' => sub { Link Here
1935
1935
1936
    t::lib::Mocks::mock_preference( 'UnsubscribeReflectionDelay', 0 );
1936
    t::lib::Mocks::mock_preference( 'UnsubscribeReflectionDelay', 0 );
1937
    Koha::Patron::Consents->delete; # for correct counts
1937
    Koha::Patron::Consents->delete; # for correct counts
1938
    Koha::Patron::Consent->new({ borrowernumber => $patron1->borrowernumber, type => 'GDPR_PROCESSING',  refused_on => dt_from_string })->store;
1938
    Koha::Patron::Consent->new({ borrowernumber => $patron1->borrowernumber, type => 'GDPR_PROCESSING',  refused_on => dt_from_string() })->store;
1939
    is( Koha::Patrons->search_unsubscribed->count, 1, 'Find patron1' );
1939
    is( Koha::Patrons->search_unsubscribed->count, 1, 'Find patron1' );
1940
1940
1941
    # Add another refusal but shift the period
1941
    # Add another refusal but shift the period
Lines 2012-2018 subtest 'search_anonymized' => sub { Link Here
2012
    is( Koha::Patrons->search_anonymized->count, 0, 'Empty set' );
2012
    is( Koha::Patrons->search_anonymized->count, 0, 'Empty set' );
2013
2013
2014
    t::lib::Mocks::mock_preference( 'PatronRemovalDelay', 1 );
2014
    t::lib::Mocks::mock_preference( 'PatronRemovalDelay', 1 );
2015
    $patron1->dateexpiry( dt_from_string );
2015
    $patron1->dateexpiry( dt_from_string() );
2016
    $patron1->anonymized(0)->store;
2016
    $patron1->anonymized(0)->store;
2017
    my $cnt = Koha::Patrons->search_anonymized->count;
2017
    my $cnt = Koha::Patrons->search_anonymized->count;
2018
    $patron1->anonymized(1)->store;
2018
    $patron1->anonymized(1)->store;
(-)a/t/db_dependent/Koha/Pseudonymization.t (-4 / +4 lines)
Lines 84-91 subtest 'Koha::Anonymized::Transactions tests' => sub { Link Here
84
    t::lib::Mocks::mock_preference( 'Pseudonymization', 0 );
84
    t::lib::Mocks::mock_preference( 'Pseudonymization', 0 );
85
    my $item = $builder->build_sample_item;
85
    my $item = $builder->build_sample_item;
86
    t::lib::Mocks::mock_userenv({ branchcode => $item->homebranch });
86
    t::lib::Mocks::mock_userenv({ branchcode => $item->homebranch });
87
    AddIssue( $patron->unblessed, $item->barcode, dt_from_string );
87
    AddIssue( $patron->unblessed, $item->barcode, dt_from_string() );
88
    AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string );
88
    AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string() );
89
    my $pseudonymized= Koha::PseudonymizedTransactions->search(
89
    my $pseudonymized= Koha::PseudonymizedTransactions->search(
90
        { itemnumber => $item->itemnumber } )->next;
90
        { itemnumber => $item->itemnumber } )->next;
91
    is( $pseudonymized, undef,
91
    is( $pseudonymized, undef,
Lines 96-103 subtest 'Koha::Anonymized::Transactions tests' => sub { Link Here
96
    );
96
    );
97
    $item = $builder->build_sample_item;
97
    $item = $builder->build_sample_item;
98
    t::lib::Mocks::mock_userenv({ branchcode => $item->homebranch });
98
    t::lib::Mocks::mock_userenv({ branchcode => $item->homebranch });
99
    AddIssue( $patron->unblessed, $item->barcode, dt_from_string );
99
    AddIssue( $patron->unblessed, $item->barcode, dt_from_string() );
100
    AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string );
100
    AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string() );
101
    my $statistic = Koha::Statistics->search( { itemnumber => $item->itemnumber } )->next;
101
    my $statistic = Koha::Statistics->search( { itemnumber => $item->itemnumber } )->next;
102
    $pseudonymized = Koha::PseudonymizedTransactions->search( { itemnumber => $item->itemnumber } )->next;
102
    $pseudonymized = Koha::PseudonymizedTransactions->search( { itemnumber => $item->itemnumber } )->next;
103
    like( $pseudonymized->hashed_borrowernumber,
103
    like( $pseudonymized->hashed_borrowernumber,
(-)a/t/db_dependent/Koha/Quotes.t (-3 / +3 lines)
Lines 19-25 use Modern::Perl; Link Here
19
use Test::More tests => 14;
19
use Test::More tests => 14;
20
20
21
use Koha::Database;
21
use Koha::Database;
22
use Koha::DateUtils qw(dt_from_string);
22
use Koha::DateUtils qw(dt_from_string());
23
use Koha::Quote;
23
use Koha::Quote;
24
use Koha::Quotes;
24
use Koha::Quotes;
25
25
Lines 66-72 t::lib::Mocks::mock_preference('QuoteOfTheDay', 'opac,intranet'); Link Here
66
$quote = Koha::Quotes->get_daily_quote('id'=>$quote_3->id);
66
$quote = Koha::Quotes->get_daily_quote('id'=>$quote_3->id);
67
is($quote->id, $quote_3->id, "Correctly got quote by ID");
67
is($quote->id, $quote_3->id, "Correctly got quote by ID");
68
is($quote->text, $quote_3->text, "Quote is correct");
68
is($quote->text, $quote_3->text, "Quote is correct");
69
is(t::lib::Dates::compare($quote->timestamp, dt_from_string), 0, "get_daily_quote updated the timestamp/last seen");
69
is(t::lib::Dates::compare($quote->timestamp, dt_from_string()), 0, "get_daily_quote updated the timestamp/last seen");
70
70
71
$quote = Koha::Quotes->get_daily_quote('random'=>1);
71
$quote = Koha::Quotes->get_daily_quote('random'=>1);
72
ok($quote, "Got a random quote.");
72
ok($quote, "Got a random quote.");
Lines 77-83 subtest 'timestamp column is updated' => sub { Link Here
77
77
78
    Koha::Quotes->search->update( { timestamp => $yesterday } );
78
    Koha::Quotes->search->update( { timestamp => $yesterday } );
79
79
80
    my $now = dt_from_string;
80
    my $now = dt_from_string();
81
81
82
    my $expected_quote = {
82
    my $expected_quote = {
83
        id          => $quote_3->id,
83
        id          => $quote_3->id,
(-)a/t/db_dependent/Letters.t (-2 / +2 lines)
Lines 77-83 my $library = $builder->build({ Link Here
77
    }
77
    }
78
});
78
});
79
my $patron_category = $builder->build({ source => 'Category' })->{categorycode};
79
my $patron_category = $builder->build({ source => 'Category' })->{categorycode};
80
my $date = dt_from_string;
80
my $date = dt_from_string();
81
my $borrowernumber = Koha::Patron->new({
81
my $borrowernumber = Koha::Patron->new({
82
    firstname    => 'Jane',
82
    firstname    => 'Jane',
83
    surname      => 'Smith',
83
    surname      => 'Smith',
Lines 631-637 subtest 'SendAlerts - claimissue' => sub { Link Here
631
    }
631
    }
632
632
633
    {
633
    {
634
    my $publisheddate = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
634
    my $publisheddate = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 });
635
    my $serialexpected = ( C4::Serials::findSerialsByStatus( 1, $subscriptionid ) )[0];
635
    my $serialexpected = ( C4::Serials::findSerialsByStatus( 1, $subscriptionid ) )[0];
636
    ModSerialStatus( $serials[0]->{serialid}, "No. 1", $publisheddate, $publisheddate, $publisheddate, '3', 'a note' );
636
    ModSerialStatus( $serials[0]->{serialid}, "No. 1", $publisheddate, $publisheddate, $publisheddate, '3', 'a note' );
637
    ($serials_count, @serials) = GetSerials($subscriptionid);
637
    ($serials_count, @serials) = GetSerials($subscriptionid);
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-1 / +1 lines)
Lines 625-631 EOF Link Here
625
        plan tests => 3;
625
        plan tests => 3;
626
626
627
        my $code = 'ISSUESLIP';
627
        my $code = 'ISSUESLIP';
628
        my $now = dt_from_string;
628
        my $now = dt_from_string();
629
        my $one_minute_ago = dt_from_string->subtract( minutes => 1 );
629
        my $one_minute_ago = dt_from_string->subtract( minutes => 1 );
630
630
631
        my $branchcode = $library->{branchcode};
631
        my $branchcode = $library->{branchcode};
(-)a/t/db_dependent/Members/IssueSlip.t (-3 / +3 lines)
Lines 123-129 my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; Link Here
123
my $module = Test::MockModule->new('C4::Context');
123
my $module = Test::MockModule->new('C4::Context');
124
$module->mock( 'userenv', sub { { branch => $branchcode } } );
124
$module->mock( 'userenv', sub { { branch => $branchcode } } );
125
125
126
my $today = dt_from_string;
126
my $today = dt_from_string();
127
my $yesterday = dt_from_string->subtract_duration( DateTime::Duration->new( days => 1 ) );
127
my $yesterday = dt_from_string->subtract_duration( DateTime::Duration->new( days => 1 ) );
128
128
129
subtest 'Issue slip' => sub {
129
subtest 'Issue slip' => sub {
Lines 165-171 EOS Link Here
165
        # Set timestamps to the same value to avoid a different order
165
        # Set timestamps to the same value to avoid a different order
166
        Koha::Checkouts->search(
166
        Koha::Checkouts->search(
167
            { borrowernumber => $borrower->{borrowernumber} }
167
            { borrowernumber => $borrower->{borrowernumber} }
168
        )->update( { timestamp => dt_from_string } );
168
        )->update( { timestamp => dt_from_string() } );
169
169
170
        $expected_slip = <<EOS;
170
        $expected_slip = <<EOS;
171
Checked out:
171
Checked out:
Lines 238-244 EOS Link Here
238
        # Set timestamps to the same value to avoid a different order
238
        # Set timestamps to the same value to avoid a different order
239
        Koha::Checkouts->search(
239
        Koha::Checkouts->search(
240
            { borrowernumber => $borrower->{borrowernumber} }
240
            { borrowernumber => $borrower->{borrowernumber} }
241
        )->update( { timestamp => dt_from_string } );
241
        )->update( { timestamp => dt_from_string() } );
242
242
243
        $expected_slip = <<EOS;
243
        $expected_slip = <<EOS;
244
Checked out:
244
Checked out:
(-)a/t/db_dependent/Patrons.t (-1 / +1 lines)
Lines 50-56 my $b1 = Koha::Patron->new( Link Here
50
    }
50
    }
51
);
51
);
52
$b1->store();
52
$b1->store();
53
my $now = dt_from_string;
53
my $now = dt_from_string();
54
my $b2 = Koha::Patron->new(
54
my $b2 = Koha::Patron->new(
55
    {
55
    {
56
        surname      => 'Test 2',
56
        surname      => 'Test 2',
(-)a/t/db_dependent/Reserves.t (-3 / +3 lines)
Lines 432-438 AddReserve( Link Here
432
432
433
$holds = $item->current_holds;
433
$holds = $item->current_holds;
434
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
434
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
435
my $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
435
my $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string() ) } } );
436
is( $future_holds->count, 0, 'current_holds does not return a future next available hold');
436
is( $future_holds->count, 0, 'current_holds does not return a future next available hold');
437
# 9788b: current_holds does not return future item level hold
437
# 9788b: current_holds does not return future item level hold
438
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
438
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
Lines 446-456 AddReserve( Link Here
446
        itemnumber       => $item->itemnumber,
446
        itemnumber       => $item->itemnumber,
447
    }
447
    }
448
); #item level hold
448
); #item level hold
449
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
449
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string() ) } } );
450
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' );
450
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' );
451
# 9788c: current_holds returns future wait (confirmed future hold)
451
# 9788c: current_holds returns future wait (confirmed future hold)
452
ModReserveAffect( $item->itemnumber,  $requesters{$branch_1} , 0); #confirm hold
452
ModReserveAffect( $item->itemnumber,  $requesters{$branch_1} , 0); #confirm hold
453
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
453
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string() ) } } );
454
is( $future_holds->count, 1, 'current_holds returns a future wait (confirmed future hold)' );
454
is( $future_holds->count, 1, 'current_holds returns a future wait (confirmed future hold)' );
455
# End of tests for bug 9788
455
# End of tests for bug 9788
456
456
(-)a/t/db_dependent/SIP/Message.t (-3 / +3 lines)
Lines 245-251 subtest "Test cr_item_field" => sub { Link Here
245
        shift;
245
        shift;
246
        return C4::SIP::ILS->checkin(@_);
246
        return C4::SIP::ILS->checkin(@_);
247
    });
247
    });
248
    my $today = dt_from_string;
248
    my $today = dt_from_string();
249
249
250
    my $respcode;
250
    my $respcode;
251
251
Lines 587-593 sub test_checkout_v2 { Link Here
587
        shift;
587
        shift;
588
        return C4::SIP::ILS->checkout(@_);
588
        return C4::SIP::ILS->checkout(@_);
589
    });
589
    });
590
    my $today = dt_from_string;
590
    my $today = dt_from_string();
591
    t::lib::Mocks::mock_userenv({ branchcode => $branchcode, flags => 1 });
591
    t::lib::Mocks::mock_userenv({ branchcode => $branchcode, flags => 1 });
592
    t::lib::Mocks::mock_preference( 'CheckPrevCheckout',  'hardyes' );
592
    t::lib::Mocks::mock_preference( 'CheckPrevCheckout',  'hardyes' );
593
593
Lines 650-656 sub test_checkin_v2 { Link Here
650
        shift;
650
        shift;
651
        return C4::SIP::ILS->checkin(@_);
651
        return C4::SIP::ILS->checkin(@_);
652
    });
652
    });
653
    my $today = dt_from_string;
653
    my $today = dt_from_string();
654
654
655
    # Checkin invalid barcode
655
    # Checkin invalid barcode
656
    Koha::Items->search({ barcode => 'not_to_be_found' })->delete;
656
    Koha::Items->search({ barcode => 'not_to_be_found' })->delete;
(-)a/t/db_dependent/SIP/Transaction.t (-2 / +2 lines)
Lines 462-468 subtest checkin_lost => sub { Link Here
462
        }
462
        }
463
    );
463
    );
464
464
465
    $item->itemlost(1)->itemlost_on(dt_from_string)->store();
465
    $item->itemlost(1)->itemlost_on(dt_from_string())->store();
466
466
467
    my $instituation = {
467
    my $instituation = {
468
        id             => $library->id,
468
        id             => $library->id,
Lines 500-506 subtest checkin_withdrawn => sub { Link Here
500
        }
500
        }
501
    );
501
    );
502
502
503
    $item->withdrawn(1)->withdrawn_on(dt_from_string)->store();
503
    $item->withdrawn(1)->withdrawn_on(dt_from_string())->store();
504
504
505
    my $instituation = {
505
    my $instituation = {
506
        id             => $library->id,
506
        id             => $library->id,
(-)a/t/db_dependent/Search/History.t (-2 / +2 lines)
Lines 224-230 C4::Search::History::add( { Link Here
224
});
224
});
225
my $search_history_id = $dbh->last_insert_id( undef, undef, 'search_history', undef );
225
my $search_history_id = $dbh->last_insert_id( undef, undef, 'search_history', undef );
226
my $search_history = C4::Search::History::get({ id => $search_history_id });
226
my $search_history = C4::Search::History::get({ id => $search_history_id });
227
is( output_pref({ dt => dt_from_string($search_history->[0]->{time}), dateonly => 1 }), output_pref({ dt => dt_from_string, dateonly => 1 }), "Inserting a new search history should handle undefined time" );
227
is( output_pref({ dt => dt_from_string($search_history->[0]->{time}), dateonly => 1 }), output_pref({ dt => dt_from_string(), dateonly => 1 }), "Inserting a new search history should handle undefined time" );
228
228
229
229
230
delete_all( $userid );
230
delete_all( $userid );
Lines 378-384 $session->flush; Link Here
378
sub myMockedget_from_session {
378
sub myMockedget_from_session {
379
    my $expected_recent_searches = [
379
    my $expected_recent_searches = [
380
        {
380
        {
381
            'time' => dt_from_string,
381
            'time' => dt_from_string(),
382
            'query_cgi' => 'cgi_test',
382
            'query_cgi' => 'cgi_test',
383
            'total' => 2,
383
            'total' => 2,
384
            'query_desc' => 'kw,wrdl: history, '
384
            'query_desc' => 'kw,wrdl: history, '
(-)a/t/db_dependent/Serials.t (-2 / +2 lines)
Lines 240-246 is(C4::Serials::GetLateOrMissingIssues(), undef, 'test getting last or missing i Link Here
240
subtest 'test_updateClaim' => sub {
240
subtest 'test_updateClaim' => sub {
241
    plan tests => 11;
241
    plan tests => 11;
242
242
243
    my $today = output_pref({ dt => dt_from_string, dateonly => 1 });
243
    my $today = output_pref({ dt => dt_from_string(), dateonly => 1 });
244
    # Given ... nothing much
244
    # Given ... nothing much
245
    # When ... Then ...
245
    # When ... Then ...
246
    my $result_0 = C4::Serials::updateClaim(undef);
246
    my $result_0 = C4::Serials::updateClaim(undef);
Lines 335-341 is( @serials, 1, "GetSerials returns the serial" ); Link Here
335
my $subscription = C4::Serials::GetSubscription($subscriptionid);
335
my $subscription = C4::Serials::GetSubscription($subscriptionid);
336
my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
336
my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
337
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
337
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
338
my $publisheddate = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
338
my $publisheddate = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 });
339
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
339
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
340
$frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
340
$frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
341
my $nextpublisheddate = C4::Serials::GetNextDate($subscription, $publisheddate, $frequency, 1);
341
my $nextpublisheddate = C4::Serials::GetNextDate($subscription, $publisheddate, $frequency, 1);
(-)a/t/db_dependent/Serials/Claims.t (-1 / +1 lines)
Lines 159-164 is( $serial_claimed->{claims_count}, 2, 'The serial should have been claimed' ); Link Here
159
is( $serial_claimed->{claims_count}, 1, 'The serial should have been claimed' );
159
is( $serial_claimed->{claims_count}, 1, 'The serial should have been claimed' );
160
160
161
161
162
my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
162
my $today = output_pref({ dt => dt_from_string(), dateformat => 'iso', dateonly => 1 });
163
# FIXME: This test should pass. The GetLateOrMissingIssues should not deal with date format!
163
# FIXME: This test should pass. The GetLateOrMissingIssues should not deal with date format!
164
#is( $serial_claimed->{claimdate}, $today, 'The serial should have been claimed today' );
164
#is( $serial_claimed->{claimdate}, $today, 'The serial should have been claimed today' );
(-)a/t/db_dependent/Suggestions.t (-4 / +4 lines)
Lines 101-107 my $my_suggestion = { Link Here
101
    branchcode    => 'CPL',
101
    branchcode    => 'CPL',
102
    managedby     => '',
102
    managedby     => '',
103
    manageddate   => '',
103
    manageddate   => '',
104
    accepteddate  => dt_from_string,
104
    accepteddate  => dt_from_string(),
105
    note          => 'my note',
105
    note          => 'my note',
106
    quantity      => '', # Insert an empty string into int to catch strict SQL modes errors
106
    quantity      => '', # Insert an empty string into int to catch strict SQL modes errors
107
};
107
};
Lines 129-135 my $my_suggestion_with_budget = { Link Here
129
    biblionumber  => $biblio_1->biblionumber,
129
    biblionumber  => $biblio_1->biblionumber,
130
    managedby     => '',
130
    managedby     => '',
131
    manageddate   => '',
131
    manageddate   => '',
132
    accepteddate  => dt_from_string,
132
    accepteddate  => dt_from_string(),
133
    note          => 'my note',
133
    note          => 'my note',
134
    budgetid      => $budget_id,
134
    budgetid      => $budget_id,
135
};
135
};
Lines 141-147 my $my_suggestion_with_budget2 = { Link Here
141
    biblionumber  => $biblio_1->biblionumber,
141
    biblionumber  => $biblio_1->biblionumber,
142
    managedby     => '',
142
    managedby     => '',
143
    manageddate   => '',
143
    manageddate   => '',
144
    accepteddate  => dt_from_string,
144
    accepteddate  => dt_from_string(),
145
    note          => 'my note',
145
    note          => 'my note',
146
    budgetid      => $budget_id,
146
    budgetid      => $budget_id,
147
};
147
};
Lines 154-160 my $my_suggestion_without_suggestedby = { Link Here
154
    branchcode    => 'CPL',
154
    branchcode    => 'CPL',
155
    managedby     => '',
155
    managedby     => '',
156
    manageddate   => '',
156
    manageddate   => '',
157
    accepteddate  => dt_from_string,
157
    accepteddate  => dt_from_string(),
158
    note          => 'my note',
158
    note          => 'my note',
159
    quantity      => '', # Insert an empty string into int to catch strict SQL modes errors
159
    quantity      => '', # Insert an empty string into int to catch strict SQL modes errors
160
};
160
};
(-)a/t/db_dependent/Template/Plugin/KohaDates.t (-1 / +1 lines)
Lines 53-59 is( $filtered_date, '01/04/1979', 'us: dt_from_string should return the valid da Link Here
53
$filtered_date = $filter->filter('1979-04-01', undef, { dateformat => 'iso' } );
53
$filtered_date = $filter->filter('1979-04-01', undef, { dateformat => 'iso' } );
54
is( $filtered_date, '1979-04-01', 'date should be returned in ISO if dateformat is passed with a value of iso' );
54
is( $filtered_date, '1979-04-01', 'date should be returned in ISO if dateformat is passed with a value of iso' );
55
55
56
is( Koha::DateUtils::output_pref( dt_from_string ), $filter->output_preference( dt_from_string ), 'Filter output_preference method output matches output_pref' );
56
is( Koha::DateUtils::output_pref( dt_from_string() ), $filter->output_preference( dt_from_string() ), 'Filter output_preference method output matches output_pref' );
57
57
58
$module_context->mock(
58
$module_context->mock(
59
    'tz',
59
    'tz',
(-)a/t/db_dependent/Upload.t (-1 / +1 lines)
Lines 287-293 subtest 'Testing delete_temporary' => sub { Link Here
287
287
288
    # Move all permanents to today - 1
288
    # Move all permanents to today - 1
289
    # Move temp 1 to today - 3, and temp 2,3 to today - 5
289
    # Move temp 1 to today - 3, and temp 2,3 to today - 5
290
    my $today = dt_from_string;
290
    my $today = dt_from_string();
291
    $today->subtract( minutes => 2 ); # should be enough :)
291
    $today->subtract( minutes => 2 ); # should be enough :)
292
    my $dt = $today->clone->subtract( days => 1 );
292
    my $dt = $today->clone->subtract( days => 1 );
293
    foreach my $rec ( Koha::UploadedFiles->search({ permanent => 1 }) ) {
293
    foreach my $rec ( Koha::UploadedFiles->search({ permanent => 1 }) ) {
(-)a/t/db_dependent/Virtualshelves.t (-2 / +2 lines)
Lines 44-50 subtest 'CRUD' => sub { Link Here
44
    is( $number_of_shelves, 1, '1 shelf should have been inserted' );
44
    is( $number_of_shelves, 1, '1 shelf should have been inserted' );
45
    is( $shelf->allow_change_from_owner, 1, 'The default value for allow_change_from_owner should be 1' );
45
    is( $shelf->allow_change_from_owner, 1, 'The default value for allow_change_from_owner should be 1' );
46
    is( $shelf->allow_change_from_others, 0, 'The default value for allow_change_from_others should be 0' );
46
    is( $shelf->allow_change_from_others, 0, 'The default value for allow_change_from_others should be 0' );
47
    is( t::lib::Dates::compare( $shelf->created_on, dt_from_string), 0, 'The creation time should have been set to today' );
47
    is( t::lib::Dates::compare( $shelf->created_on, dt_from_string()), 0, 'The creation time should have been set to today' );
48
48
49
    # Test if creation date will not be overwritten by store
49
    # Test if creation date will not be overwritten by store
50
    my $created = dt_from_string->subtract( hours => 1 );
50
    my $created = dt_from_string->subtract( hours => 1 );
Lines 196-202 subtest 'Shelf content' => sub { Link Here
196
    my $content1 = $shelf->add_biblio( $biblio1->biblionumber, $patron1->{borrowernumber} );
196
    my $content1 = $shelf->add_biblio( $biblio1->biblionumber, $patron1->{borrowernumber} );
197
    is( ref($content1), 'Koha::Virtualshelfcontent', 'add_biblio to a shelf should return a Koha::Virtualshelfcontent object if inserted' );
197
    is( ref($content1), 'Koha::Virtualshelfcontent', 'add_biblio to a shelf should return a Koha::Virtualshelfcontent object if inserted' );
198
    $shelf = Koha::Virtualshelves->find( $shelf->shelfnumber );
198
    $shelf = Koha::Virtualshelves->find( $shelf->shelfnumber );
199
    is( t::lib::Dates::compare( $shelf->lastmodified, dt_from_string), 0, 'Adding a biblio to a shelf should update the lastmodified for the shelf' );
199
    is( t::lib::Dates::compare( $shelf->lastmodified, dt_from_string()), 0, 'Adding a biblio to a shelf should update the lastmodified for the shelf' );
200
    my $content2 = $shelf->add_biblio( $biblio2->biblionumber, $patron1->{borrowernumber} );
200
    my $content2 = $shelf->add_biblio( $biblio2->biblionumber, $patron1->{borrowernumber} );
201
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
201
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
202
    is( $number_of_contents, 2, '2 biblio should have been inserted' );
202
    is( $number_of_contents, 2, '2 biblio should have been inserted' );
(-)a/t/db_dependent/api/v1/return_claims.t (-1 / +1 lines)
Lines 28-34 use C4::Circulation qw( AddIssue ); Link Here
28
28
29
use Koha::Checkouts::ReturnClaims;
29
use Koha::Checkouts::ReturnClaims;
30
use Koha::Database;
30
use Koha::Database;
31
use Koha::DateUtils qw(dt_from_string);
31
use Koha::DateUtils qw(dt_from_string());
32
32
33
my $schema  = Koha::Database->schema;
33
my $schema  = Koha::Database->schema;
34
my $builder = t::lib::TestBuilder->new;
34
my $builder = t::lib::TestBuilder->new;
(-)a/t/lib/Koha/BackgroundJob/BatchTest.pm (-2 / +2 lines)
Lines 37-43 sub process { Link Here
37
    }
37
    }
38
38
39
    my $job_progress = 0;
39
    my $job_progress = 0;
40
    $job->started_on(dt_from_string)
40
    $job->started_on(dt_from_string())
41
        ->progress($job_progress)
41
        ->progress($job_progress)
42
        ->status('started')
42
        ->status('started')
43
        ->store;
43
        ->store;
Lines 63-69 sub process { Link Here
63
    $job_data->{messages} = \@messages;
63
    $job_data->{messages} = \@messages;
64
    $job_data->{report} = $report;
64
    $job_data->{report} = $report;
65
65
66
    $job->ended_on(dt_from_string)
66
    $job->ended_on(dt_from_string())
67
        ->data(encode_json $job_data);
67
        ->data(encode_json $job_data);
68
    $job->status('finished') if $job->status ne 'cancelled';
68
    $job->status('finished') if $job->status ne 'cancelled';
69
    $job->store;
69
    $job->store;
(-)a/t/lib/TestBuilder.pm (-5 / +5 lines)
Lines 2-11 package t::lib::TestBuilder; Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Koha::Database qw( schema );
5
use Koha::Database;
6
use C4::Biblio qw( AddBiblio );
6
use C4::Biblio qw( AddBiblio );
7
use Koha::Biblios qw( _type );
7
use Koha::Biblios;
8
use Koha::Items qw( _type );
8
use Koha::Items;
9
use Koha::DateUtils qw( dt_from_string );
9
use Koha::DateUtils qw( dt_from_string );
10
10
11
use Bytes::Random::Secure;
11
use Bytes::Random::Secure;
Lines 506-517 sub _gen_real { Link Here
506
506
507
sub _gen_date {
507
sub _gen_date {
508
    my ($self, $params) = @_;
508
    my ($self, $params) = @_;
509
    return $self->schema->storage->datetime_parser->format_date(dt_from_string)
509
    return $self->schema->storage->datetime_parser->format_date(dt_from_string())
510
}
510
}
511
511
512
sub _gen_datetime {
512
sub _gen_datetime {
513
    my ($self, $params) = @_;
513
    my ($self, $params) = @_;
514
    return $self->schema->storage->datetime_parser->format_datetime(dt_from_string);
514
    return $self->schema->storage->datetime_parser->format_datetime(dt_from_string());
515
}
515
}
516
516
517
sub _gen_text {
517
sub _gen_text {
(-)a/tools/batchMod.pl (-1 / +1 lines)
Lines 439-445 foreach my $tag (sort keys %{$tagslib}) { Link Here
439
    if ( $use_default_values) {
439
    if ( $use_default_values) {
440
	    $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
440
	    $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
441
	    # get today date & replace YYYY, MM, DD if provided in the default value
441
	    # get today date & replace YYYY, MM, DD if provided in the default value
442
            my $today = dt_from_string;
442
            my $today = dt_from_string();
443
            my $year  = $today->year;
443
            my $year  = $today->year;
444
            my $month = $today->month;
444
            my $month = $today->month;
445
            my $day   = $today->day;
445
            my $day   = $today->day;
(-)a/tools/cleanborrowers.pl (-4 / +4 lines)
Lines 53-71 my $params = $cgi->Vars; Link Here
53
my $step = $params->{step} || 1;
53
my $step = $params->{step} || 1;
54
my $not_borrowed_since =    # the date which filter on issue history.
54
my $not_borrowed_since =    # the date which filter on issue history.
55
  $params->{not_borrowed_since}
55
  $params->{not_borrowed_since}
56
  ? dt_from_string $params->{not_borrowed_since}
56
  ? dt_from_string() $params->{not_borrowed_since}
57
  : undef;
57
  : undef;
58
my $last_issue_date =         # the date which filter on borrowers last issue.
58
my $last_issue_date =         # the date which filter on borrowers last issue.
59
  $params->{last_issue_date}
59
  $params->{last_issue_date}
60
  ? dt_from_string $params->{last_issue_date}
60
  ? dt_from_string() $params->{last_issue_date}
61
  : undef;
61
  : undef;
62
my $borrower_dateexpiry =
62
my $borrower_dateexpiry =
63
  $params->{borrower_dateexpiry}
63
  $params->{borrower_dateexpiry}
64
  ? dt_from_string $params->{borrower_dateexpiry}
64
  ? dt_from_string() $params->{borrower_dateexpiry}
65
  : undef;
65
  : undef;
66
my $borrower_lastseen =
66
my $borrower_lastseen =
67
  $params->{borrower_lastseen}
67
  $params->{borrower_lastseen}
68
  ? dt_from_string $params->{borrower_lastseen}
68
  ? dt_from_string() $params->{borrower_lastseen}
69
  : undef;
69
  : undef;
70
my $patron_list_id = $params->{patron_list_id};
70
my $patron_list_id = $params->{patron_list_id};
71
71
(-)a/tools/holidays.pl (-1 / +1 lines)
Lines 39-45 my ($template, $loggedinuser, $cookie) Link Here
39
39
40
# calendardate - date passed in url for human readability (syspref)
40
# calendardate - date passed in url for human readability (syspref)
41
# if the url has an invalid date default to 'now.'
41
# if the url has an invalid date default to 'now.'
42
my $calendarinput_dt = eval { dt_from_string( scalar $input->param('calendardate') ); } || dt_from_string;
42
my $calendarinput_dt = eval { dt_from_string( scalar $input->param('calendardate') ); } || dt_from_string();
43
my $calendardate = output_pref( { dt => $calendarinput_dt, dateonly => 1 } );
43
my $calendardate = output_pref( { dt => $calendarinput_dt, dateonly => 1 } );
44
44
45
# keydate - date passed to calendar.js.  calendar.js does not process dashes within a date.
45
# keydate - date passed to calendar.js.  calendar.js does not process dashes within a date.
(-)a/tools/inventory.pl (-3 / +2 lines)
Lines 134-140 foreach my $itemtype ( @itemtypes ) { Link Here
134
134
135
$template->param(
135
$template->param(
136
    authorised_values        => \@authorised_value_list,
136
    authorised_values        => \@authorised_value_list,
137
    today                    => dt_from_string,
137
    today                    => dt_from_string(),
138
    minlocation              => $minlocation,
138
    minlocation              => $minlocation,
139
    maxlocation              => $maxlocation,
139
    maxlocation              => $maxlocation,
140
    location                 => $location,
140
    location                 => $location,
Lines 225-231 if ( ($uploadbarcodes && length($uploadbarcodes) > 0) || ($barcodelist && length Link Here
225
                        my ($doreturn, $messages, $iteminformation, $borrower) =AddReturn($barcode, $data->{homebranch});
225
                        my ($doreturn, $messages, $iteminformation, $borrower) =AddReturn($barcode, $data->{homebranch});
226
                        if( $doreturn ) {
226
                        if( $doreturn ) {
227
                            $item_unblessed->{onloan} = undef;
227
                            $item_unblessed->{onloan} = undef;
228
                            $item_unblessed->{datelastseen} = dt_from_string;
228
                            $item_unblessed->{datelastseen} = dt_from_string();
229
                        } else {
229
                        } else {
230
                            push @errorloop, { barcode => $barcode, ERR_ONLOAN_NOT_RET => 1 };
230
                            push @errorloop, { barcode => $barcode, ERR_ONLOAN_NOT_RET => 1 };
231
                        }
231
                        }
232
- 

Return to bug 28931