Skip to content
This repository was archived by the owner on May 29, 2024. It is now read-only.

Commit 3bc6899

Browse files
author
Seth Battis
committed
Time Zones
Fixed time zones in calculations where it matters -- left untouched areas where we were simply comparing the time between two dates.
1 parent 530f076 commit 3bc6899

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

config.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
define('TOOL_START_PAGE', 'index.php');
99
}
1010

11+
define('SCHOOL_TIME_ZONE', 'America/New_York'); // Go Sox! Stupid PHP.
12+
1113
define('DATA_COLLECTION_CRONTAB', '0 0 * * *'); // collect data every night at midnight
1214

1315
/* graph coloring (tied into CSS styling of summary text, so be sure to use

private/data-collection.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,18 @@ function collectStatistics($term) {
121121

122122
// check for due dates
123123
$dueDate = new DateTime($assignment['due_at']);
124+
$dueDate->setTimeZone(new DateTimeZone(SCHOOL_TIME_ZONE));
124125
if (($timestamp - $dueDate->getTimestamp()) > 0) {
125126
$statistic['assignments_due_count']++;
126127

127128
// update created_modified_histogram
128-
$createdModifiedHistogram[HISTOGRAM_CREATED][date("g:00 a", strtotime($assignment['created_at']))]++;
129-
if ($assignment['updated_at'] != $assignment['created_at']) {
130-
$createdModifiedHistogram[HISTOGRAM_MODIFIED][date("g:00 a", strtotime($assignment['updated_at']))]++;
129+
$createdAt = new DateTime($assignment['created_at']);
130+
$createdAt->setTimeZone(new DateTimeZone(SCHOOL_TIME_ZONE));
131+
$updatedAt = new DateTime($assignment['updated_at']);
132+
$updatedAt->setTimeZone(new DateTimeZone(SCHOOL_TIME_ZONE));
133+
$createdModifiedHistogram[HISTOGRAM_CREATED][$createdAt->format('g:00 a')]++;
134+
if ($createdAt != $updatedAt) {
135+
$createdModifiedHistogram[HISTOGRAM_MODIFIED][$updatedAt->format('g:00 a')]++;
131136
}
132137

133138
// tally lead time on the assignment

0 commit comments

Comments
 (0)