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

(-)a/C4/Circulation.pm (-11 / +9 lines)
Lines 703-709 sub CanBookBeIssued { Link Here
703
    if ($duedate && ref $duedate ne 'DateTime') {
703
    if ($duedate && ref $duedate ne 'DateTime') {
704
        $duedate = dt_from_string($duedate);
704
        $duedate = dt_from_string($duedate);
705
    }
705
    }
706
    my $now = DateTime->now( time_zone => C4::Context->tz() );
706
    my $now = dt_from_string();
707
    unless ( $duedate ) {
707
    unless ( $duedate ) {
708
        my $issuedate = $now->clone();
708
        my $issuedate = $now->clone();
709
709
Lines 1234-1240 sub checkHighHolds { Link Here
1234
            }
1234
            }
1235
        }
1235
        }
1236
1236
1237
        my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1237
        my $issuedate = dt_from_string();
1238
1238
1239
        my $calendar = Koha::Calendar->new( branchcode => $branchcode );
1239
        my $calendar = Koha::Calendar->new( branchcode => $branchcode );
1240
1240
Lines 1313-1319 sub AddIssue { Link Here
1313
1313
1314
    # $issuedate defaults to today.
1314
    # $issuedate defaults to today.
1315
    if ( !defined $issuedate ) {
1315
    if ( !defined $issuedate ) {
1316
        $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1316
        $issuedate = dt_from_string();
1317
    }
1317
    }
1318
    else {
1318
    else {
1319
        if ( ref $issuedate ne 'DateTime' ) {
1319
        if ( ref $issuedate ne 'DateTime' ) {
Lines 1463-1469 sub AddIssue { Link Here
1463
                    holdingbranch => C4::Context->userenv->{'branch'},
1463
                    holdingbranch => C4::Context->userenv->{'branch'},
1464
                    itemlost      => 0,
1464
                    itemlost      => 0,
1465
                    onloan        => $datedue->ymd(),
1465
                    onloan        => $datedue->ymd(),
1466
                    datelastborrowed => DateTime->now( time_zone => C4::Context->tz() )->ymd(),
1466
                    datelastborrowed => dt_from_string(),
1467
                },
1467
                },
1468
                $item_object->biblionumber,
1468
                $item_object->biblionumber,
1469
                $item_object->itemnumber,
1469
                $item_object->itemnumber,
Lines 2766-2772 sub CanBookBeRenewed { Link Here
2766
                $soonestrenewal->truncate( to => 'day' );
2766
                $soonestrenewal->truncate( to => 'day' );
2767
            }
2767
            }
2768
2768
2769
            if ( $soonestrenewal > DateTime->now( time_zone => C4::Context->tz() ) )
2769
            if ( $soonestrenewal > dt_from_string() )
2770
            {
2770
            {
2771
                return ( 0, "auto_too_soon" ) if $issue->auto_renew;
2771
                return ( 0, "auto_too_soon" ) if $issue->auto_renew;
2772
                return ( 0, "too_soon" );
2772
                return ( 0, "too_soon" );
Lines 2888-2894 sub AddRenewal { Link Here
2888
    my $itemnumber      = shift or return;
2888
    my $itemnumber      = shift or return;
2889
    my $branch          = shift;
2889
    my $branch          = shift;
2890
    my $datedue         = shift;
2890
    my $datedue         = shift;
2891
    my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz);
2891
    my $lastreneweddate = shift || dt_from_string();
2892
2892
2893
    my $item_object   = Koha::Items->find($itemnumber) or return;
2893
    my $item_object   = Koha::Items->find($itemnumber) or return;
2894
    my $biblio = $item_object->biblio;
2894
    my $biblio = $item_object->biblio;
Lines 2927-2933 sub AddRenewal { Link Here
2927
2927
2928
            $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
2928
            $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
2929
                                            dt_from_string( $issue->date_due, 'sql' ) :
2929
                                            dt_from_string( $issue->date_due, 'sql' ) :
2930
                                            DateTime->now( time_zone => C4::Context->tz());
2930
                                            dt_from_string();
2931
            $datedue =  CalcDateDue($datedue, $itemtype, $circ_library->branchcode, $patron_unblessed, 'is a renewal');
2931
            $datedue =  CalcDateDue($datedue, $itemtype, $circ_library->branchcode, $patron_unblessed, 'is a renewal');
2932
        }
2932
        }
2933
2933
Lines 3556-3564 sub CalcDateDue { Link Here
3556
            $datedue = $startdate->clone;
3556
            $datedue = $startdate->clone;
3557
        }
3557
        }
3558
    } else {
3558
    } else {
3559
        $datedue =
3559
        $datedue = dt_from_string()->truncate( to => 'minute' );
3560
          DateTime->now( time_zone => C4::Context->tz() )
3561
          ->truncate( to => 'minute' );
3562
    }
3560
    }
3563
3561
3564
3562
Lines 4035-4041 sub GetAgeRestriction { Link Here
4035
            }
4033
            }
4036
4034
4037
            #Get how many days the borrower has to reach the age restriction
4035
            #Get how many days the borrower has to reach the age restriction
4038
            my @Today = split /-/, DateTime->today->ymd();
