New event dates fix able to submit without one

This commit is contained in:
Kalle
2022-08-07 13:25:49 +03:00
parent 53fa0147c7
commit 6a6f8a19e8
4 changed files with 72 additions and 98 deletions

View File

@@ -34,7 +34,19 @@ export function weekNumberToDate({
return result;
}
/** Returns date as a string with the format YYYY-MM-DDThh:mm */
/** Returns date as a string with the format YYYY-MM-DDThh:mm in user's time zone */
export function dateToYearMonthDayHourMinuteString(date: Date) {
return date.toISOString().slice(0, 16);
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
const hour = date.getHours();
const minute = date.getMinutes();
return `${year}-${prefixZero(month)}-${prefixZero(day)}T${prefixZero(
hour
)}:${prefixZero(minute)}`;
}
function prefixZero(number: number) {
return number < 10 ? `0${number}` : number;
}