From b5bed59e2da3d6aba28e7c5d480398284768c670 Mon Sep 17 00:00:00 2001 From: cinderblockgames <79210192+cinderblockgames@users.noreply.github.com> Date: Thu, 18 Nov 2021 09:46:39 -0500 Subject: [PATCH] Fixing day extension and date string. --- src/components/greeter.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/greeter.tsx b/src/components/greeter.tsx index db30679..feaa250 100644 --- a/src/components/greeter.tsx +++ b/src/components/greeter.tsx @@ -70,11 +70,11 @@ export const getGreeting = (greetings: Array): string => { export const getExtension = (day: number) => { let extension = "th"; - if (day % 10 === 1) { + if (day % 10 === 1 && day !== 11) { extension = "st"; - } else if (day % 10 === 2) { + } else if (day % 10 === 2 && day !== 12) { extension = "nd"; - } else if (day % 10 === 3) { + } else if (day % 10 === 3 && day !== 13) { extension = "rd"; } @@ -93,9 +93,9 @@ export const getDateString = ( ) => { let currentDate = new Date(); - let weekday = weekdays[currentDate.getUTCDay()]; + let weekday = weekdays[currentDate.getDay()]; let day = currentDate.getDate(); - let month = months[currentDate.getUTCMonth()]; + let month = months[currentDate.getMonth()]; let extension = getExtension(day); let year = currentDate.getFullYear();