From 9a76fa76fbf8ac9af76cbf291acf417e043a6b91 Mon Sep 17 00:00:00 2001 From: Steve Bosman Date: Sun, 6 Feb 2022 22:40:07 +0000 Subject: [PATCH] 95 Weekday - move methods into appropriate? scopes or classes --- 95_Weekday/javascript/weekday.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/95_Weekday/javascript/weekday.js b/95_Weekday/javascript/weekday.js index 223e17fe..6070c71c 100644 --- a/95_Weekday/javascript/weekday.js +++ b/95_Weekday/javascript/weekday.js @@ -52,6 +52,8 @@ const MONTHS_PER_YEAR = 12; const DAYS_PER_COMMON_YEAR = 365; const DAYS_PER_IDEALISED_MONTH = 30; const MAXIMUM_DAYS_PER_MONTH = 31; +// In a common (non-leap) year the day of the week for the first of each month moves by the following amounts. +const COMMON_YEAR_MONTH_OFFSET = [0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5]; /** * Date representation. @@ -121,9 +123,6 @@ class DateStruct { * @returns {number} Value between 1 and 7 representing Sunday to Saturday. */ getDayOfWeek() { - // In a common (non-leap) year the day of the week for the first of each month moves by the following amounts. - const COMMON_YEAR_MONTH_OFFSET = [0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5]; - // Calculate an offset based on the century part of the year. const centuriesSince1500 = Math.floor((this.year - 1500) / 100); let centuryOffset = centuriesSince1500 * 5 + (centuriesSince1500 + 3) / 4;