]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1347175 - cron: Invalid local time for date in time zone: America/Los_Angeles
authorDylan William Hardison <dylan@hardison.net>
Tue, 18 Apr 2017 13:58:44 +0000 (09:58 -0400)
committerDylan William Hardison <dylan@hardison.net>
Tue, 18 Apr 2017 13:58:57 +0000 (09:58 -0400)
extensions/RequestNagger/bin/send-request-nags.pl

index d9da4f04be47c3ffa7553d24dc7260f6794784e4..f823fc197dadaf4a8ea66d8a5c405bb5d5d22a58 100755 (executable)
@@ -7,6 +7,7 @@
 # This Source Code Form is "Incompatible With Secondary Licenses", as
 # defined by the Mozilla Public License, v. 2.0.
 
+use 5.10.1;
 use strict;
 use warnings;
 
@@ -42,10 +43,9 @@ if (my $filename = shift @ARGV) {
     exit;
 }
 
-my $dbh = Bugzilla->dbh;
-my $date = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
-my $now = datetime_from($date)->truncate( to => 'day' );
-$date = format_time($date, '%a, %d %b %Y %T %z', 'UTC');
+my $dbh     = Bugzilla->dbh;
+my $db_date = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
+my $date    = format_time($db_date, '%a, %d %b %Y %T %z', 'UTC');
 
 # delete expired defers
 $dbh->do("DELETE FROM nag_defer WHERE defer_until <= CURRENT_DATE()");
@@ -156,6 +156,7 @@ sub send_nags {
 
 sub _include_request {
     my ($request, $report) = @_;
+    state $now = datetime_from($db_date, 'UTC')->truncate( to => 'day' );
 
     my $recipient = Bugzilla::User->new({ id => $request->{recipient_id}, cache => 1 });
 
@@ -180,7 +181,7 @@ sub _include_request {
     }
 
     # exclude weekends and re-check nag-interval
-    my $date = datetime_from($request->{modification_date});
+    my $date = datetime_from($request->{modification_date}, 'UTC');
     my $hours = 0;
     $hours += 24 - $date->hour if $date->day_of_week <= 5;
     $date->add( days => 1 )->truncate( to => 'day' );