From 67114c714ee0289d9575075588f511f2ebabccc4 Mon Sep 17 00:00:00 2001 From: shamoni <––github.ovdwz@slmail.me> Date: Fri, 13 Oct 2023 08:33:28 +0200 Subject: [PATCH 1/3] changed time zone to the device's set time zone --- zpordle.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/zpordle.js b/zpordle.js index 5f1595f..86029be 100644 --- a/zpordle.js +++ b/zpordle.js @@ -274,13 +274,24 @@ var EMOJI_TABLE = { } var SHARE_BUTTON = ""; -// always use pacific time +// get current date and time in user's local time zone var d = new Date(); -var pstDate = d.toLocaleString("en-us", { - timeZone: "America/Los_Angeles" -}); -var nd = new Date(pstDate); -var today = nd.getFullYear() + '/' + (nd.getMonth() + 1) + '/' + nd.getDate(); +var userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; +var userLocalDate = d.toLocaleString("en-us", { timeZone: userTimeZone }); + +// parse the user's local date string to create a Date object +var nd = new Date(userLocalDate); + +// extract the year, month, and day from the Date object +var year = nd.getFullYear(); +var month = nd.getMonth() + 1; // months are zero-based +var day = nd.getDate(); + +// format the date string with the user's local date +var formattedDate = year + '/' + month + '/' + day; + +console.log("User's local date: " + formattedDate); + // using https://github.com/davidbau/seedrandom Math.seedrandom(today); From 608b1109726b7c2133e2ec6a8d42d2f9275b2ecc Mon Sep 17 00:00:00 2001 From: saucecoat <43880196+saucecoat@users.noreply.github.com> Date: Fri, 13 Oct 2023 06:47:02 +0000 Subject: [PATCH 2/3] fixed variable name --- zpordle.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/zpordle.js b/zpordle.js index 86029be..a6d917e 100644 --- a/zpordle.js +++ b/zpordle.js @@ -288,10 +288,7 @@ var month = nd.getMonth() + 1; // months are zero-based var day = nd.getDate(); // format the date string with the user's local date -var formattedDate = year + '/' + month + '/' + day; - -console.log("User's local date: " + formattedDate); - +var today = year + '/' + month + '/' + day; // using https://github.com/davidbau/seedrandom Math.seedrandom(today); From c45dde4dd9d7232c18949926e0bb9f8bf8d93a3d Mon Sep 17 00:00:00 2001 From: saucecoat <43880196+saucecoat@users.noreply.github.com> Date: Fri, 13 Oct 2023 08:12:12 +0000 Subject: [PATCH 3/3] shortened changes --- zpordle.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/zpordle.js b/zpordle.js index a6d917e..126ece8 100644 --- a/zpordle.js +++ b/zpordle.js @@ -279,16 +279,9 @@ var d = new Date(); var userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; var userLocalDate = d.toLocaleString("en-us", { timeZone: userTimeZone }); -// parse the user's local date string to create a Date object var nd = new Date(userLocalDate); -// extract the year, month, and day from the Date object -var year = nd.getFullYear(); -var month = nd.getMonth() + 1; // months are zero-based -var day = nd.getDate(); - -// format the date string with the user's local date -var today = year + '/' + month + '/' + day; +var today = nd.getFullYear() + '/' + (nd.getMonth() + 1) + '/' + nd.getDate(); // using https://github.com/davidbau/seedrandom Math.seedrandom(today);