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);
|
||||
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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
}}
|
||||
|
Loading…
Reference in New Issue
Block a user