4036
            my @Today = split /-/, dt_from_string()->ymd();
4039
            my $daysToAgeRestriction = Date_to_Days(@alloweddate) - Date_to_Days(@Today);
4037
            my $daysToAgeRestriction = Date_to_Days(@alloweddate) - Date_to_Days(@Today);
4040
            #Negative days means the borrower went past the age restriction age
4038
            #Negative days means the borrower went past the age restriction age
4041
            return ($restriction_year, $daysToAgeRestriction);
4039
            return ($restriction_year, $daysToAgeRestriction);
(-)a/C4/Letters.pm (-1 / +1 lines)
Lines 797-803 sub _parseletter { Link Here
797
    }
797
    }
798
798
799
    if ($letter->{content} && $letter->{content} =~ /<<today>>/) {
799
    if ($letter->{content} && $letter->{content} =~ /<<today>>/) {
800
        my $todaysdate = output_pref( DateTime->now() );
800
        my $todaysdate = output_pref( dt_from_string() );
801
        $letter->{content} =~ s/<<today>>/$todaysdate/go;
801
        $letter->{content} =~ s/<<today>>/$todaysdate/go;
802
    }
802
    }
803
803
(-)a/C4/MarcModificationTemplates.pm (-1 / +2 lines)
Lines 24-29 use DateTime; Link Here
24
use C4::Context;
24
use C4::Context;
25
use Koha::SimpleMARC;
25
use Koha::SimpleMARC;
26
use Koha::MoreUtils;
26
use Koha::MoreUtils;
27
use Koha::DateUtils;
27
28
28
use vars qw(@ISA @EXPORT);
29
use vars qw(@ISA @EXPORT);
29
30
Lines 501-507 sub ModifyRecordWithTemplate { Link Here
501
    warn( "C4::MarcModificationTemplates::ModifyRecordWithTemplate( $template_id, $record )" ) if DEBUG;
502
    warn( "C4::MarcModificationTemplates::ModifyRecordWithTemplate( $template_id, $record )" ) if DEBUG;
502
    warn( "Unmodified Record:\n" . $record->as_formatted() ) if DEBUG >= 10;
503
    warn( "Unmodified Record:\n" . $record->as_formatted() ) if DEBUG >= 10;
503
504
504
    my $current_date = DateTime->now()->ymd();
505
    my $current_date = dt_from_string()->ymd();
505
    my $branchcode = '';
506
    my $branchcode = '';
506
    $branchcode = C4::Context->userenv->{branch} if C4::Context->userenv;
507
    $branchcode = C4::Context->userenv->{branch} if C4::Context->userenv;
507
508
(-)a/Koha/Calendar.pm (-1 / +1 lines)
Lines 410-416 Koha::Calendar - Object containing a branches calendar Link Here
410
  use Koha::Calendar
410
  use Koha::Calendar
411
411
412
  my $c = Koha::Calendar->new( branchcode => 'MAIN' );
412
  my $c = Koha::Calendar->new( branchcode => 'MAIN' );
413
  my $dt = DateTime->now();
413
  my $dt = dt_from_string();
414
414
415
  # are we open
415
  # are we open
416
  $open = $c->is_holiday($dt);
416
  $open = $c->is_holiday($dt);
(-)a/Koha/Checkout.pm (-1 / +2 lines)
Lines 54-60 will be the reference date. Link Here
54
54
55
sub is_overdue {
55
sub is_overdue {
56
    my ( $self, $dt ) = @_;
56
    my ( $self, $dt ) = @_;
57
    $dt ||= DateTime->now( time_zone => C4::Context->tz );
57
    $dt ||= dt_from_string();
58
58
    my $is_overdue =
59
    my $is_overdue =
59
      DateTime->compare( dt_from_string( $self->date_due, 'sql' ), $dt ) == -1
60
      DateTime->compare( dt_from_string( $self->date_due, 'sql' ), $dt ) == -1
60
      ? 1
61
      ? 1
(-)a/Koha/Checkouts.pm (-1 / +2 lines)
Lines 24-29 use Carp; Link Here
24
use C4::Context;
24
use C4::Context;
25
use Koha::Checkout;
25
use Koha::Checkout;
26
use Koha::Database;
26
use Koha::Database;
27
use Koha::DateUtils;
27
28
28
use base qw(Koha::Objects);
29
use base qw(Koha::Objects);
29
30
Lines 48-54 sub calculate_dropbox_date { Link Here
48
    my $branchcode = $userenv->{branch} // q{};
49
    my $branchcode = $userenv->{branch} // q{};
49
50
50
    my $calendar = Koha::Calendar->new( branchcode => $branchcode );
51
    my $calendar = Koha::Calendar->new( branchcode => $branchcode );
51
    my $today        = DateTime->now( time_zone => C4::Context->tz() );
52
    my $today        = dt_from_string();
52
    my $dropbox_date = $calendar->addDate( $today, -1 );
53
    my $dropbox_date = $calendar->addDate( $today, -1 );
53
54
54
    return $dropbox_date;
55
    return $dropbox_date;
(-)a/Koha/EDI.pm (-2 / +3 lines)
Lines 27-32 use Business::ISBN; Link Here
27
use DateTime;
27
use DateTime;
28
use C4::Context;
28
use C4::Context;
29
use Koha::Database;
29
use Koha::Database;
30
use Koha::DateUtils;
30
use C4::Acquisition qw( NewBasket CloseBasket ModOrder);
31
use C4::Acquisition qw( NewBasket CloseBasket ModOrder);
31
use C4::Suggestions qw( ModSuggestion );
32
use C4::Suggestions qw( ModSuggestion );
32
use C4::Items qw(AddItem);
33
use C4::Items qw(AddItem);
Lines 175-181 sub process_ordrsp { Link Here
175
                            ordernumber             => $ordernumber,
176
                            ordernumber             => $ordernumber,
176
                            cancellationreason      => $reason,
177
                            cancellationreason      => $reason,
177
                            orderstatus             => 'cancelled',
178
                            orderstatus             => 'cancelled',
178
                            datecancellationprinted => DateTime->now()->ymd(),
179
                            datecancellationprinted => dt_from_string()->ymd(),
179
                        }
180
                        }
180
                    );
181
                    );
181
                }
