input datetime-local needs day to also be two digits
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Lukáš Kucharczyk 2023-03-02 17:26:44 +01:00
parent 29c41865d0
commit e1655d6cfa
1 changed files with 9 additions and 2 deletions

View File

@ -4,6 +4,13 @@
* @returns {string} * @returns {string}
*/ */
export function toISOUTCString(date) { export function toISOUTCString(date) {
let month = (date.getMonth() + 1).toString().padStart(2, 0); function stringAndPad(number) {
return `${date.getFullYear()}-${month}-${date.getDate()}T${date.getHours()}:${date.getMinutes()}`; return number.toString().padStart(2, 0);
}
const year = date.getFullYear();
const month = stringAndPad(date.getMonth() + 1);
const day = stringAndPad(date.getDate());
const hours = stringAndPad(date.getHours());
const minutes = stringAndPad(date.getMinutes());
return `${year}-${month}-${day}T${hours}:${minutes}`;
} }