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

(-)a/C4/Circulation.pm (-11 / +9 lines)
Lines 705-711 sub CanBookBeIssued { Link Here
705
    if ($duedate && ref $duedate ne 'DateTime') {
705
    if ($duedate && ref $duedate ne 'DateTime') {
706
        $duedate = dt_from_string($duedate);
706
        $duedate = dt_from_string($duedate);
707
    }
707
    }
708
    my $now = DateTime->now( time_zone => C4::Context->tz() );
708
    my $now = dt_from_string();
709
    unless ( $duedate ) {
709
    unless ( $duedate ) {
710
        my $issuedate = $now->clone();
710
        my $issuedate = $now->clone();
711
711
Lines 1236-1242 sub checkHighHolds { Link Here
1236
            }
1236
            }
1237
        }
1237
        }
1238
1238
1239
        my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1239
        my $issuedate = dt_from_string();
1240
1240
1241
        my $calendar = Koha::Calendar->new( branchcode => $branchcode );
1241
        my $calendar = Koha::Calendar->new( branchcode => $branchcode );
1242
1242
Lines 1315-1321 sub AddIssue { Link Here
1315
1315
1316
    # $issuedate defaults to today.
1316
    # $issuedate defaults to today.
1317
    if ( !defined $issuedate ) {
1317
    if ( !defined $issuedate ) {
1318
        $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1318
        $issuedate = dt_from_string();
1319
    }
1319
    }
1320
    else {
1320
    else {
1321
        if ( ref $issuedate ne 'DateTime' ) {
1321
        if ( ref $issuedate ne 'DateTime' ) {
Lines 1466-1472 sub AddIssue { Link Here
1466
            $item_object->holdingbranch(C4::Context->userenv->{'branch'});
1466
            $item_object->holdingbranch(C4::Context->userenv->{'branch'});
1467
            $item_object->itemlost(0);
1467
            $item_object->itemlost(0);
1468
            $item_object->onloan($datedue->ymd());
1468
            $item_object->onloan($datedue->ymd());
1469
            $item_object->datelastborrowed(DateTime->now( time_zone => C4::Context->tz() )->ymd()); # FIXME we should use dt_from_string here
1469
            $item_object->datelastborrowed( dt_from_string()->ymd() );
1470
            $item_object->store({log_action => 0});
1470
            $item_object->store({log_action => 0});
1471
            ModDateLastSeen( $item_object->itemnumber );
1471
            ModDateLastSeen( $item_object->itemnumber );
1472
1472
Lines 2805-2811 sub CanBookBeRenewed { Link Here
2805
                $soonestrenewal->truncate( to => 'day' );
2805
                $soonestrenewal->truncate( to => 'day' );
2806
            }
2806
            }
2807
2807
2808
            if ( $soonestrenewal > DateTime->now( time_zone => C4::Context->tz() ) )
2808
            if ( $soonestrenewal > dt_from_string() )
2809
            {
2809
            {
2810
                return ( 0, "auto_too_soon" ) if $issue->auto_renew && $patron->autorenew_checkouts;
2810
                return ( 0, "auto_too_soon" ) if $issue->auto_renew && $patron->autorenew_checkouts;
2811
                return ( 0, "too_soon" );
2811
                return ( 0, "too_soon" );
Lines 2932-2938 sub AddRenewal { Link Here
2932
    my $itemnumber      = shift or return;
2932
    my $itemnumber      = shift or return;
2933
    my $branch          = shift;
2933
    my $branch          = shift;
2934
    my $datedue         = shift;
2934
    my $datedue         = shift;
2935
    my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz);
2935
    my $lastreneweddate = shift || dt_from_string();
2936
    my $skipfinecalc    = shift;
2936
    my $skipfinecalc    = shift;
2937
2937
2938
    my $item_object   = Koha::Items->find($itemnumber) or return;
2938
    my $item_object   = Koha::Items->find($itemnumber) or return;
Lines 2972-2978 sub AddRenewal { Link Here
2972
2972
2973
            $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
2973
            $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
2974
                                            dt_from_string( $issue->date_due, 'sql' ) :
2974
                                            dt_from_string( $issue->date_due, 'sql' ) :
2975
                                            DateTime->now( time_zone => C4::Context->tz());
2975
                                            dt_from_string();
2976
            $datedue =  CalcDateDue($datedue, $itemtype, $circ_library->branchcode, $patron_unblessed, 'is a renewal');
2976
            $datedue =  CalcDateDue($datedue, $itemtype, $circ_library->branchcode, $patron_unblessed, 'is a renewal');
2977
        }
2977
        }
2978
2978
Lines 3595-3603 sub CalcDateDue { Link Here
3595
            $datedue = $startdate->clone;
3595
            $datedue = $startdate->clone;
3596
        }
3596
        }
3597
    } else {
3597
    } else {
3598
        $datedue =
3598
        $datedue = dt_from_string()->truncate( to => 'minute' );
3599
          DateTime->now( time_zone => C4::Context->tz() )
3600
          ->truncate( to => 'minute' );
3601
    }
3599
    }
3602
3600
3603
3601
Lines 4081-4087 sub GetAgeRestriction { Link Here
4081
            }
4079
            }
4082
4080
4083
            #Get how many days the borrower has to reach the age restriction
4081
            #Get how many days the borrower has to reach the age restriction
4084
            my @Today = split /-/, DateTime->today->ymd();
4082
            my @Today = split /-/, dt_from_string()->ymd();
4085
            my $daysToAgeRestriction = Date_to_Days(@alloweddate) - Date_to_Days(@Today);
4083
            my $daysToAgeRestriction = Date_to_Days(@alloweddate) - Date_to_Days(@Today);
4086
            #Negative days means the borrower went past the age restriction age
4084
            #Negative days means the borrower went past the age restriction age
4087
            return ($restriction_year, $daysToAgeRestriction);
4085
            return ($restriction_year, $daysToAgeRestriction);
(-)a/C4/Letters.pm (-1 / +1 lines)
Lines 796-802 sub _parseletter { Link Here
796
    }
796
    }
797
797
798
    if ($letter->{content} && $letter->{content} =~ /<<today>>/) {
798
    if ($letter->{content} && $letter->{content} =~ /<<today>>/) {
799
        my $todaysdate = output_pref( DateTime->now() );
799
        my $todaysdate = output_pref( dt_from_string() );
800
        $letter->{content} =~ s/<<today>>/$todaysdate/go;
800
        $letter->{content} =~ s/<<today>>/$todaysdate/go;
801
    }
801
    }
802
802
(-)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::Biblio qw( AddBiblio TransformKohaToMarc GetMarcBiblio GetFrameworkCode GetMarcFromKohaField );
33
use C4::Biblio qw( AddBiblio TransformKohaToMarc GetMarcBiblio GetFrameworkCode GetMarcFromKohaField );
Lines 174-180 sub process_ordrsp { Link Here
174
                            ordernumber             => $ordernumber,
175
                            ordernumber             => $ordernumber,
175
                            cancellationreason      => $reason,
176
                            cancellationreason      => $reason,
176
                            orderstatus             => 'cancelled',
177
                            orderstatus             => 'cancelled',
177
                            datecancellationprinted => DateTime->now()->ymd(),
178
                            datecancellationprinted => dt_from_string()->ymd(),
178
                        }
179
                        }