182
                }
Lines 625-631 sub quote_item { Link Here
625
    # database definitions should set some of these defaults but dont
626
    # database definitions should set some of these defaults but dont
626
    my $order_hash = {
627
    my $order_hash = {
627
        biblionumber       => $bib->{biblionumber},
628
        biblionumber       => $bib->{biblionumber},
628
        entrydate          => DateTime->now( time_zone => 'local' )->ymd(),
629
        entrydate          => dt_from_string()->ymd(),
629
        basketno           => $basketno,
630
        basketno           => $basketno,
630
        listprice          => $item->price,
631
        listprice          => $item->price,
631
        quantity           => $order_quantity,
632
        quantity           => $order_quantity,
(-)a/Koha/Edifact/Order.pm (-1 / +2 lines)
Lines 26-31 use DateTime; Link Here
26
use Readonly;
26
use Readonly;
27
use Business::ISBN;
27
use Business::ISBN;
28
use Koha::Database;
28
use Koha::Database;
29
use Koha::DateUtils;
29
use C4::Budgets qw( GetBudget );
30
use C4::Budgets qw( GetBudget );
30
31
31
use Koha::Acquisition::Orders;
32
use Koha::Acquisition::Orders;
Lines 51-57 sub new { Link Here
51
52
52
        # convenient alias
53
        # convenient alias
53
        $self->{basket} = $self->{orderlines}->[0]->basketno;
54
        $self->{basket} = $self->{orderlines}->[0]->basketno;
54
        $self->{message_date} = DateTime->now( time_zone => 'local' );
55
        $self->{message_date} = dt_from_string();
55
    }
56
    }
56
57
57
    # validate that its worth proceeding
58
    # validate that its worth proceeding
(-)a/Koha/Edifact/Transport.pm (-1 / +2 lines)
Lines 29-34 use File::Slurp; Link Here
29
use File::Copy;
29
use File::Copy;
30
use File::Basename qw( fileparse );
30
use File::Basename qw( fileparse );
31
use Koha::Database;
31
use Koha::Database;
32
use Koha::DateUtils;
32
use Encode qw( from_to );
33
use Encode qw( from_to );
33
34
34
sub new {
35
sub new {
Lines 40-46 sub new { Link Here
40
        account     => $acct,
41
        account     => $acct,
41
        schema      => $schema,
42
        schema      => $schema,
42
        working_dir => C4::Context::temporary_directory,    #temporary work directory
43
        working_dir => C4::Context::temporary_directory,    #temporary work directory
43
        transfer_date => DateTime->now( time_zone => 'local' ),
44
        transfer_date => dt_from_string(),
44
    };
45
    };
45
46
46
    bless $self, $class;
47
    bless $self, $class;
(-)a/Koha/Illrequest.pm (-1 / +2 lines)
Lines 28-33 use Try::Tiny; Link Here
28
use DateTime;
28
use DateTime;
29
29
30
use Koha::Database;
30
use Koha::Database;
31
use Koha::DateUtils qw/ dt_from_string /;
31
use Koha::Email;
32
use Koha::Email;
32
use Koha::Exceptions::Ill;
33
use Koha::Exceptions::Ill;
33
use Koha::Illcomments;
34
use Koha::Illcomments;
Lines 662-668 Mark a request as completed (status = COMP). Link Here
662
sub mark_completed {
663
sub mark_completed {
663
    my ( $self ) = @_;
664
    my ( $self ) = @_;
664
    $self->status('COMP')->store;
665
    $self->status('COMP')->store;
665
    $self->completed(DateTime->now)->store;
666
    $self->completed(dt_from_string())->store;
666
    return {
667
    return {
667
        error   => 0,
668
        error   => 0,
668
        status  => '',
669
        status  => '',
(-)a/Koha/Patron/Password/Recovery.pm (-1 / +2 lines)
Lines 21-26 use Modern::Perl; Link Here
21
use C4::Context;
21
use C4::Context;
22
use C4::Letters;
22
use C4::Letters;
23
use Crypt::Eksblowfish::Bcrypt qw(en_base64);
23
use Crypt::Eksblowfish::Bcrypt qw(en_base64);
24
use Koha::DateUtils;
24
25
25
use vars qw(@ISA @EXPORT);
26
use vars qw(@ISA @EXPORT);
26
27
Lines 115-121 sub SendPasswordRecoveryEmail { Link Here
115
116
116
    # insert into database
117
    # insert into database
117
    my $expirydate =
118
    my $expirydate =
118
      DateTime->now( time_zone => C4::Context->tz() )->add( days => 2 );
119
      dt_from_string()->add( days => 2 );
119
    if ($update) {
120
    if ($update) {
120
        my $rs =
121
        my $rs =
121
          $schema->resultset('BorrowerPasswordRecovery')
122
          $schema->resultset('BorrowerPasswordRecovery')
(-)a/Koha/Sitemapper/Writer.pm (-2 / +2 lines)
Lines 23-29 use Moo; Link Here
23
use Modern::Perl;
23
use Modern::Perl;
24
use XML::Writer;
24
use XML::Writer;
25
use IO::File;
25
use IO::File;
26
use DateTime;
26
use Koha::DateUtils;
27
27
28
28
29
my $MAX = 50000;
29
my $MAX = 50000;
Lines 106-112 sub end { Link Here
106
106
107
    my $w = $self->_writer_create("sitemapindex.xml");
107
    my $w = $self->_writer_create("sitemapindex.xml");
108
    $w->startTag('sitemapindex', 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9');
108
    $w->startTag('sitemapindex', 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9');
109
    my $now = DateTime->now()->ymd;
109
    my $now = dt_from_string()->ymd;
110
    for my $i ( 1..$self->count ) {
110
    for my $i ( 1..$self->count ) {
111
        $w->startTag('sitemap');
111
        $w->startTag('sitemap');
112
            $w->startTag('loc');
112
            $w->startTag('loc');
(-)a/Koha/StockRotationItem.pm (-6 / +6 lines)
Lines 129-135 sub needs_advancing { Link Here
129
        );
129
        );
130
        my $duration = DateTime::Duration
130
        my $duration = DateTime::Duration
131
            ->new( days => $self->stage->duration );
131
            ->new( days => $self->stage->duration );
132
        if ( $arrival + $duration le DateTime->now ) {
132
        if ( $arrival + $duration le dt_from_string() ) {
133
            return 1;
133
            return 1;
134
        } else {
134
        } else {
135
            return 0;
135
            return 0;
Lines 155-161 sub repatriate { Link Here
155
        'itemnumber' => $self->itemnumber_id,
155
        'itemnumber' => $self->itemnumber_id,
156
        'frombranch' => $self->itemnumber->holdingbranch,
156
        'frombranch' => $self->itemnumber->holdingbranch,
157
        'tobranch'   => $self->stage->branchcode_id,
157
        'tobranch'   => $self->stage->branchcode_id,
158
        'datesent'   => DateTime->now,
158
        'datesent'   => dt_from_string(),
159
        'comments'   => $msg || "StockrotationRepatriation",
159
        'comments'   => $msg || "StockrotationRepatriation",
160
    })->store;
160
    })->store;
161
    $self->itemnumber->homebranch($self->stage->branchcode_id)->store;
161
    $self->itemnumber->homebranch($self->stage->branchcode_id)->store;
Lines 184-197 sub advance { Link Here
184
    my $transfer = Koha::Item::Transfer->new({
184
    my $transfer = Koha::Item::Transfer->new({
185
        'itemnumber' => $self->itemnumber_id,
185
        'itemnumber' => $self->itemnumber_id,
186
        'frombranch' => $item->holdingbranch,
186
        'frombranch' => $item->holdingbranch,
187
        'datesent'   => DateTime->now,
187
        'datesent'   => dt_from_string(),
188
        'comments'   => "StockrotationAdvance"
188
        'comments'   => "StockrotationAdvance"
189
    });
189
    });
190
190
191
    if ( $self->indemand && !$self->fresh ) {
191
    if ( $self->indemand && !$self->fresh ) {
192
        $self->indemand(0)->store;  # De-activate indemand
192
        $self->indemand(0)->store;  # De-activate indemand
193
        $transfer->tobranch($self->stage->branchcode_id);
193
        $transfer->tobranch($self->stage->branchcode_id);
194
        $transfer->datearrived(DateTime->now);
194
        $transfer->datearrived(dt_from_string());
195
    } else {
195
    } else {
196
        # Find and update our stage.
196
        # Find and update our stage.
197
        my $stage = $self->stage;
197
        my $stage = $self->stage;
Lines 199-205 sub advance { Link Here
199
        if ( $self->fresh ) {   # Just added to rota
199
        if ( $self->fresh ) {   # Just added to rota
200
            $new_stage = $self->stage->first_sibling || $self->stage;
200
            $new_stage = $self->stage->first_sibling || $self->stage;
201
            $transfer->tobranch($new_stage->branchcode_id);
201
            $transfer->tobranch($new_stage->branchcode_id);
202
            $transfer->datearrived(DateTime->now) # Already at first branch
202
            $transfer->datearrived(dt_from_string()) # Already at first branch
203
                if $item->holdingbranch eq $new_stage->branchcode_id;
203
                if $item->holdingbranch eq $new_stage->branchcode_id;
204
            $self->fresh(0)->store;         # Reset fresh
204
            $self->fresh(0)->store;         # Reset fresh
205
        } elsif ( !$stage->last_sibling ) { # Last stage
205
        } elsif ( !$stage->last_sibling ) { # Last stage
Lines 207-213 sub advance { Link Here
207
                # Revert to first stage.
207
                # Revert to first stage.
208
                $new_stage = $stage->first_sibling || $stage;
208
                $new_stage = $stage->first_sibling || $stage;
209
                $transfer->tobranch($new_stage->branchcode_id);
209
                $transfer->tobranch($new_stage->branchcode_id);
210
                $transfer->datearrived(DateTime->now);
210
                $transfer->datearrived(dt_from_string());
211
            } else {
211
            } else {
212
                $self->delete;  # StockRotationItem is done.
212
                $self->delete;  # StockRotationItem is done.
213
                return 1;
213
                return 1;
(-)a/circ/overdue.pl (-1 / +1 lines)
Lines 214-220 if ($noreport) { Link Here
214
    #  FIX 2: ensure there are indexes for columns participating in the WHERE clauses, where feasible/reasonable
214
    #  FIX 2: ensure there are indexes for columns participating in the WHERE clauses, where feasible/reasonable
215
215
216
216
217
    my $today_dt = DateTime->now(time_zone => C4::Context->tz);
217
    my $today_dt = dt_from_string();
218
    $today_dt->truncate(to => 'minute');
218
    $today_dt->truncate(to => 'minute');
219
    my $todaysdate = $today_dt->strftime('%Y-%m-%d %H:%M');
219
    my $todaysdate = $today_dt->strftime('%Y-%m-%d %H:%M');
220
220
(-)a/circ/returns.pl (-3 / +3 lines)
Lines 309-315 if ($barcode) { Link Here
309
      AddReturn( $barcode, $userenv_branch, $exemptfine, $return_date );
309
      AddReturn( $barcode, $userenv_branch, $exemptfine, $return_date );
310
310
311
    if ($returned) {
311
    if ($returned) {
312
        my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute');
312
        my $time_now = dt_from_string()->truncate( to => 'minute');
313
        my $date_due_dt = dt_from_string( $issue->date_due, 'sql' );
313
        my $date_due_dt = dt_from_string( $issue->date_due, 'sql' );
314
        my $duedate = $date_due_dt->strftime('%Y-%m-%d %H:%M');
314
        my $duedate = $date_due_dt->strftime('%Y-%m-%d %H:%M');
315
        $returneditems{0}      = $barcode;
315
        $returneditems{0}      = $barcode;
Lines 318-324 if ($barcode) { Link Here
318
        $input{borrowernumber} = $borrower->{'borrowernumber'};
318
        $input{borrowernumber} = $borrower->{'borrowernumber'};
319
        $input{duedate}        = $duedate;
319
        $input{duedate}        = $duedate;
320
        unless ( $dropboxmode ) {
320
        unless ( $dropboxmode ) {
321
            $input{return_overdue} = 1 if (DateTime->compare($date_due_dt, DateTime->now()) == -1);
321
            $input{return_overdue} = 1 if (DateTime->compare($date_due_dt, dt_from_string()) == -1);
322
        } else {
322
        } else {
323
            $input{return_overdue} = 1 if (DateTime->compare($date_due_dt, $dropboxdate) == -1);
323
            $input{return_overdue} = 1 if (DateTime->compare($date_due_dt, $dropboxdate) == -1);
324
        }
324
        }
Lines 575-581 foreach ( sort { $a <=> $b } keys %returneditems ) { Link Here
575
            $ri{duedate} = output_pref($duedate);
575
            $ri{duedate} = output_pref($duedate);
576
            my $patron = Koha::Patrons->find( $riborrowernumber{$_} );
576
            my $patron = Koha::Patrons->find( $riborrowernumber{$_} );
577
            unless ( $dropboxmode ) {
577
            unless ( $dropboxmode ) {
578
                $ri{return_overdue} = 1 if (DateTime->compare($duedate, DateTime->now()) == -1);
578
                $ri{return_overdue} = 1 if (DateTime->compare($duedate, dt_from_string()) == -1);
579
            } else {
579
            } else {
580
                $ri{return_overdue} = 1 if (DateTime->compare($duedate, $dropboxdate) == -1);
580
                $ri{return_overdue} = 1 if (DateTime->compare($duedate, $dropboxdate) == -1);
581
            }
581
            }
(-)a/installer/data/mysql/fix_unclosed_nonaccruing_fines_bug17135.pl (-1 / +1 lines)
Lines 76-82 sub Bug_17135_fix { Link Here
76
76
77
    my $control = C4::Context->preference('CircControl');
77
    my $control = C4::Context->preference('CircControl');
78
    my $mode = C4::Context->preference('finesMode');
78
    my $mode = C4::Context->preference('finesMode');
79
    my $today = DateTime->now( time_zone => C4::Context->tz() );
79
    my $today = dt_from_string();
80
    my $dbh = C4::Context->dbh;
80
    my $dbh = C4::Context->dbh;
81
81
82
    ## fetch the unclosed FU fines linked to the issues by issue_id
82
    ## fetch the unclosed FU fines linked to the issues by issue_id
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +1 lines)
Lines 16262-16268 $DBversion = '18.06.00.016'; Link Here
16262
if( CheckVersion( $DBversion ) ) {
16262
if( CheckVersion( $DBversion ) ) {
16263
    my $dtf  = Koha::Database->new->schema->storage->datetime_parser;
16263
    my $dtf  = Koha::Database->new->schema->storage->datetime_parser;
16264
    my $days = C4::Context->preference('MaxPickupDelay') || 7;
16264
    my $days = C4::Context->preference('MaxPickupDelay') || 7;
16265
    my $date = DateTime->now()->add( days => $days );
16265
    my $date = dt_from_string()->add( days => $days );
16266
    my $sql  = q|UPDATE reserves SET expirationdate = ? WHERE expirationdate IS NULL AND waitingdate IS NOT NULL|;
16266
    my $sql  = q|UPDATE reserves SET expirationdate = ? WHERE expirationdate IS NULL AND waitingdate IS NOT NULL|;
16267
    $dbh->do( $sql, undef, $dtf->format_datetime($date) );
16267
    $dbh->do( $sql, undef, $dtf->format_datetime($date) );
16268
    SetVersion( $DBversion );
16268
    SetVersion( $DBversion );
(-)a/members/summary-print.pl (-1 / +2 lines)
Lines 25-30 use C4::Members; Link Here
25
use C4::Circulation qw( GetIssuingCharges );
25
use C4::Circulation qw( GetIssuingCharges );
26
use C4::Reserves;
26
use C4::Reserves;
27
use C4::Items;
27
use C4::Items;
28
use Koha::DateUtils;
28
use Koha::Holds;
29
use Koha::Holds;
29
use Koha::ItemTypes;
30
use Koha::ItemTypes;
30
use Koha::Patrons;
31
use Koha::Patrons;
Lines 109-115 sub build_reserve_data { Link Here
109
110
110
    my $return = [];
111
    my $return = [];
111
112
112
    my $today = DateTime->now( time_zone => C4::Context->tz );
113
    my $today = dt_from_string();
113
    $today->truncate( to => 'day' );
114
    $today->truncate( to => 'day' );
114
115
115
    while ( my $reserve = $reserves->next() ) {
116
    while ( my $reserve = $reserves->next() ) {
(-)a/misc/cronjobs/fines.pl (-1 / +1 lines)
Lines 84-90 my $mode = C4::Context->preference('finesMode'); Link Here
84
my $delim = "\t";    # ?  C4::Context->preference('delimiter') || "\t";
84
my $delim = "\t";    # ?  C4::Context->preference('delimiter') || "\t";
85
85
86
my %is_holiday;
86
my %is_holiday;
87
my $today = DateTime->now( time_zone => C4::Context->tz() );
87
my $today = dt_from_string();
88
my $filename;
88
my $filename;
89
if ($log or $output_dir) {
89
if ($log or $output_dir) {
90
    $filename = get_filename($output_dir);
90
    $filename = get_filename($output_dir);
(-)a/misc/cronjobs/overdue_notices.pl (-2 / +2 lines)
Lines 417-423 if ( defined $htmlfilename ) { Link Here
417
  if ( $htmlfilename eq '' ) {
417
  if ( $htmlfilename eq '' ) {
418
    $fh = *STDOUT;
418
    $fh = *STDOUT;
419
  } else {
419
  } else {
420
    my $today = DateTime->now(time_zone => C4::Context->tz );
420
    my $today = dt_from_string();
421
    open $fh, ">:encoding(UTF-8)",File::Spec->catdir ($htmlfilename,"notices-".$today->ymd().".html");
421
    open $fh, ">:encoding(UTF-8)",File::Spec->catdir ($htmlfilename,"notices-".$today->ymd().".html");
422
  }
422
  }
423
  
423
  
Lines 438-444 elsif ( defined $text_filename ) { Link Here
438
  if ( $text_filename eq '' ) {
438
  if ( $text_filename eq '' ) {
439
    $fh = *STDOUT;
439
    $fh = *STDOUT;
440
  } else {
440
  } else {
441
    my $today = DateTime->now(time_zone => C4::Context->tz );
441
    my $today = dt_from_string();
442
    open $fh, ">",File::Spec->catdir ($text_filename,"notices-".$today->ymd().".txt");
442
    open $fh, ">",File::Spec->catdir ($text_filename,"notices-".$today->ymd().".txt");
443
  }
443
  }
444
}
444
}
(-)a/misc/cronjobs/update_totalissues.pl (-1 / +2 lines)
Lines 32-37 use Getopt::Long; Link Here
32
use Pod::Usage;
32
use Pod::Usage;
33
33
34
use Koha::Script -cron;
34
use Koha::Script -cron;
35
use Koha::DateUtils qw/ dt_from_string /;
35
use C4::Context;
36
use C4::Context;
36
use C4::Biblio;
37
use C4::Biblio;
37
use C4::Log;
38
use C4::Log;
Lines 122-128 sub process_items { Link Here
122
123
123
sub process_stats {
124
sub process_stats {
124
    if ($interval) {
125
    if ($interval) {
125
        my $dt = DateTime->now;
126
        my $dt = dt_from_string();
126
127
127
        my %units = (
128
        my %units = (
128
            h => 'hours',
129
            h => 'hours',
(-)a/opac/opac-ics.pl (-1 / +1 lines)
Lines 55-61 my $pending_checkouts = $patron->pending_checkouts; Link Here
55
while ( my $c = $pending_checkouts->next ) {
55
while ( my $c = $pending_checkouts->next ) {
56
    my $issue = $c->unblessed_all_relateds;
56
    my $issue = $c->unblessed_all_relateds;
57
    my $vevent = Data::ICal::Entry::Event->new();
57
    my $vevent = Data::ICal::Entry::Event->new();
58
    my $timestamp = DateTime->now(); # Defaults to UTC
58
    my $timestamp = dt_from_string(undef,undef,"UTC"); #Get current time in UTC
59
    # Send some values to the template to generate summary and description
59
    # Send some values to the template to generate summary and description
60
    $issue->{overdue} = $c->is_overdue;
60
    $issue->{overdue} = $c->is_overdue;
61
    $template->param(
61
    $template->param(
(-)a/t/Circulation/AgeRestrictionMarkers.t (-2 / +3 lines)
Lines 22-27 use Modern::Perl; Link Here
22
22
23
use DateTime;
23
use DateTime;
24
use Test::More tests => 7;
24
use Test::More tests => 7;
25
use Koha::DateUtils;
25
26
26
use t::lib::Mocks;
27
use t::lib::Mocks;
27
28
Lines 38-44 is ( C4::Circulation::GetAgeRestriction('K16'), '16', 'K16 returns 16' ); Link Here
38
subtest 'Patron tests - 15 years old' => sub {
39
subtest 'Patron tests - 15 years old' => sub {
39
    plan tests => 5;
40
    plan tests => 5;
40
    ##Testing age restriction for a borrower.
41
    ##Testing age restriction for a borrower.
41
    my $now = DateTime->now();
42
    my $now = dt_from_string();
42
    my $borrower = { dateofbirth => $now->add( years => -15 )->strftime("%Y-%m-%d") };
43
    my $borrower = { dateofbirth => $now->add( years => -15 )->strftime("%Y-%m-%d") };
43
    TestPatron($borrower,0);
44
    TestPatron($borrower,0);
44
};
45
};
Lines 55-61 subtest 'Patron tests - 15 years old (Time Zone shifts)' => sub { Link Here
55
            Time::Fake->offset("+${offset}h");
56
            Time::Fake->offset("+${offset}h");
56
57
57
            ##Testing age restriction for a borrower.
58
            ##Testing age restriction for a borrower.
58
            my $now = DateTime->now();
59
            my $now = dt_from_string();
59
            my $borrower = { dateofbirth => $now->add( years => -15 )->strftime("%Y-%m-%d") };
60
            my $borrower = { dateofbirth => $now->add( years => -15 )->strftime("%Y-%m-%d") };
60
            TestPatron($borrower,$offset);
61
            TestPatron($borrower,$offset);
61
62
(-)a/t/db_dependent/DecreaseLoanHighHolds.t (-2 / +3 lines)
Lines 20-25 use DateTime; Link Here
20
20
21
use C4::Circulation;
21
use C4::Circulation;
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::DateUtils;
23
use Koha::Patrons;
24
use Koha::Patrons;
24
use Koha::Biblio;
25
use Koha::Biblio;
25
use Koha::Item;
26
use Koha::Item;
Lines 38-44 my $builder = t::lib::TestBuilder->new; Link Here
38
$dbh->{RaiseError} = 1;
39
$dbh->{RaiseError} = 1;
39
$schema->storage->txn_begin();
40
$schema->storage->txn_begin();
40
41
41
my $now_value       = DateTime->now();
42
my $now_value       = dt_from_string();
42
my $mocked_datetime = Test::MockModule->new('DateTime');
43
my $mocked_datetime = Test::MockModule->new('DateTime');
43
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
44
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
44
45
Lines 112-118 $builder->build( Link Here
112
113
113
114
114
my $orig_due = C4::Circulation::CalcDateDue(
115
my $orig_due = C4::Circulation::CalcDateDue(
115
    DateTime->now(time_zone => C4::Context->tz()),
116
    dt_from_string(),
116
    $item->effective_itemtype,
117
    $item->effective_itemtype,
117
    $patron->branchcode,
118
    $patron->branchcode,
118
    $patron->unblessed
119
    $patron->unblessed
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-1 / +1 lines)
Lines 58-64 $dbh->{RaiseError} = 1; Link Here
58
58
59
$dbh->do(q|DELETE FROM letter|);
59
$dbh->do(q|DELETE FROM letter|);
60
60
61
my $now_value       = DateTime->now();
61
my $now_value       = dt_from_string();
62
my $mocked_datetime = Test::MockModule->new('DateTime');
62
my $mocked_datetime = Test::MockModule->new('DateTime');
63
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
63
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
64
64
(-)a/t/db_dependent/OAI/Server.t (-1 / +1 lines)
Lines 72-78 $dbh->do('DELETE FROM oai_sets'); Link Here
72
72
73
set_fixed_time(CORE::time());
73
set_fixed_time(CORE::time());
74
74
75
my $base_datetime = DateTime->now();
75
my $base_datetime = dt_from_string();
76
my $date_added = $base_datetime->ymd . ' ' .$base_datetime->hms . 'Z';
76
my $date_added = $base_datetime->ymd . ' ' .$base_datetime->hms . 'Z';
77
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z';
77
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z';
78
my (@header, @marcxml, @oaidc);
78
my (@header, @marcxml, @oaidc);
(-)a/t/db_dependent/Passwordrecovery.t (-5 / +6 lines)
Lines 21-26 use C4::Context; Link Here
21
use Mail::Sendmail;
21
use Mail::Sendmail;
22
use C4::Letters;
22
use C4::Letters;
23
use Koha::Database;
23
use Koha::Database;
24
use Koha::DateUtils;
24
use Koha::Patrons;
25
use Koha::Patrons;
25
use t::lib::TestBuilder;
26
use t::lib::TestBuilder;
26
27
Lines 115-135 $schema->resultset('BorrowerPasswordRecovery')->create( Link Here
115
    {
116
    {
116
        borrowernumber => $borrowernumber1,
117
        borrowernumber => $borrowernumber1,
117
        uuid           => $uuid1,
118
        uuid           => $uuid1,
118
        valid_until    => DateTime->now( time_zone => C4::Context->tz() )->add( days => 2 )->datetime()
119
        valid_until    => dt_from_string()->add( days => 2 )->datetime()
119
    }
120
    }
120
);
121
);
121
$schema->resultset('BorrowerPasswordRecovery')->create(
122
$schema->resultset('BorrowerPasswordRecovery')->create(
122
    {
123
    {
123
        borrowernumber => $borrowernumber2,
124
        borrowernumber => $borrowernumber2,
124
        uuid           => $uuid2,
125
        uuid           => $uuid2,
125
        valid_until    => DateTime->now( time_zone => C4::Context->tz() )->subtract( days => 2 )->datetime()
126
        valid_until    => dt_from_string()->subtract( days => 2 )->datetime()
126
    }
127
    }
127
);
128
);
128
$schema->resultset('BorrowerPasswordRecovery')->create(
129
$schema->resultset('BorrowerPasswordRecovery')->create(
129
    {
130
    {
130
        borrowernumber => $borrowernumber3,
131
        borrowernumber => $borrowernumber3,
131
        uuid           => $uuid3,
132
        uuid           => $uuid3,
132
        valid_until    => DateTime->now( time_zone => C4::Context->tz() )->subtract( days => 3 )->datetime()
133
        valid_until    => dt_from_string()->subtract( days => 3 )->datetime()
133
    }
134
    }
134
);
135
);
135
136
Lines 167-173 $schema->resultset('BorrowerPasswordRecovery')->create( Link Here
167
    {
168
    {
168
        borrowernumber => $borrowernumber2,
169
        borrowernumber => $borrowernumber2,
169
        uuid           => $uuid2,
170
        uuid           => $uuid2,
170
        valid_until    => DateTime->now( time_zone => C4::Context->tz() )->subtract( days => 2 )->datetime()
171
        valid_until    => dt_from_string()->subtract( days => 2 )->datetime()
171
    }
172
    }
172
);
173
);
173
174
Lines 182-188 $schema->resultset('BorrowerPasswordRecovery')->create( Link Here
182
    {
183
    {
183
        borrowernumber => $borrowernumber3,
184
        borrowernumber => $borrowernumber3,
184
        uuid           => $uuid3,
185
        uuid           => $uuid3,
185
        valid_until    => DateTime->now( time_zone => C4::Context->tz() )->subtract( days => 3 )->datetime()
186
        valid_until    => dt_from_string()->subtract( days => 3 )->datetime()
186
    }
187
    }
187
);
188
);
188
189
(-)a/t/db_dependent/Sitemapper.t (-2 / +2 lines)
Lines 21-26 use Modern::Perl; Link Here
21
use File::Basename;
21
use File::Basename;
22
use File::Path;
22
use File::Path;
23
use DateTime;
23
use DateTime;
24
use Koha::DateUtils;
24
use Test::MockModule;
25
use Test::MockModule;
25
use Test::More tests => 16;
26
use Test::More tests => 16;
26
use Carp qw/croak carp/;
27
use Carp qw/croak carp/;
Lines 31-37 BEGIN { Link Here
31
    use_ok('Koha::Sitemapper::Writer');
32
    use_ok('Koha::Sitemapper::Writer');
32
}
33
}
33
34
34
my $now_value       = DateTime->now();
35
my $now_value       = dt_from_string();
35
my $mocked_datetime = Test::MockModule->new('DateTime');
36
my $mocked_datetime = Test::MockModule->new('DateTime');
36
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
37
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
37
38
38
- 

Return to bug 24840