[#632] fix to adapt headers to proper selected timezone (#674)

Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
Camille Moussu
2026-03-20 09:27:54 +01:00
committed by GitHub
parent 1079405ae8
commit 2ba92ed194
3 changed files with 120 additions and 6 deletions
+13 -6
View File
@@ -22,6 +22,7 @@ import FullCalendar from "@fullcalendar/react";
import timeGridPlugin from "@fullcalendar/timegrid";
import { Box, Button, radius } from "@linagora/twake-mui";
import AddIcon from "@mui/icons-material/Add";
import moment from "moment-timezone";
import { MutableRefObject, useEffect, useMemo, useRef, useState } from "react";
import { useI18n } from "twake-i18n";
import { useCalendarDataLoader } from "../../features/Calendars/useCalendarLoader";
@@ -467,6 +468,7 @@ export default function CalendarApp({
dayCellContent={(arg) => {
const month = arg.date.toLocaleDateString(t("locale"), {
month: "short",
timeZone: timezone,
});
if (arg.view.type === "dayGridMonth") {
return (
@@ -523,18 +525,23 @@ export default function CalendarApp({
}, 100);
}}
dayHeaderContent={(arg) => {
const date = arg.date.getDate();
const weekDay = arg.date
.toLocaleDateString(t("locale"), { weekday: "short" })
const m = moment.tz(arg.date, timezone);
const date = m.date();
const weekDay = m
.toDate()
.toLocaleDateString(t("locale"), {
weekday: "short",
timeZone: timezone,
})
.toUpperCase();
return (
<div className="fc-daygrid-day-top">
<small>{weekDay}</small>
{arg.view.type !== "dayGridMonth" && (
<span
className={`fc-daygrid-day-number ${
arg.isToday ? "current-date" : ""
}`}
className={`fc-daygrid-day-number ${arg.isToday ? "current-date" : ""}`}
>
{date}
</span>
@@ -72,6 +72,7 @@ export function TimezoneAutocomplete({
<TextField
{...params}
placeholder={placeholder}
onFocus={(e) => e.target.select()}
variant="outlined"
autoComplete="off"
inputRef={inputRef}