From 0b7d469e0e88a2b8ecf0173b948c288e95ca0af3 Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Mon, 28 Oct 2024 11:55:13 -0700 Subject: [PATCH] feature/IO-2979-DST - Finish DST Signed-off-by: Dave Richer --- .../components/schedule-calendar-wrapper/localizer.js | 11 ++++++++--- .../scheduler-calendar-wrapper.component.jsx | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/client/src/components/schedule-calendar-wrapper/localizer.js b/client/src/components/schedule-calendar-wrapper/localizer.js index e91016416..871511ce2 100644 --- a/client/src/components/schedule-calendar-wrapper/localizer.js +++ b/client/src/components/schedule-calendar-wrapper/localizer.js @@ -119,7 +119,7 @@ var formats = { agendaTimeRangeFormat: timeRangeFormat }; -const localizer = (dayjsLib) => { +const localizer = (dayjsLib, timezone) => { // load dayjs plugins dayjsLib.extend(isBetween); dayjsLib.extend(isSameOrAfter); @@ -128,6 +128,10 @@ const localizer = (dayjsLib) => { dayjsLib.extend(localizedFormat); dayjsLib.extend(minMax); dayjsLib.extend(utc); + + dayjsLib.locale("en"); + dayjsLib.tz.setDefault(timezone); + var locale = function locale(dj, c) { return c ? dj.locale(c) : dj; }; @@ -136,8 +140,9 @@ const localizer = (dayjsLib) => { // then use the timezone aware version //TODO This was the issue entirely... - // var dayjs = dayjsLib.tz ? dayjsLib.tz : dayjsLib; - var dayjs = dayjsLib; + var dayjs = dayjsLib.tz ? dayjsLib.tz : dayjsLib; + + // var dayjs = dayjsLib; function getTimezoneOffset(date) { // ensures this gets cast to timezone diff --git a/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx b/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx index fb866d89d..1d9e14eb9 100644 --- a/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx +++ b/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx @@ -1,7 +1,7 @@ import dayjs from "../../utils/day"; import queryString from "query-string"; import React from "react"; -import { Calendar } from "react-big-calendar"; +import { Calendar, dayjsLocalizer } from "react-big-calendar"; import { connect } from "react-redux"; import { Link, useLocation, useNavigate } from "react-router-dom"; import { createStructuredSelector } from "reselect"; @@ -14,13 +14,13 @@ import { selectProblemJobs } from "../../redux/application/application.selectors import { Alert, Collapse, Space } from "antd"; import { Trans, useTranslation } from "react-i18next"; import InstanceRenderManager from "../../utils/instanceRenderMgr"; -import local from "./localizer"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, problemJobs: selectProblemJobs }); -const localizer = local(dayjs); + +const localizer = dayjsLocalizer(dayjs); export function ScheduleCalendarWrapperComponent({ bodyshop,