diff --git a/inc/class.schedule.php b/inc/class.schedule.php
--- a/inc/class.schedule.php
+++ b/inc/class.schedule.php
@@ -538,7 +538,8 @@ class Schedule
* Also, ensure that our $time array is big enough for all of
* these courses.
*/
- $max_day_plusone = 5;
+ $dayloop_max = 5;
+ $have_sunday = FALSE;
$have_saturday = FALSE;
$max_time = (int)max($time);
@@ -550,12 +551,11 @@ class Schedule
for ($si = 0; $si < $course_slot->sections_count(); $si ++)
foreach ($course_slot->section_get_i($si)->getMeetings() as $meeting)
{
- /* Saturdayness */
+ /* Sundayness and Saturdayness */
+ if ($meeting->getDay(6))
+ $have_sunday = TRUE;
if ($meeting->getDay(5))
- {
- $max_day_plusone = 6;
- $have_saturday = TRUE;
- }
+ $have_saturday = TRUE;
/* very late / very early classes */
while ((int)ltrim($meeting->getEndTime(), '0') > $max_time)
@@ -580,6 +580,9 @@ class Schedule
if ($sort_time)
sort($time);
+ if ($have_saturday)
+ $dayloop_max = 6;
+
echo '
' . PHP_EOL
. '
' . PHP_EOL
. '
' . PHP_EOL
@@ -679,8 +682,10 @@ class Schedule
// Header row
echo "
\n"
- . ' | ' . ($i + 1) . " | \n"
- . " Monday | \n"
+ . ' ' . ($i + 1) . " | \n";
+ if ($have_sunday)
+ echo ' Sunday | ' . PHP_EOL;
+ echo " Monday | \n"
. " Tuesday | \n"
. " Wednesday | \n"
. " Thursday | \n"
@@ -690,16 +695,23 @@ class Schedule
echo "
\n";
$last_meeting = array();
- $rowspan = array(0, 0, 0, 0, 0, 0);
+ $rowspan = array(0, 0, 0, 0, 0, 0, 0);
for($r = 0; $r < (count($time)-1); $r++)
{
echo "
\n"
. " | " . $this->prettyTime($time[$r]) . " | \n";
- /* currently, 0-5 = monday-saturday */
- for($dayLoop = 0; $dayLoop < $max_day_plusone; $dayLoop++)
+ /*
+ * Currently, 6, 0-5 = sunday, monday-saturday. We use
+ * the trick that -1 through 5 mod 7 is
+ * sunday-saturday.
+ */
+ for($dayLoop = $have_sunday ? -1 : 0; $dayLoop < $dayloop_max; $dayLoop = ($dayLoop + 1) % 7)
{
+ if ($dayLoop < 0)
+ $dayLoop = 6;
+
/* Makes sure there is not a class already in progress */
if($rowspan[$dayLoop] <= 0)
{
diff --git a/inc/class.section_meeting.inc b/inc/class.section_meeting.inc
--- a/inc/class.section_meeting.inc
+++ b/inc/class.section_meeting.inc
@@ -46,9 +46,10 @@ class SectionMeeting
* Construct a SectionMeeting.
*
* \param $days
- * A string of single-char day upon which a section meets. Monday
- * is represented with 'm', Tuesday with 't', Wednesday with 'w',
- * Thursday with 'h', and Friday with 'f'.
+ * A string of single-char day upon which a section meets. Sunday
+ * is represented with 'u', Monday with 'm', Tuesday with 't',
+ * Wednesday with 'w', Thursday with 'h', Friday with 'f', and
+ * Saturday with 's'.
* \param $time_start
* The time of day when the section meeting starts. Use
* school_crawl_time_format() or ensure that the time is formatted
@@ -83,11 +84,12 @@ class SectionMeeting
*
* \param $days_str
* The days of the week in a string format. One char per
- * day. Mon-Sat is represented with 'm', 't', 'w', 'h', 'f', 's'.
+ * day. Sun-Sat is represented with 'u', 'm', 't', 'w', 'h', 'f',
+ * 's'.
*/
private function days_set($days_str)
{
- $this->days = array(0 => FALSE, 1 => FALSE, 2 => FALSE, 3 => FALSE, 4 => FALSE, 5 => FALSE);
+ $this->days = array(0 => FALSE, 1 => FALSE, 2 => FALSE, 3 => FALSE, 4 => FALSE, 5 => FALSE, 6 => FALSE);
$days_str_strlen = strlen($days_str);
for ($i = 0; $i < $days_str_strlen; $i ++)
@@ -102,9 +104,11 @@ class SectionMeeting
*/
private static function day_atoi($day_c)
{
- static $day_atoi = array('m' => 0, 't' => 1, 'w' => 2, 'h' => 3, 'f' => 4, 's' => 5,
- 'M' => 0, 'T' => 1, 'W' => 2, 'H' => 3, 'F' => 4, 'S' => 5,
- 0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5);
+ static $day_atoi = array(
+ 'm' => 0, 't' => 1, 'w' => 2, 'h' => 3, 'f' => 4, 's' => 5, 'u' => 6,
+ 'M' => 0, 'T' => 1, 'W' => 2, 'H' => 3, 'F' => 4, 'S' => 5, 'U' => 6,
+ 0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6,
+ );
return $day_atoi[$day_c];
}
@@ -218,7 +222,7 @@ class SectionMeeting
* times. But if they don't both meet on the same day at least
* once, they don't conflict.
*/
- for ($day = 0; $day < 6; $day ++)
+ for ($day = 0; $day < 7; $day ++)
{
if ($this->getDay($day) && $that->getDay($day))
return TRUE;
@@ -242,7 +246,7 @@ class SectionMeeting
*/
public function to_json_array()
{
- static $daymap = array(0 => 'm', 1 => 't', 2 => 'w', 3 => 'h', 4 => 'f', 5 => 's');
+ static $daymap = array(0 => 'm', 1 => 't', 2 => 'w', 3 => 'h', 4 => 'f', 5 => 's', 6 => 'u');
$json_array = array(
'time_start' => $this->time_start,
@@ -253,7 +257,7 @@ class SectionMeeting
'type' => $this->type,
);
- for ($day = 0; $day < 6; $day ++)
+ for ($day = 0; $day < 7; $day ++)
$json_array['days'][$daymap[$day]] = $this->getDay($day);
return $json_array;
diff --git a/inc/school.crawl.inc b/inc/school.crawl.inc
--- a/inc/school.crawl.inc
+++ b/inc/school.crawl.inc
@@ -165,14 +165,14 @@ function school_crawl_gmmktime(array $tm
* simplicity. One-char representations are supported, however, but
* use 'm', 't', 'w', 'h', 'f' to distinguish Thursday and
* Tuesday. 'r' may also be used for Thursday.). Case does not
- * matter. 's' is for Saturday, based on CCBCMD.
+ * matter. 's' is for Saturday, based on CCBCMD. 'u' is for Sunday.
* \return
* slate_permutate's strange internal days representation.
*/
function school_crawl_days_format(array $school_crawl_log, $days)
{
- static $daymap_1 = array('m' => 'm', 't' => 't', 'w' => 'w', 'h' => 'h', 'r' => 'h', 'f' => 'f', 's' => 's');
- static $daymap_2 = array('th' => 'h');
+ static $daymap_1 = array('u' => 'u', 'm' => 'm', 't' => 't', 'w' => 'w', 'h' => 'h', 'r' => 'h', 'f' => 'f', 's' => 's');
+ static $daymap_2 = array('su' => 'u', 'th' => 'h');
$my_days = array();
foreach ($days as $day)
diff --git a/input.php b/input.php
--- a/input.php
+++ b/input.php
@@ -313,6 +313,7 @@ if (!empty($_REQUEST['selectsemester']))
+
@@ -329,12 +330,13 @@ if (!empty($_REQUEST['selectsemester']))
Prof |
Start Time |
End Time |
+ Su |
M |
Tu |
W |
Th |
F |
- S |
+ Sa |
|
|
@@ -381,7 +383,8 @@ function input_course_js(Course $course,
. json_encode($section->getSynonym()) . ', '
. json_encode($meeting->getStartTime()) . ', '
. json_encode($meeting->getEndTime()) . ', '
- . json_encode(array('m' => $meeting->getDay(0), 't' => $meeting->getDay(1), 'w' => $meeting->getDay(2), 'h' => $meeting->getDay(3), 'f' => $meeting->getDay(4),
+ . json_encode(array('u' => $meeting->getDay(6), 'm' => $meeting->getDay(0), 't' => $meeting->getDay(1),
+ 'w' => $meeting->getDay(2), 'h' => $meeting->getDay(3), 'f' => $meeting->getDay(4),
's' => $meeting->getDay(5))) . ', '
. json_encode($meeting->instructor_get()) . ', '
. json_encode($meeting->getLocation()) . ', '
diff --git a/process.php b/process.php
--- a/process.php
+++ b/process.php
@@ -31,16 +31,16 @@ function arrayToDays($array, $mode = 'nu
switch($mode)
{
case 'short':
- $days = array('Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat');
+ $days = array('Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun');
break;
case 'long':
- $days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
+ $days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
break;
case 'num':
- $days = array('1','2','3','4','5');
+ $days = array('1','2','3','4','5', '6');
break;
case 'alpha':
- $days = array('m', 't', 'w', 'h', 'f', 's');
+ $days = array('m', 't', 'w', 'h', 'f', 's', 'u');
break;
default:
$outString = 'Invalid mode passed to arrayToDays()!';
@@ -55,13 +55,21 @@ function arrayToDays($array, $mode = 'nu
$outString .= ', ';
}
}
+ /*
+ * Sunday is last in the array format (our input, the
+ * array indices used on the input.php page) but first
+ * in good/real formats:
+ */
+ if (isset($array[$i]) && $array[$i] == $key)
+ $outString = $days[$i] . ($pretty ? ', ' : '') . $outString;
+
if($pretty){
$outString = substr($outString,0,strlen($outString) - 2); // Remove last comma and space
$outString = substr($outString,0, strrpos( $outString, ' ')) . ' and' . substr($outString, strrpos( $outString, ' '), strlen($outString));
}
}
else {
- for($i=0; $i < 6; $i++)
+ for($i=0; $i < 7; $i++)
if(isset($array[$i]))
$outString = $days[$i];
}
diff --git a/school.d/hope.crawl.inc b/school.d/hope.crawl.inc
--- a/school.d/hope.crawl.inc
+++ b/school.d/hope.crawl.inc
@@ -291,6 +291,8 @@ function hope_crawl_semester(array $scho
}
}
+ if (trim($section_csv[$fields['U']]))
+ school_crawl_logf($school_crawl_log, 0, "Section %d has sunday.", $synonym);
$days = school_crawl_days_format($school_crawl_log, array_filter(array_slice($section_csv, $fields['M'], 7), '_hope_crawl_days_filter'));
list($time_start, $time_end) = explode('-', $section_csv[$fields['Times']]);
if (strlen($time_start) != 4 || strlen($time_end) != 4)
diff --git a/school.d/umich.crawl.inc b/school.d/umich.crawl.inc
--- a/school.d/umich.crawl.inc
+++ b/school.d/umich.crawl.inc
@@ -165,7 +165,7 @@ function umich_crawl_semester(array $sch
'TH' => FALSE,
'F' => FALSE,
'S' => FALSE,
- 'SU' => FALSE /* OK, we'll have to add Sunday support someday ;-) */,
+ 'SU' => FALSE,
'Start Date' => FALSE /* yea! */,
'End Date' => FALSE /* "12/13/2011" */,
'Time' => FALSE /* "1230-130PM", "9-1030AM", "1130-1PM" */,
@@ -174,12 +174,11 @@ function umich_crawl_semester(array $sch
'Units' => FALSE /* As in credit hours */,
);
$ignored_fields = array(
- 'Term' => TRUE,
- 'Session' => TRUE,
- 'Acad Group' => TRUE,
- 'Codes' => TRUE,
- 'SU' => TRUE,
- );
+ 'Term' => TRUE,
+ 'Session' => TRUE,
+ 'Acad Group' => TRUE,
+ 'Codes' => TRUE,
+ );
foreach (str_getcsv($csv[0]) as $col_num => $col_name)
if (isset($fields[$col_name]))
@@ -229,7 +228,7 @@ function umich_crawl_semester(array $sch
$credit_hours = (float)$row[$fields['Units']];
$days = '';
- foreach (array('M' => 'm', 'T' => 't', 'W' => 'w', 'TH' => 'h', 'F' => 'f', 'S' => 's')
+ foreach (array('SU' => 'u', 'M' => 'm', 'T' => 't', 'W' => 'w', 'TH' => 'h', 'F' => 'f', 'S' => 's')
as $field => $day)
if (strlen(trim($row[$fields[$field]])))
$days .= $day;
diff --git a/scripts/scheduleInput.js b/scripts/scheduleInput.js
--- a/scripts/scheduleInput.js
+++ b/scripts/scheduleInput.js
@@ -200,7 +200,8 @@ function add_section_n(cnum, name, synon
section_html = section_html + genOptionHtml(etime, prettyTime(etime), etime);
}
- section_html = section_html + '\
+ section_html = section_html + '\n\
+
| \
| \
| \
| \
@@ -244,7 +245,9 @@ function add_section_n(cnum, name, synon
section_tr.find('.section-type-entry').val(type);
section_tr.find('.section-credit-hours-entry').val(credit_hours);
- /* unhide the saturday columns if it's used by autocomplete data */
+ /* unhide the saturday and sunday columns if they're used by autocomplete data */
+ if (days.u)
+ jQuery('#jsrows col.sunday').removeClass('collapsed');
if (days.s)
jQuery('#jsrows col.saturday').removeClass('collapsed');
@@ -254,7 +257,7 @@ function add_section_n(cnum, name, synon
}
function add_section(cnum)
{
- var section_i = add_section_n(cnum, '', '', '', '', {m: false, t: false, w: false, h: false, f: false, s: false}, '', '', '', 'default', -1);
+ var section_i = add_section_n(cnum, '', '', '', '', {}, '', '', '', 'default', -1);
if (cnum == slate_permutate_course_free)
course_free_check(cnum);
return section_i;
@@ -340,7 +343,7 @@ function course_add_slot_row(course_i, s
jQuery('tr.class' + course_i + ':last').after(
'\n'
);
@@ -385,7 +388,7 @@ function add_class_n(course_id, title)
sectionsOfClass[classNum] = 0; // Initialize at 0
course_ajax_requests[classNum] = false;
- jQuery('#jsrows').append('
| | | |
');
+ jQuery('#jsrows').append('
| | | |
');
/* store classNum as course_i into the
|
: */
var tr_course = jQuery('#tr-course-' + classNum);