From b05b14591137d6566c162c542f4be1a25ba51463 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 11 Apr 2020 19:16:23 -0400 Subject: [PATCH] [+] Create method to getGradeLevel from graduation year --- src/logic/utils/gpa-utils.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/logic/utils/gpa-utils.ts b/src/logic/utils/gpa-utils.ts index 873014d..b639737 100644 --- a/src/logic/utils/gpa-utils.ts +++ b/src/logic/utils/gpa-utils.ts @@ -186,4 +186,21 @@ export class GPAUtils // Add average to the row return +(score * 100).toFixed(2); } + + /** + * Get grade level from graduation year + * + * @param graduationYear + */ + public static getGradeLevel(graduationYear: number): number + { + // Get current year + let currentYear = new Date().getFullYear(); + + // Convert current year to current school year: +1 if it's after October + if (new Date().getMonth() > 7) currentYear ++; + + // Calculate grade level + return 12 - (graduationYear - currentYear); + } }