Skip to content

Commit

Permalink
Bug 1347175 - cron: Invalid local time for date in time zone: America…
Browse files Browse the repository at this point in the history
…/Los_Angeles
  • Loading branch information
dylanwh committed Apr 18, 2017
1 parent cfded4d commit f04f94b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions extensions/RequestNagger/bin/send-request-nags.pl
Expand Up @@ -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;

Expand Down Expand Up @@ -42,10 +43,9 @@
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()");
Expand Down Expand Up @@ -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 });

Expand All @@ -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' );
Expand Down

0 comments on commit f04f94b

Please sign in to comment.