Revert legacy poll date formatting

This commit is contained in:
Luke Vella 2022-04-12 12:21:25 +01:00
parent a6e39cc2c3
commit e830d0b0f4
2 changed files with 3 additions and 2 deletions

View file

@ -82,7 +82,7 @@ export default async function handler(
const date = legacyPoll.dates[i].toISOString();
newOptions.push({
id: await nanoid(),
value: date.substring(0, date.indexOf("T")), // remove time
value: date,
});
}

View file

@ -63,7 +63,8 @@ export const decodeDateOption = (
}
// we add the time because otherwise Date will assume UTC time which might change the day for some time zones
const date = new Date(option + "T00:00:00");
const dateString = option.indexOf("T") === -1 ? option + "T00:00:00" : option;
const date = new Date(dateString);
return {
type: "date",
day: format(date, "dd"),