properly get date on api requests from frontend

This commit is contained in:
Izalia Mae 2024-06-16 09:08:33 -04:00
parent 058df0ac78
commit cad7f47e7e

View file

@ -57,17 +57,9 @@ body.addEventListener("click", (event) => {
// misc // misc
function get_date_string(date) { function get_date_string(date) {
var year = date.getFullYear().toString(); var year = date.getUTCFullYear().toString();
var month = date.getMonth().toString(); var month = (date.getUTCMonth() + 1).toString().padStart(2, "0");
var day = date.getDay().toString(); var day = date.getUTCDate().toString().padStart(2, "0");
if (month.length === 1) {
month = "0" + month;
}
if (day.length === 1) {
day = "0" + day
}
return `${year}-${month}-${day}`; return `${year}-${month}-${day}`;
} }
@ -127,6 +119,7 @@ async function request(method, path, body = null) {
} else { } else {
if (Object.hasOwn(message, "created")) { if (Object.hasOwn(message, "created")) {
console.log(message.created)
message.created = new Date(message.created); message.created = new Date(message.created);
} }
} }