fix misc bugs

This commit is contained in:
Jon Goldberg 2020-05-11 10:53:28 -04:00
parent c027e56dd0
commit efba28f3f4

View File

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