From 5a3b55dd7c862d6ae66372fd74550901e3a3e898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Rozs=C3=ADval?= Date: Thu, 24 Nov 2022 09:33:22 +0100 Subject: [PATCH] fix: fix final day resolution --- src/constants.ts | 2 +- src/date.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 29d19aa..9e7df5e 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -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; diff --git a/src/date.ts b/src/date.ts index 0ae5014..6b9f23e 100644 --- a/src/date.ts +++ b/src/date.ts @@ -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;