From efba28f3f4a740d56e6af57a267e335ec1aaef03 Mon Sep 17 00:00:00 2001 From: "oncall@orange" Date: Mon, 11 May 2020 10:53:28 -0400 Subject: [PATCH] fix misc bugs --- oncall.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/oncall.php b/oncall.php index 8faee7e..348ac15 100644 --- a/oncall.php +++ b/oncall.php @@ -4,12 +4,11 @@ declare(strict_types = 1); require_once 'vendor/autoload.php'; use Yasumi\Holiday; - /* On Call Ticket Notification Script */ $oncall = new oncall(); $oncall->dateAndTimeCheck(); $oncall->retrieveItems(); -if (!$this->notify) { +if (!$oncall->notify) { exit(0); } $oncall->setEmail(); @@ -71,7 +70,7 @@ class oncall { * A flag of whether Mattermost should be contacted. * @var bool */ - private $notify; + public $notify; public function __construct() { // Load the .env file @@ -107,7 +106,8 @@ class oncall { if ($td_min > 60) { $this->everyone = TRUE; } - if ($td_min < 3 || ($td_min >= 30 || $td_min < 33)) { + // Notify every 30 minutes. + if (($td_min % 30) < 3) { $this->notify = TRUE; } return $td_min; @@ -201,7 +201,7 @@ class oncall { public function setEmail() { // path to file containing email of person on call - $contactfile = './contact.txt'; + $contactfile = __DIR__ . "/contact.txt"; // set the email of the person on call $this->email = trim(file_get_contents("$contactfile")); } @@ -210,7 +210,7 @@ class oncall { * Checks whether we're responsible for on-call on this date and time. */ public function dateAndTimeCheck() { - $today = new DateTime(); + $today = new DateTime("now", new DateTimeZone('America/New_York')); $thisYear = (int) $today->format('Y'); $thisHour = (int) $today->format('H');