Skip to content

Commit 3b18367

Browse files
Merge pull request #125 from MITLibraries/lm451
Tweak hours loader to handle dates outside defined terms/semesters
2 parents 6448018 + 6e6ad94 commit 3b18367

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

web/app/plugins/mitlib-pull-hours/js/hours-loader.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,20 @@ var HoursLoader = {
207207
// For each date in the week...
208208
_.each(testweek, function(dayofweek) {
209209
testday = new Date(dayofweek);
210-
rebuildsemester = [];
210+
// Define default vales, in case testday is beyond the range of defined semesters.
211+
// Ideally these would be calculated from the Default Hours sheet.
212+
semester_cache = 'Default-Hours.json';
213+
testday.semestername = "Default Hours";
214+
testday.start = '1/1/1970';
215+
testday.end = '12/31/2100';
216+
rebuildsemester = [
217+
'Default Hours',
218+
'1/1/1970',
219+
'12/31/2100',
220+
'Default-Hours.json'
221+
];
211222
// Cycle through each term, determining which it belongs to.
212-
// (This is inefficient, I know...)
223+
// (This is inefficient, I know... - could be _.every() with a break or return?)
213224
_.each(testsemesters, function(semester) {
214225
semester_start = new Date(semester[1]);
215226
semester_end = new Date(semester[2]);

0 commit comments

Comments
 (0)