Skip to content

Commit

Permalink
fix: resolved #5 and #6
Browse files Browse the repository at this point in the history
  • Loading branch information
r1zyn committed Jul 26, 2022
1 parent 64fe106 commit 3ee165a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/utils/closestFriday.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,20 @@ export default function closestFriday(fromDate: Date): Date {
}

/**
* Function that gets the difference between two days.
* Function that gets the difference between two days.
* @param {number} start The starting day
* @param {number} end The ending day
* @returns {number}
*/
export function getDifferenceBetweenDays(
start: number,
end: number
): number {
export function getDifferenceBetweenDays(start: number, end: number): number {
/**
* The weekend days for Date.getDay().
* @type {number[]}
*/
const weekends: number[] = [0, 6];

if (weekends.includes(end)) { // Checks if the day is a weekend, as if the first day of the Tangaroa period is a weekend, Matariki will be the Friday before, and vice-versa
if (weekends.includes(end)) {
// Checks if the day is a weekend, as if the first day of the Tangaroa period is a weekend, Matariki will be the Friday before, and vice-versa
if (end === 0) {
end = 7; // Change Sunday to index of 7 so we can get the day difference
}
Expand Down

0 comments on commit 3ee165a

Please sign in to comment.