Fix date issues
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
Pierre HUBERT 2024-06-20 22:57:44 +02:00
parent b4a360c492
commit 1305667f24
3 changed files with 14 additions and 7 deletions

View File

@ -252,8 +252,9 @@ export function AccommodationsReservationsRoute(): React.ReactElement {
const u = users?.find((u) => u.user_id === r.user_id);
return {
title: `${u?.user_name} - ${a.name}`,
start: fmtUnixDateFullCalendar(r.reservation_start),
end: fmtUnixDateFullCalendar(r.reservation_end),
start: fmtUnixDateFullCalendar(r.reservation_start, false),
end: fmtUnixDateFullCalendar(r.reservation_end, true),
allDay: true,
color: a.color ? "#" + a.color : undefined,
borderColor:
r.validated === true

View File

@ -8,18 +8,25 @@ export function fmtUnixDate(time: number): string {
/**
* Get formatted UNIX date for Full Calendar
*/
export function fmtUnixDateFullCalendar(time: number): string {
const d = new Date(time * 1000);
export function fmtUnixDateFullCalendar(
time: number,
correctEnd: boolean
): string {
let d = new Date(time * 1000);
if (d.getHours() > 0 && correctEnd)
d = new Date(time * 1000 + 3600 * 24 * 1000);
const s = `${d.getFullYear()}-${(d.getMonth() + 1)
.toString(10)
.padStart(2, "0")}-${d.getDate().toString(10).padStart(2, "0")}T${d
.padStart(2, "0")}-${d.getDate().toString(10).padStart(2, "0")}`; /*T${d
.getHours()
.toString(10)
.padStart(2, "0")}:${d.getMinutes().toString(10).padStart(2, "0")}:${d
.getSeconds()
.toString(10)
.padStart(2, "0")}`;
.padStart(2, "0")}`*/
console.log(s, d);
return s;
}

View File

@ -89,7 +89,6 @@ export function PropDateInput(p: {
v = v.set("minutes", 0);
v = v.set("seconds", 0);
}
console.log(midDay, v, v.get("hours"));
p.onChange(v.unix());
}}