From 4ea6466f1ef3f55350f9a2b4b575b147f1134143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Thu, 2 Mar 2023 17:26:44 +0100 Subject: [PATCH] input datetime-local needs day to also be two digits --- games/static/js/utils.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/games/static/js/utils.js b/games/static/js/utils.js index 988e0a7..19cadd1 100644 --- a/games/static/js/utils.js +++ b/games/static/js/utils.js @@ -4,6 +4,14 @@ * @returns {string} */ export function toISOUTCString(date) { - let month = (date.getMonth() + 1).toString().padStart(2, 0); - return `${date.getFullYear()}-${month}-${date.getDate()}T${date.getHours()}:${date.getMinutes()}`; + function stringAndPad(number) { + return number.toString().padStart(2, 0); + } + return `${ + date.getFullYear()}- + ${stringAndPad(date.getMonth() + 1)}- + ${stringAndPad(date.getDate())}T + ${stringAndPad(date.getHours())}: + ${stringAndPad(date.getMinutes()) + }`; }