2023-02-21 22:49:57 +00:00
|
|
|
/**
|
|
|
|
* @description Formats Date to a UTC string accepted by the datetime-local input field.
|
|
|
|
* @param {Date} date
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
export function toISOUTCString(date) {
|
2023-03-02 16:26:44 +00:00
|
|
|
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())
|
|
|
|
}`;
|
2023-02-21 22:49:57 +00:00
|
|
|
}
|