179
                    );
180
                    );
180
                }
181
                }
Lines 624-630 sub quote_item { Link Here
624
    # database definitions should set some of these defaults but dont
625
    # database definitions should set some of these defaults but dont
625
    my $order_hash = {
626
    my $order_hash = {
626
        biblionumber       => $bib->{biblionumber},
627
        biblionumber       => $bib->{biblionumber},
627
        entrydate          => DateTime->now( time_zone => 'local' )->ymd(),
628
        entrydate          => dt_from_string()->ymd(),
628
        basketno           => $basketno,
629
        basketno           => $basketno,
629
        listprice          => $item->price,
630
        listprice          => $item->price,
630
        quantity           => $order_quantity,
631
        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/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/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 302-308 if ($barcode) { Link Here
302
      AddReturn( $barcode, $userenv_branch, $exemptfine, $return_date );
302
      AddReturn( $barcode, $userenv_branch, $exemptfine, $return_date );
303
303
304
    if ($returned) {
304
    if ($returned) {
305
        my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute');
305
        my $time_now = dt_from_string()->truncate( to => 'minute');
306
        my $date_due_dt = dt_from_string( $issue->date_due, 'sql' );
306
        my $date_due_dt = dt_from_string( $issue->date_due, 'sql' );
307
        my $duedate = $date_due_dt->strftime('%Y-%m-%d %H:%M');
307
        my $duedate = $date_due_dt->strftime('%Y-%m-%d %H:%M');
308
        $returneditems{0}      = $barcode;
308
        $returneditems{0}      = $barcode;
Lines 311-317 if ($barcode) { Link Here
311
        $input{borrowernumber} = $borrower->{'borrowernumber'};
311
        $input{borrowernumber} = $borrower->{'borrowernumber'};
312
        $input{duedate}        = $duedate;
312
        $input{duedate}        = $duedate;
313
        unless ( $dropboxmode ) {
313
        unless ( $dropboxmode ) {
314
            $input{return_overdue} = 1 if (DateTime->compare($date_due_dt, DateTime->now()) == -1);
314
            $input{return_overdue} = 1 if (DateTime->compare($date_due_dt, dt_from_string()) == -1);
315
        } else {
315
        } else {
316
            $input{return_overdue} = 1 if (DateTime->compare($date_due_dt, $dropboxdate) == -1);
316
            $input{return_overdue} = 1 if (DateTime->compare($date_due_dt, $dropboxdate) == -1);
317
        }
317
        }
Lines 569-575 foreach ( sort { $a <=> $b } keys %returneditems ) { Link Here
569
            $ri{duedate} = output_pref($duedate);
569
            $ri{duedate} = output_pref($duedate);
570
            my $patron = Koha::Patrons->find( $riborrowernumber{$_} );
570
            my $patron = Koha::Patrons->find( $riborrowernumber{$_} );
571
            unless ( $dropboxmode ) {
571
            unless ( $dropboxmode ) {
572
                $ri{return_overdue} = 1 if (DateTime->compare($duedate, DateTime->now()) == -1);
572
                $ri{return_overdue} = 1 if (DateTime->compare($duedate, dt_from_string()) == -1);
573
            } else {
573
            } else {
574
                $ri{return_overdue} = 1 if (DateTime->compare($duedate, $dropboxdate) == -1);
574
                $ri{return_overdue} = 1 if (DateTime->compare($duedate, $dropboxdate) == -1);
575
            }
575
            }
(-)a/installer/data/mysql/fix_unclosed_nonaccruing_fines_bug17135.pl (-1 / +1 lines)
Lines 77-83 sub Bug_17135_fix { Link Here
77
77
78
    my $control = C4::Context->preference('CircControl');
78
    my $control = C4::Context->preference('CircControl');
79
    my $mode = C4::Context->preference('finesMode');
79
    my $mode = C4::Context->preference('finesMode');
80
    my $today = DateTime->now( time_zone => C4::Context->tz() );
80
    my $today = dt_from_string();
81
    my $dbh = C4::Context->dbh;
81
    my $dbh = C4::Context->dbh;
82
82
83
    ## fetch the unclosed FU fines linked to the issues by issue_id
83
    ## 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 88-94 my $mode = C4::Context->preference('finesMode'); Link Here
88
my $delim = "\t";    # ?  C4::Context->preference('delimiter') || "\t";
88
my $delim = "\t";    # ?  C4::Context->preference('delimiter') || "\t";
89
89
90
my %is_holiday;
90
my %is_holiday;
91
my $today = DateTime->now( time_zone => C4::Context->tz() );
91
my $today = dt_from_string();
92
my $filename;
92
my $filename;
93
if ($log or $output_dir) {
93
if ($log or $output_dir) {
94
    $filename = get_filename($output_dir);
94
    $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/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 21-26 Link Here
21
use Modern::Perl;
21
use Modern::Perl;
22
22
23
use DateTime;
23
use DateTime;
24
use Koha::DateUtils;
24
use Test::More tests => 8;
25
use Test::More tests => 8;
25
use Test::Warn;
26
use Test::Warn;
26
27
Lines 39-45 is ( C4::Circulation::GetAgeRestriction('K16'), '16', 'K16 returns 16' ); Link Here
39
subtest 'Patron tests - 15 years old' => sub {
40
subtest 'Patron tests - 15 years old' => sub {
40
    plan tests => 5;
41
    plan tests => 5;
41
    ##Testing age restriction for a borrower.
42
    ##Testing age restriction for a borrower.
42
    my $now = DateTime->now();
43
    my $now = dt_from_string();
43
    my $borrower = { dateofbirth => $now->add( years => -15 )->strftime("%Y-%m-%d") };
44
    my $borrower = { dateofbirth => $now->add( years => -15 )->strftime("%Y-%m-%d") };
44
    TestPatron($borrower,0);
45
    TestPatron($borrower,0);
45
};
46
};
Lines 56-62 subtest 'Patron tests - 15 years old (Time Zone shifts)' => sub { Link Here
56
            Time::Fake->offset("+${offset}h");
57
            Time::Fake->offset("+${offset}h");
57
58
58
            ##Testing age restriction for a borrower.
59
            ##Testing age restriction for a borrower.
59
            my $now = DateTime->now();
60
            my $now = dt_from_string();
60
            my $borrower = { dateofbirth => $now->add( years => -15 )->strftime("%Y-%m-%d") };
61
            my $borrower = { dateofbirth => $now->add( years => -15 )->strftime("%Y-%m-%d") };
61
            TestPatron($borrower,$offset);
62
            TestPatron($borrower,$offset);
62
63
(-)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 37-43 my $builder = t::lib::TestBuilder->new; Link Here
37
38
38
$schema->storage->txn_begin();
39
$schema->storage->txn_begin();
39
40
40
my $now_value       = DateTime->now();
41
my $now_value       = dt_from_string();
41
my $mocked_datetime = Test::MockModule->new('DateTime');
42
my $mocked_datetime = Test::MockModule->new('DateTime');
42
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
43
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
43
44
Lines 111-117 Koha::CirculationRules->set_rules( Link Here
111
112
112
113
113
my $orig_due = C4::Circulation::CalcDateDue(
114
my $orig_due = C4::Circulation::CalcDateDue(
114
    DateTime->now(time_zone => C4::Context->tz()),
115
    dt_from_string(),
115
    $item->effective_itemtype,
116
    $item->effective_itemtype,
116
    $patron->branchcode,
117
    $patron->branchcode,
117
    $patron->unblessed
118
    $patron->unblessed
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-1 / +1 lines)
Lines 57-63 my $dbh = C4::Context->dbh; Link Here
57
57
58
$dbh->do(q|DELETE FROM letter|);
58
$dbh->do(q|DELETE FROM letter|);
59
59
60
my $now_value       = DateTime->now();
60
my $now_value       = dt_from_string();
61
my $mocked_datetime = Test::MockModule->new('DateTime');
61
my $mocked_datetime = Test::MockModule->new('DateTime');
62
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
62
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
63
63
(-)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 112-132 $schema->resultset('BorrowerPasswordRecovery')->create( Link Here
112
    {
113
    {
113
        borrowernumber => $borrowernumber1,
114
        borrowernumber => $borrowernumber1,
114
        uuid           => $uuid1,
115
        uuid           => $uuid1,
115
        valid_until    => DateTime->now( time_zone => C4::Context->tz() )->add( days => 2 )->datetime()
116
        valid_until    => dt_from_string()->add( days => 2 )->datetime()
116
    }
117
    }
117
);
118
);
118
$schema->resultset('BorrowerPasswordRecovery')->create(
119
$schema->resultset('BorrowerPasswordRecovery')->create(
119
    {
120
    {
120
        borrowernumber => $borrowernumber2,
121
        borrowernumber => $borrowernumber2,
121
        uuid           => $uuid2,
122
        uuid           => $uuid2,
122
        valid_until    => DateTime->now( time_zone => C4::Context->tz() )->subtract( days => 2 )->datetime()
123
        valid_until    => dt_from_string()->subtract( days => 2 )->datetime()
123
    }
124
    }
124
);
125
);
125
$schema->resultset('BorrowerPasswordRecovery')->create(
126
$schema->resultset('BorrowerPasswordRecovery')->create(
126
    {
127
    {
127
        borrowernumber => $borrowernumber3,
128
        borrowernumber => $borrowernumber3,
128
        uuid           => $uuid3,
129
        uuid           => $uuid3,
129
        valid_until    => DateTime->now( time_zone => C4::Context->tz() )->subtract( days => 3 )->datetime()
130
        valid_until    => dt_from_string()->subtract( days => 3 )->datetime()
130
    }
131
    }
131
);
132
);
132
133
Lines 164-170 $schema->resultset('BorrowerPasswordRecovery')->create( Link Here
164
    {
165
    {
165
        borrowernumber => $borrowernumber2,
166
        borrowernumber => $borrowernumber2,
166
        uuid           => $uuid2,
167
        uuid           => $uuid2,
167
        valid_until    => DateTime->now( time_zone => C4::Context->tz() )->subtract( days => 2 )->datetime()
168
        valid_until    => dt_from_string()->subtract( days => 2 )->datetime()
168
    }
169
    }
169
);
170
);
170
171
Lines 179-185 $schema->resultset('BorrowerPasswordRecovery')->create( Link Here
179
    {
180
    {
180
        borrowernumber => $borrowernumber3,
181
        borrowernumber => $borrowernumber3,
181
        uuid           => $uuid3,
182
        uuid           => $uuid3,
182
        valid_until    => DateTime->now( time_zone => C4::Context->tz() )->subtract( days => 3 )->datetime()
183
        valid_until    => dt_from_string()->subtract( days => 3 )->datetime()
183
    }
184
    }
184
);
185
);
185
186
(-)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