Skip to content

Commit

Permalink
fix: fix final day resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
rozsival committed Nov 24, 2022
1 parent 86859b1 commit 5a3b55d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export const JANUARY = 1;
export const LAST_NOTIFICATION_DAYS = 1;
export const SATURDAY = 6;
export const SATURDAY_DIFF = 1;
export const SUNDAY = 1;
export const SUNDAY = 0;
export const SUNDAY_DIFF = 2;
4 changes: 1 addition & 3 deletions src/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ import { CLOSURE_DAY } from './environment';

export const now = () => new Date();

export const formatDay = (date: Date) => date.getDay() + 1;

export const formatMonth = (date: Date) => date.getMonth() + 1;

export const getFinalDay = () => {
const date = now();
date.setDate(CLOSURE_DAY);
const day = formatDay(date);
const day = date.getDay();
const final = date.getDate();
if (day === SATURDAY) return final - SATURDAY_DIFF;
if (day === SUNDAY) return final - SUNDAY_DIFF;
Expand Down

0 comments on commit 5a3b55d

Please sign in to comment.