diff options
| -rw-r--r-- | src/helpers/scoreToEmoji.ts | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/helpers/scoreToEmoji.ts b/src/helpers/scoreToEmoji.ts index af19194..c363eea 100644 --- a/src/helpers/scoreToEmoji.ts +++ b/src/helpers/scoreToEmoji.ts @@ -2,10 +2,15 @@ import { GuessType, GuessState } from "../types/guess"; import { appName } from "../constants"; export async function scoreToEmoji(guesses: GuessType[]): Promise<string> { - const msInDay = 86400000; - const todaysDate = new Date(); + const msInDay = 24 * 60 * 60 * 1000; + const today = new Date(); const startDate = new Date(import.meta.env.VITE_START_DATE); - const index = Math.floor((todaysDate.getTime() - startDate.getTime() )/msInDay) + 1 + const index = + Math.floor( + (Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate()) - + Date.UTC(startDate.getUTCFullYear(), startDate.getUTCMonth(), startDate.getUTCDate())) / + msInDay + ) + 1; const emojis = { incorrect: "🟥", partiallyCorrect: "🟨", |
