feat(calendar): implement local date string formatting for event filtering
All checks were successful
Build & Push Docker Image / build (push) Successful in 6m27s
All checks were successful
Build & Push Docker Image / build (push) Successful in 6m27s
This commit is contained in:
@@ -111,10 +111,10 @@ export default function Calendar() {
|
|||||||
}, [currentDate]);
|
}, [currentDate]);
|
||||||
|
|
||||||
const eventsForDay = (day) => {
|
const eventsForDay = (day) => {
|
||||||
const dayStr = day.toISOString().split('T')[0];
|
const dayStr = toLocalDateStr(day);
|
||||||
return events.filter(ev => {
|
return events.filter(ev => {
|
||||||
const start = ev.start_time.split('T')[0];
|
const start = toLocalDateStr(new Date(ev.start_time));
|
||||||
const end = ev.end_time.split('T')[0];
|
const end = toLocalDateStr(new Date(ev.end_time));
|
||||||
return dayStr >= start && dayStr <= end;
|
return dayStr >= start && dayStr <= end;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -826,6 +826,13 @@ export default function Calendar() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
|
function toLocalDateStr(date) {
|
||||||
|
const y = date.getFullYear();
|
||||||
|
const m = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
const d = String(date.getDate()).padStart(2, '0');
|
||||||
|
return `${y}-${m}-${d}`;
|
||||||
|
}
|
||||||
|
|
||||||
function toLocalDateTimeStr(date) {
|
function toLocalDateTimeStr(date) {
|
||||||
const y = date.getFullYear();
|
const y = date.getFullYear();
|
||||||
const m = String(date.getMonth() + 1).padStart(2, '0');
|
const m = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
|||||||
Reference in New Issue
Block a user