-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added aws-lti-middleware directory containing code for AWS LTI middle…
…ware
- Loading branch information
Showing
5,800 changed files
with
1,066,289 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const { SESSION_SYSTEM } = require('@common/global-config') | ||
|
||
const calculateSemester = (ms) => { | ||
const date = new Date(ms) | ||
const semesters = [ | ||
{ | ||
name: "Fall", | ||
start: 70, | ||
end: 100 | ||
}, | ||
{ | ||
name: "Spring", | ||
start: 0, | ||
end: 45 | ||
}, | ||
{ | ||
name: "Summer", | ||
start: 45, | ||
end: 70 | ||
} | ||
] | ||
const quarters = [ | ||
{ | ||
name: "Fall", | ||
start: 75, | ||
end: 100 | ||
}, | ||
{ | ||
name: "Winter", | ||
start: 0, | ||
end: 30 | ||
}, | ||
{ | ||
name: "Spring", | ||
start: 30, | ||
end: 55 | ||
}, | ||
{ | ||
name: "Summer", | ||
start: 55, | ||
end: 75 | ||
} | ||
] | ||
|
||
const currentYear = date.getUTCFullYear() | ||
const nextYear = date.getUTCFullYear() + 1 | ||
|
||
const _baseline = new Date(0) | ||
_baseline.setUTCFullYear(currentYear) | ||
const baseline = _baseline.getTime() | ||
|
||
const _eoy = new Date(0) | ||
_eoy.setUTCFullYear(nextYear) | ||
const eoy = _eoy.getTime() | ||
|
||
const progress = (ms - baseline) / (eoy - baseline) * 100 | ||
|
||
const session = (SESSION_SYSTEM === "SEMESTER" ? semesters : quarters) | ||
.find(({ start, end }) => progress >= start && progress < end); | ||
|
||
return `${session.name} ${currentYear}` | ||
} | ||
|
||
module.exports = { | ||
calculateSemester | ||
} |
Oops, something went wrong.