From cf1c57556e2857c703faf323402147847df4d0d0 Mon Sep 17 00:00:00 2001 From: EpicGazel Date: Tue, 24 Sep 2024 13:26:54 -0400 Subject: [PATCH] InsertTimestamps.plugin.js: Set current datetime as default value Updated to have the default value set upon opening as the current time and date. --- Plugins/InsertTimestamps/InsertTimestamps.plugin.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/InsertTimestamps/InsertTimestamps.plugin.js b/Plugins/InsertTimestamps/InsertTimestamps.plugin.js index 53f8a23..a787d23 100644 --- a/Plugins/InsertTimestamps/InsertTimestamps.plugin.js +++ b/Plugins/InsertTimestamps/InsertTimestamps.plugin.js @@ -33,7 +33,8 @@ var ButtonClasses = BdApi.Webpack.getByKeys("emojiButton", "stickerButton"); var cl = (...names) => names.map((n) => `vbd-its-${n}`).join(" "); var Formats = ["", "t", "T", "d", "D", "f", "F", "R"]; function PickerModal({ rootProps }) { - const [value, setValue] = useState(); + //Credit: https://stackoverflow.com/a/62845336 for time conversion + const [value, setValue] = useState(() => new Date(Date.now() - new Date().getTimezoneOffset() * 60000).toISOString().slice(0, 16)); const [format, setFormat] = useState(""); const time = Math.round((new Date(value).getTime() || Date.now()) / 1e3); const formatTimestamp = (time2, format2) => ``;