From 443e54076273748da26d180b64e4e39ebf3df255 Mon Sep 17 00:00:00 2001 From: Ryan Morash Date: Tue, 5 Aug 2025 00:11:57 +0000 Subject: [PATCH 1/4] Use UTC time for date handling to ensure consistency across time zones --- script.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/script.js b/script.js index dfb4a19..d65d292 100644 --- a/script.js +++ b/script.js @@ -13,7 +13,7 @@ var firstGame = true; var expiredSession = false; const allowExpiration = false; // Wordle doesn't have expiration, but I may want to implement this eventually, who knows -const firstgameMilli = new Date(2022, 8, 4, 0, 0, 0, 0).getTime(); +const firstgameMilli = new Date(Date.UTC(2022, 8, 4, 0, 0, 0, 0)).getTime(); const dayLength = 1000*60*60*24; var gameNumber; @@ -53,10 +53,11 @@ initializeGame(); function getGameNumber() { let curdate = new Date(); - curdate.setMilliseconds(0); - curdate.setSeconds(0); - curdate.setMinutes(0); - curdate.setHours(0); + // Use UTC/GMT time instead of local time + curdate.setUTCMilliseconds(0); + curdate.setUTCSeconds(0); + curdate.setUTCMinutes(0); + curdate.setUTCHours(0); let curdateMilli = curdate.getTime(); let dif = curdateMilli - firstgameMilli; @@ -70,10 +71,11 @@ function getGameNumber() { } function getAbsoluteDate(date) { - date.setMilliseconds(0); - date.setSeconds(0); - date.setMinutes(0); - date.setHours(0); + // Use UTC/GMT time instead of local time + date.setUTCMilliseconds(0); + date.setUTCSeconds(0); + date.setUTCMinutes(0); + date.setUTCHours(0); } function addZeros(num, digits = 2) { @@ -178,7 +180,7 @@ function initializeGame() { // The first game will last ~48 hours } - gameTimerNext.setDate(gameTimerNext.getDate() + 1); + gameTimerNext.setUTCDate(gameTimerNext.getUTCDate() + 1); updateMobileHeight(); } @@ -482,7 +484,9 @@ function getWordOfTheDay(seed) { // Practice mode if (seed === undefined) { let curDate = new Date(); - let func = mulberry32(curDate.getTime()); + // Use UTC time for consistency + let utcDate = new Date(curDate.getUTCFullYear(), curDate.getUTCMonth(), curDate.getUTCDate()); + let func = mulberry32(utcDate.getTime()); let num = Math.floor(func() * wordList.length); return wordList[num]; From 542fa6845574cfc73c59c22c49f0217119b949b2 Mon Sep 17 00:00:00 2001 From: Ryan Morash Date: Tue, 5 Aug 2025 00:19:19 +0000 Subject: [PATCH 2/4] Use UTC time for date handling in getWordOfTheDay function for consistency --- script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.js b/script.js index d65d292..78e255f 100644 --- a/script.js +++ b/script.js @@ -485,7 +485,7 @@ function getWordOfTheDay(seed) { if (seed === undefined) { let curDate = new Date(); // Use UTC time for consistency - let utcDate = new Date(curDate.getUTCFullYear(), curDate.getUTCMonth(), curDate.getUTCDate()); + let utcDate = new Date(Date.UTC(curDate.getUTCFullYear(), curDate.getUTCMonth(), curDate.getUTCDate())); let func = mulberry32(utcDate.getTime()); let num = Math.floor(func() * wordList.length); From 38d261e25fe86cf11707e875311af000285f7099 Mon Sep 17 00:00:00 2001 From: Ryan Morash Date: Tue, 5 Aug 2025 00:11:57 +0000 Subject: [PATCH 3/4] Revert "Use UTC time for date handling in getWordOfTheDay function for consistency" This reverts commit 542fa6845574cfc73c59c22c49f0217119b949b2. --- script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.js b/script.js index 78e255f..d65d292 100644 --- a/script.js +++ b/script.js @@ -485,7 +485,7 @@ function getWordOfTheDay(seed) { if (seed === undefined) { let curDate = new Date(); // Use UTC time for consistency - let utcDate = new Date(Date.UTC(curDate.getUTCFullYear(), curDate.getUTCMonth(), curDate.getUTCDate())); + let utcDate = new Date(curDate.getUTCFullYear(), curDate.getUTCMonth(), curDate.getUTCDate()); let func = mulberry32(utcDate.getTime()); let num = Math.floor(func() * wordList.length); From 2725cafe37f393d07cfe6640132f0a2c5c8e9e80 Mon Sep 17 00:00:00 2001 From: Ryan Morash Date: Tue, 5 Aug 2025 00:53:21 +0000 Subject: [PATCH 4/4] Fix Copilot review suggestions --- script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index d65d292..c5f211e 100644 --- a/script.js +++ b/script.js @@ -13,7 +13,7 @@ var firstGame = true; var expiredSession = false; const allowExpiration = false; // Wordle doesn't have expiration, but I may want to implement this eventually, who knows -const firstgameMilli = new Date(Date.UTC(2022, 8, 4, 0, 0, 0, 0)).getTime(); +const firstgameMilli = Date.UTC(2022, 8, 4, 0, 0, 0, 0); const dayLength = 1000*60*60*24; var gameNumber; @@ -485,7 +485,7 @@ function getWordOfTheDay(seed) { if (seed === undefined) { let curDate = new Date(); // Use UTC time for consistency - let utcDate = new Date(curDate.getUTCFullYear(), curDate.getUTCMonth(), curDate.getUTCDate()); + let utcDate = new Date(Date.UTC(curDate.getUTCFullYear(), curDate.getUTCMonth(), curDate.getUTCDate())); let func = mulberry32(utcDate.getTime()); let num = Math.floor(func() * wordList.length);