From 3e37ab15fceac06666f7df38f717be5eedc378e6 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Dec 2019 13:47:35 -0500 Subject: [PATCH] [+] Encapsulate getTerm(date) --- src/constants.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/constants.ts b/src/constants.ts index bf984fe..26b5b94 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -68,4 +68,14 @@ export default class Constants new Date('Jun 05 2020'), ]; public static CURRENT_TERM = findLastIndex(Constants.TERMS, d => d < new Date()); + + /** + * Find out the specified date is in which term + * + * @param date + */ + static getTerm(date: Date) + { + return findLastIndex(Constants.TERMS, d => d <= date); + } }