Fix date issues
This commit is contained in:
parent
b4a360c492
commit
1305667f24
@ -252,8 +252,9 @@ export function AccommodationsReservationsRoute(): React.ReactElement {
|
|||||||
const u = users?.find((u) => u.user_id === r.user_id);
|
const u = users?.find((u) => u.user_id === r.user_id);
|
||||||
return {
|
return {
|
||||||
title: `${u?.user_name} - ${a.name}`,
|
title: `${u?.user_name} - ${a.name}`,
|
||||||
start: fmtUnixDateFullCalendar(r.reservation_start),
|
start: fmtUnixDateFullCalendar(r.reservation_start, false),
|
||||||
end: fmtUnixDateFullCalendar(r.reservation_end),
|
end: fmtUnixDateFullCalendar(r.reservation_end, true),
|
||||||
|
allDay: true,
|
||||||
color: a.color ? "#" + a.color : undefined,
|
color: a.color ? "#" + a.color : undefined,
|
||||||
borderColor:
|
borderColor:
|
||||||
r.validated === true
|
r.validated === true
|
||||||
|
@ -8,18 +8,25 @@ export function fmtUnixDate(time: number): string {
|
|||||||
/**
|
/**
|
||||||
* Get formatted UNIX date for Full Calendar
|
* Get formatted UNIX date for Full Calendar
|
||||||
*/
|
*/
|
||||||
export function fmtUnixDateFullCalendar(time: number): string {
|
export function fmtUnixDateFullCalendar(
|
||||||
const d = new Date(time * 1000);
|
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)
|
const s = `${d.getFullYear()}-${(d.getMonth() + 1)
|
||||||
.toString(10)
|
.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()
|
.getHours()
|
||||||
.toString(10)
|
.toString(10)
|
||||||
.padStart(2, "0")}:${d.getMinutes().toString(10).padStart(2, "0")}:${d
|
.padStart(2, "0")}:${d.getMinutes().toString(10).padStart(2, "0")}:${d
|
||||||
.getSeconds()
|
.getSeconds()
|
||||||
.toString(10)
|
.toString(10)
|
||||||
.padStart(2, "0")}`;
|
.padStart(2, "0")}`*/
|
||||||
|
|
||||||
|
console.log(s, d);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,6 @@ export function PropDateInput(p: {
|
|||||||
v = v.set("minutes", 0);
|
v = v.set("minutes", 0);
|
||||||
v = v.set("seconds", 0);
|
v = v.set("seconds", 0);
|
||||||
}
|
}
|
||||||
console.log(midDay, v, v.get("hours"));
|
|
||||||
|
|
||||||
p.onChange(v.unix());
|
p.onChange(v.unix());
|
||||||
}}
|
}}
|
||||||
|
Loading…
Reference in New Issue
Block a user