π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
[WEB-761] fix: Time zone date misalignment (#3986)
rahulramesha1a462711e118
diff --git a/packages/editor/document-editor/src/ui/components/editor-header.tsx b/packages/editor/document-editor/src/ui/components/editor-header.tsxindex a322ddddc5..aaa4c7be33 100644--- a/packages/editor/document-editor/src/ui/components/editor-header.tsx+++ b/packages/editor/document-editor/src/ui/components/editor-header.tsx@@ -72,7 +72,7 @@ export const EditorHeader = (props: IEditorHeader) => {Icon={Archive}backgroundColor="bg-blue-500/20"textColor="text-blue-500"- label={`Archived at ${new Date(archivedAt).toLocaleString()}`}+ label={`Archived at ${archivedAt.toLocaleString()}`}/>)}diff --git a/packages/editor/document-editor/src/ui/components/info-popover.tsx b/packages/editor/document-editor/src/ui/components/info-popover.tsxindex f78dd34737..9a17a93767 100644--- a/packages/editor/document-editor/src/ui/components/info-popover.tsx+++ b/packages/editor/document-editor/src/ui/components/info-popover.tsx@@ -52,14 +52,14 @@ export const InfoPopover: React.FC<Props> = (props) => {<h6 className="text-xs text-custom-text-400">Last updated on</h6><h5 className="flex items-center gap-1 text-sm"><History className="h-3 w-3" />- {renderDate(new Date(documentDetails.last_updated_at))}+ {renderDate(documentDetails.last_updated_at)}</h5></div><div className="space-y-1.5"><h6 className="text-xs text-custom-text-400">Created on</h6><h5 className="flex items-center gap-1 text-sm"><Calendar className="h-3 w-3" />- {renderDate(new Date(documentDetails.created_on))}+ {renderDate(documentDetails.created_on)}</h5></div></div>diff --git a/web/components/core/filters/date-filter-modal.tsx b/web/components/core/filters/date-filter-modal.tsxindex c5238ec1c8..3e2f3ff6ad 100644--- a/web/components/core/filters/date-filter-modal.tsx+++ b/web/components/core/filters/date-filter-modal.tsx@@ -8,7 +8,7 @@ import { DateFilterSelect } from "./date-filter-select";// uiimport { Button } from "@plane/ui";// helpers-import { renderFormattedPayloadDate, renderFormattedDate } from "helpers/date-time.helper";+import { renderFormattedPayloadDate, renderFormattedDate, getDate } from "helpers/date-time.helper";type Props = {title: string;@@ -43,7 +43,10 @@ export const DateFilterModal: React.FC<Props> = ({ title, handleClose, isOpen, ohandleClose();};- const isInvalid = watch("filterType") === "range" ? new Date(watch("date1")) > new Date(watch("date2")) : false;+ const date1 = getDate(watch("date1"));+ const date2 = getDate(watch("date1"));++ const isInvalid = watch("filterType") === "range" && date1 && date2 ? date1 > date2 : false;return (<Transition.Root show={isOpen} as={Fragment}>@@ -86,35 +89,45 @@ export const DateFilterModal: React.FC<Props> = ({ title, handleClose, isOpen, o<Controllercontrol={control}name="date1"- render={({ field: { value, onChange } }) => (- <DayPicker- selected={value ? new Date(value) : undefined}- defaultMonth={value ? new Date(value) : undefined}- onSelect={(date) => onChange(date)}- mode="single"- disabled={[- { after: new Date(watch("date2")) }- ]}- className="border border-custom-border-200 p-3 rounded-md"- />- )}+ render={({ field: { value, onChange } }) => {+ const dateValue = getDate(value);+ const date2Value = getDate(watch("date2"));+ return (+ <DayPicker+ selected={dateValue}+ defaultMonth={dateValue}+ onSelect={(date) => {+ if (!date) return;+ onChange(date);+ }}+ mode="single"+ disabled={date2Value ? [{ after: date2Value }] : undefined}+ className="border border-custom-border-200 p-3 rounded-md"+ />+ );+ }}/>{watch("filterType") === "range" && (<Controllercontrol={control}name="date2"- render={({ field: { value, onChange } }) => (- <DayPicker- selected={value ? new Date(value) : undefined}- defaultMonth={value ? new Date(value) : undefined}- onSelect={(date) => onChange(date)}- mode="single"- disabled={[- { before: new Date(watch("date1")) }- ]}- className="border border-custom-border-200 p-3 rounded-md"- />- )}+ render={({ field: { value, onChange } }) => {+ const dateValue = getDate(value);+ const date1Value = getDate(watch("date1"));+ return (+ <DayPicker+ selected={dateValue}+ defaultMonth={dateValue}+ onSelect={(date) => {+ if (!date) return;+ onChange(date);+ }}+ mode="single"+ disabled={date1Value ? [{ before: date1Value }] : undefined}+ className="border border-custom-border-200 p-3 rounded-md"+ />+ );+ }}/>)}</div>diff --git a/web/components/core/sidebar/progress-chart.tsx b/web/components/core/sidebar/progress-chart.tsxindex ca21756fc3..b0ff4ba738 100644--- a/web/components/core/sidebar/progress-chart.tsx+++ b/web/components/core/sidebar/progress-chart.tsx@@ -3,7 +3,7 @@ import { eachDayOfInterval, isValid } from "date-fns";// uiimport { LineGraph } from "components/ui";// helpers-import { renderFormattedDateWithoutYear } from "helpers/date-time.helper";+import { getDate, renderFormattedDateWithoutYear } from "helpers/date-time.helper";//typesimport { TCompletionChartDistribution } from "@plane/types";@@ -47,11 +47,11 @@ const ProgressChart: React.FC<Props> = ({ distribution, startDate, endDate, tota}));const generateXAxisTickValues = () => {- const start = new Date(startDate);- const end = new Date(endDate);+ const start = getDate(startDate);+ const end = getDate(endDate);let dates: Date[] = [];- if (isValid(start) && isValid(end)) {+ if (start && end && isValid(start) && isValid(end)) {dates = eachDayOfInterval({ start, end });}diff --git a/web/components/cycles/active-cycle-details.tsx b/web/components/cycles/active-cycle-details.tsxindex 425ce7df3f..b5d6523ed5 100644--- a/web/components/cycles/active-cycle-details.tsx+++ b/web/components/cycles/active-cycle-details.tsx@@ -27,7 +27,12 @@ import { EmptyState, getEmptyStateImagePath } from "components/empty-state";// iconsimport { ArrowRight, CalendarCheck, CalendarDays, Star, Target } from "lucide-react";// helpers-import { renderFormattedDate, findHowManyDaysLeft, renderFormattedDateWithoutYear } from "helpers/date-time.helper";+import {+ renderFormattedDate,+ findHowManyDaysLeft,+ renderFormattedDateWithoutYear,+ getDate,+} from "helpers/date-time.helper";import { truncateText } from "helpers/string.helper";// typesimport { ICycle, TCycleGroups } from "@plane/types";@@ -102,8 +107,10 @@ export const ActiveCycleDetails: React.FC<IActiveCycleDetails> = observer((props/>);- const endDate = new Date(activeCycle.end_date ?? "");- const startDate = new Date(activeCycle.start_date ?? "");+ const endDate = getDate(activeCycle.end_date);+ const startDate = getDate(activeCycle.start_date);+ const daysLeft = findHowManyDaysLeft(activeCycle.end_date) ?? 0;+ const cycleStatus = activeCycle.status.toLowerCase() as TCycleGroups;const groupedIssues: any = {backlog: activeCycle.backlog_issues,@@ -113,8 +120,6 @@ export const ActiveCycleDetails: React.FC<IActiveCycleDetails> = observer((propscancelled: activeCycle.cancelled_issues,};- const cycleStatus = activeCycle.status.toLowerCase() as TCycleGroups;-const handleAddToFavorites = (e: MouseEvent<HTMLButtonElement>) => {e.preventDefault();if (!workspaceSlug || !projectId) return;@@ -151,8 +156,6 @@ export const ActiveCycleDetails: React.FC<IActiveCycleDetails> = observer((propscolor: group.color,}));- const daysLeft = findHowManyDaysLeft(activeCycle.end_date) ?? 0;-return (<div className="grid-row-2 grid divide-y rounded-[10px] border border-custom-border-200 bg-custom-background-100 shadow"><div className="grid grid-cols-1 divide-y border-custom-border-200 lg:grid-cols-3 lg:divide-x lg:divide-y-0">diff --git a/web/components/cycles/cycles-board-card.tsx b/web/components/cycles/cycles-board-card.tsxindex 7d6b1e0003..2b3e4bdc83 100644--- a/web/components/cycles/cycles-board-card.tsx+++ b/web/components/cycles/cycles-board-card.tsx@@ -12,7 +12,7 @@ import { Avatar, AvatarGroup, CustomMenu, Tooltip, LayersIcon, CycleGroupIcon }// iconsimport { Info, LinkIcon, Pencil, Star, Trash2 } from "lucide-react";// helpers-import { findHowManyDaysLeft, renderFormattedDate } from "helpers/date-time.helper";+import { findHowManyDaysLeft, getDate, renderFormattedDate } from "helpers/date-time.helper";import { copyTextToClipboard } from "helpers/string.helper";// constantsimport { CYCLE_STATUS } from "constants/cycle";@@ -50,8 +50,8 @@ export const CyclesBoardCard: FC<ICyclesBoardCard> = observer((props) => {const cycleStatus = cycleDetails.status.toLocaleLowerCase();const isCompleted = cycleStatus === "completed";- const endDate = new Date(cycleDetails.end_date ?? "");- const startDate = new Date(cycleDetails.start_date ?? "");+ const endDate = getDate(cycleDetails.end_date);+ const startDate = getDate(cycleDetails.start_date);const isDateValid = cycleDetails.start_date || cycleDetails.end_date;const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;diff --git a/web/components/cycles/cycles-list-item.tsx b/web/components/cycles/cycles-list-item.tsxindex 31958cd847..98cf7b1aa3 100644--- a/web/components/cycles/cycles-list-item.tsx+++ b/web/components/cycles/cycles-list-item.tsx@@ -12,7 +12,7 @@ import { CustomMenu, Tooltip, CircularProgressIndicator, CycleGroupIcon, AvatarG// iconsimport { Check, Info, LinkIcon, Pencil, Star, Trash2, User2 } from "lucide-react";// helpers-import { findHowManyDaysLeft, renderFormattedDate } from "helpers/date-time.helper";+import { findHowManyDaysLeft, getDate, renderFormattedDate } from "helpers/date-time.helper";import { copyTextToClipboard } from "helpers/string.helper";// constantsimport { CYCLE_STATUS } from "constants/cycle";@@ -137,8 +137,8 @@ export const CyclesListItem: FC<TCyclesListItem> = observer((props) => {// TODO: change this logic once backend fix the responseconst cycleStatus = cycleDetails.status ? (cycleDetails.status.toLocaleLowerCase() as TCycleGroups) : "draft";const isCompleted = cycleStatus === "completed";- const endDate = new Date(cycleDetails.end_date ?? "");- const startDate = new Date(cycleDetails.start_date ?? "");+ const endDate = getDate(cycleDetails.end_date);+ const startDate = getDate(cycleDetails.start_date);const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;diff --git a/web/components/cycles/form.tsx b/web/components/cycles/form.tsxindex 799d804382..9941d551d4 100644--- a/web/components/cycles/form.tsx+++ b/web/components/cycles/form.tsx@@ -5,7 +5,7 @@ import { DateRangeDropdown, ProjectDropdown } from "components/dropdowns";// uiimport { Button, Input, TextArea } from "@plane/ui";// helpers-import { renderFormattedPayloadDate } from "helpers/date-time.helper";+import { getDate, renderFormattedPayloadDate } from "helpers/date-time.helper";// typesimport { ICycle } from "@plane/types";@@ -135,8 +135,8 @@ export const CycleForm: React.FC<Props> = (props) => {className="h-7"minDate={new Date()}value={{- from: startDateValue ? new Date(startDateValue) : undefined,- to: endDateValue ? new Date(endDateValue) : undefined,+ from: getDate(startDateValue),+ to: getDate(endDateValue),}}onSelect={(val) => {onChangeStartDate(val?.from ? renderFormattedPayloadDate(val.from) : null);diff --git a/web/components/cycles/gantt-chart/cycles-list-layout.tsx b/web/components/cycles/gantt-chart/cycles-list-layout.tsxindex 646333aad9..1467743198 100644--- a/web/components/cycles/gantt-chart/cycles-list-layout.tsx+++ b/web/components/cycles/gantt-chart/cycles-list-layout.tsx@@ -8,6 +8,7 @@ import { GanttChartRoot, IBlockUpdateData, CycleGanttSidebar } from "components/import { CycleGanttBlock } from "components/cycles";// typesimport { ICycle } from "@plane/types";+import { getDate } from "helpers/date-time.helper";// constantsimport { EUserProjectRoles } from "constants/project";@@ -45,8 +46,8 @@ export const CyclesListGanttChartView: FC<Props> = observer((props) => {data: block,id: block?.id ?? "",sort_order: block?.sort_order ?? 0,- start_date: new Date(block?.start_date ?? ""),- target_date: new Date(block?.end_date ?? ""),+ start_date: getDate(block?.start_date),+ target_date: getDate(block?.end_date),}));return structuredBlocks;diff --git a/web/components/cycles/sidebar.tsx b/web/components/cycles/sidebar.tsxindex 646736bd2b..56f137f8d3 100644--- a/web/components/cycles/sidebar.tsx+++ b/web/components/cycles/sidebar.tsx@@ -18,8 +18,8 @@ import { Avatar, CustomMenu, Loader, LayersIcon } from "@plane/ui";// iconsimport { ChevronDown, LinkIcon, Trash2, UserCircle2, AlertCircle, ChevronRight, CalendarClock } from "lucide-react";// helpers+import { findHowManyDaysLeft, getDate, renderFormattedPayloadDate } from "helpers/date-time.helper";import { copyUrlToClipboard } from "helpers/string.helper";-import { findHowManyDaysLeft, renderFormattedPayloadDate } from "helpers/date-time.helper";// typesimport { ICycle } from "@plane/types";// constants@@ -186,8 +186,11 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {const cycleStatus = cycleDetails?.status.toLocaleLowerCase();const isCompleted = cycleStatus === "completed";- const isStartValid = new Date(`${cycleDetails?.start_date}`) <= new Date();- const isEndValid = new Date(`${cycleDetails?.end_date}`) >= new Date(`${cycleDetails?.start_date}`);+ const startDate = getDate(cycleDetails?.start_date);+ const endDate = getDate(cycleDetails?.end_date);++ const isStartValid = startDate && startDate <= new Date();+ const isEndValid = endDate && startDate && endDate >= startDate;const progressPercentage = cycleDetails? isCompleted && cycleDetails?.progress_snapshot@@ -317,8 +320,8 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {buttonVariant="background-with-text"minDate={new Date()}value={{- from: startDateValue ? new Date(startDateValue) : undefined,- to: endDateValue ? new Date(endDateValue) : undefined,+ from: getDate(startDateValue),+ to: getDate(endDateValue),}}onSelect={(val) => {onChangeStartDate(val?.from ? renderFormattedPayloadDate(val.from) : null);diff --git a/web/components/dashboard/widgets/issue-panels/issue-list-item.tsx b/web/components/dashboard/widgets/issue-panels/issue-list-item.tsxindex 716a3afc18..b269423c6f 100644--- a/web/components/dashboard/widgets/issue-panels/issue-list-item.tsx+++ b/web/components/dashboard/widgets/issue-panels/issue-list-item.tsx@@ -5,7 +5,7 @@ import { useIssueDetail, useMember, useProject } from "hooks/store";// uiimport { Avatar, AvatarGroup, ControlLink, PriorityIcon } from "@plane/ui";// helpers-import { findTotalDaysInRange, renderFormattedDate } from "helpers/date-time.helper";+import { findTotalDaysInRange, getDate, renderFormattedDate } from "helpers/date-time.helper";// typesimport { TIssue, TWidgetIssue } from "@plane/types";@@ -34,6 +34,8 @@ export const AssignedUpcomingIssueListItem: React.FC<IssueListItemProps> = obserconst blockedByIssueProjectDetails =blockedByIssues.length === 1 ? getProjectById(blockedByIssues[0]?.project_id ?? "") : null;+ const targetDate = getDate(issueDetails.target_date);+return (<ControlLinkhref={`/${workspaceSlug}/projects/${issueDetails.project_id}/issues/${issueDetails.id}`}@@ -48,11 +50,7 @@ export const AssignedUpcomingIssueListItem: React.FC<IssueListItemProps> = obser<h6 className="text-sm flex-grow truncate">{issueDetails.name}</h6></div><div className="text-xs text-center">- {issueDetails.target_date- ? isToday(new Date(issueDetails.target_date))- ? "Today"- : renderFormattedDate(issueDetails.target_date)- : "-"}+ {targetDate ? (isToday(targetDate) ? "Today" : renderFormattedDate(targetDate)) : "-"}</div><div className="text-xs text-center">{blockedByIssues.length > 0@@ -83,7 +81,7 @@ export const AssignedOverdueIssueListItem: React.FC<IssueListItemProps> = observconst blockedByIssueProjectDetails =blockedByIssues.length === 1 ? getProjectById(blockedByIssues[0]?.project_id ?? "") : null;- const dueBy = findTotalDaysInRange(new Date(issueDetails.target_date ?? ""), new Date(), false) ?? 0;+ const dueBy = findTotalDaysInRange(getDate(issueDetails.target_date), new Date(), false) ?? 0;return (<ControlLink@@ -212,7 +210,7 @@ export const CreatedOverdueIssueListItem: React.FC<IssueListItemProps> = observeconst projectDetails = getProjectById(issue.project_id);- const dueBy = findTotalDaysInRange(new Date(issue.target_date ?? ""), new Date(), false) ?? 0;+ const dueBy = findTotalDaysInRange(getDate(issue.target_date), new Date(), false) ?? 0;return (<ControlLinkdiff --git a/web/components/dropdowns/date.tsx b/web/components/dropdowns/date.tsxindex 570ea45da7..80d2731fd5 100644--- a/web/components/dropdowns/date.tsx+++ b/web/components/dropdowns/date.tsx@@ -9,7 +9,7 @@ import useOutsideClickDetector from "hooks/use-outside-click-detector";// componentsimport { DropdownButton } from "./buttons";// helpers-import { renderFormattedDate } from "helpers/date-time.helper";+import { getDate, renderFormattedDate } from "helpers/date-time.helper";import { cn } from "helpers/common.helper";// typesimport { TDropdownProps } from "./types";@@ -168,8 +168,8 @@ export const DateDropdown: React.FC<Props> = (props) => {{...attributes.popper}><DayPicker- selected={value ? new Date(value) : undefined}- defaultMonth={value ? new Date(value) : undefined}+ selected={getDate(value)}+ defaultMonth={getDate(value)}onSelect={(date) => {dropdownOnChange(date ?? null);}}diff --git a/web/components/exporter/single-export.tsx b/web/components/exporter/single-export.tsxindex 34e41fc358..bd73824cf8 100644--- a/web/components/exporter/single-export.tsx+++ b/web/components/exporter/single-export.tsx@@ -2,7 +2,7 @@ import { useState, FC } from "react";// uiimport { Button } from "@plane/ui";// helpers-import { renderFormattedDate } from "helpers/date-time.helper";+import { getDate, renderFormattedDate } from "helpers/date-time.helper";// typesimport { IExportData } from "@plane/types";@@ -18,7 +18,8 @@ export const SingleExport: FC<Props> = ({ service, refreshing }) => {const checkExpiry = (inputDateString: string) => {const currentDate = new Date();- const expiryDate = new Date(inputDateString);+ const expiryDate = getDate(inputDateString);+ if (!expiryDate) return false;expiryDate.setDate(expiryDate.getDate() + 7);return expiryDate > currentDate;};diff --git a/web/components/gantt-chart/chart/root.tsx b/web/components/gantt-chart/chart/root.tsxindex be6229ce38..dada139a85 100644--- a/web/components/gantt-chart/chart/root.tsx+++ b/web/components/gantt-chart/chart/root.tsx@@ -64,9 +64,9 @@ export const ChartViewRoot: FC<ChartViewRootProps> = observer((props) => {useGanttChart();// rendering the block structure- const renderBlockStructure = (view: any, blocks: IGanttBlock[] | null) =>+ const renderBlockStructure = (view: ChartDataType, blocks: IGanttBlock[] | null) =>blocks- ? blocks.map((block: any) => ({+ ? blocks.map((block: IGanttBlock) => ({...block,position: getMonthChartItemPositionWidthInMonth(view, block),}))diff --git a/web/components/gantt-chart/types/index.ts b/web/components/gantt-chart/types/index.tsindex 6268e4363a..cd90758fc3 100644--- a/web/components/gantt-chart/types/index.ts+++ b/web/components/gantt-chart/types/index.ts@@ -6,8 +6,8 @@ export interface IGanttBlock {width: number;};sort_order: number;- start_date: Date | null;- target_date: Date | null;+ start_date: Date | undefined;+ target_date: Date | undefined;}export interface IBlockUpdateData {diff --git a/web/components/gantt-chart/views/month-view.ts b/web/components/gantt-chart/views/month-view.tsindex 13d054da1a..8978dc3174 100644--- a/web/components/gantt-chart/views/month-view.ts+++ b/web/components/gantt-chart/views/month-view.ts@@ -1,4 +1,5 @@// types+import { findTotalDaysInRange } from "helpers/date-time.helper";import { ChartDataType, IGanttBlock } from "../types";// dataimport { weeks, months } from "../data";@@ -167,15 +168,16 @@ export const getMonthChartItemPositionWidthInMonth = (chartData: ChartDataType,const { startDate } = chartData.data;const { start_date: itemStartDate, target_date: itemTargetDate } = itemData;- if (!itemStartDate || !itemTargetDate) return null;+ if (!itemStartDate || !itemTargetDate) return;startDate.setHours(0, 0, 0, 0);itemStartDate.setHours(0, 0, 0, 0);itemTargetDate.setHours(0, 0, 0, 0);- // position code starts- const positionTimeDifference: number = startDate.getTime() - itemStartDate.getTime();- const positionDaysDifference: number = Math.abs(Math.floor(positionTimeDifference / (1000 * 60 * 60 * 24)));+ const positionDaysDifference = findTotalDaysInRange(startDate, itemStartDate, false);++ if (!positionDaysDifference) return;+scrollPosition = positionDaysDifference * chartData.data.width;var diffMonths = (itemStartDate.getFullYear() - startDate.getFullYear()) * 12;diff --git a/web/components/inbox/inbox-issue-actions.tsx b/web/components/inbox/inbox-issue-actions.tsxindex 48d9157c63..aba20ba3c6 100644--- a/web/components/inbox/inbox-issue-actions.tsx+++ b/web/components/inbox/inbox-issue-actions.tsx@@ -21,6 +21,8 @@ import { CheckCircle2, ChevronDown, ChevronUp, Clock, FileStack, Trash2, XCircleimport type { TInboxStatus, TInboxDetailedStatus } from "@plane/types";import { EUserProjectRoles } from "constants/project";import { ISSUE_DELETED } from "constants/event-tracker";+//helpers+import { getDate } from "helpers/date-time.helper";type TInboxIssueActionsHeader = {workspaceSlug: string;@@ -171,11 +173,11 @@ export const InboxIssueActionsHeader: FC<TInboxIssueActionsHeader> = observer((pconst isAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;const today = new Date();- const tomorrow = new Date(today);- tomorrow.setDate(today.getDate() + 1);+ const tomorrow = getDate(today);+ tomorrow?.setDate(today.getDate() + 1);useEffect(() => {if (!issueStatus || !issueStatus.snoozed_till) return;- setDate(new Date(issueStatus.snoozed_till));+ setDate(issueStatus.snoozed_till);}, [issueStatus]);if (!issueStatus || !issue || !inboxIssues) return <></>;@@ -269,19 +271,23 @@ export const InboxIssueActionsHeader: FC<TInboxIssueActionsHeader> = observer((p{({ close }) => (<div className="flex h-full w-full flex-col gap-y-1"><DayPicker- selected={date ? new Date(date) : undefined}- defaultMonth={date ? new Date(date) : undefined}+ selected={getDate(date)}+ defaultMonth={getDate(date)}onSelect={(date) => {if (!date) return;setDate(date);}}mode="single"className="border border-custom-border-200 rounded-md p-3"- disabled={[- {- before: tomorrow,- },- ]}+ disabled={+ tomorrow+ ? [+ {+ before: tomorrow,+ },+ ]+ : undefined+ }/><Buttonvariant="primary"@@ -289,7 +295,7 @@ export const InboxIssueActionsHeader: FC<TInboxIssueActionsHeader> = observer((pclose();inboxIssueOperations.updateInboxIssueStatus({status: 0,- snoozed_till: new Date(date),+ snoozed_till: date,});}}>diff --git a/web/components/inbox/inbox-issue-status.tsx b/web/components/inbox/inbox-issue-status.tsxindex 2d101f2aaf..e4159146dc 100644--- a/web/components/inbox/inbox-issue-status.tsx+++ b/web/components/inbox/inbox-issue-status.tsx@@ -28,7 +28,7 @@ export const InboxIssueStatus: React.FC<Props> = observer((props) => {if (!inboxIssueStatusDetail) return <></>;const isSnoozedDatePassed =- inboxIssueDetail.status === 0 && new Date(inboxIssueDetail.snoozed_till ?? "") < new Date();+ inboxIssueDetail.status === 0 && !!inboxIssueDetail.snoozed_till && inboxIssueDetail.snoozed_till < new Date();return (<div@@ -46,7 +46,7 @@ export const InboxIssueStatus: React.FC<Props> = observer((props) => {workspaceSlug,projectId,inboxIssueDetail.duplicate_to ?? "",- new Date(inboxIssueDetail.snoozed_till ?? "")+ inboxIssueDetail.snoozed_till)) : (<span>{inboxIssueStatusDetail.title}</span>diff --git a/web/components/issues/issue-detail/inbox/sidebar.tsx b/web/components/issues/issue-detail/inbox/sidebar.tsxindex 592791a85b..2b4da03538 100644--- a/web/components/issues/issue-detail/inbox/sidebar.tsx+++ b/web/components/issues/issue-detail/inbox/sidebar.tsx@@ -9,7 +9,7 @@ import { DateDropdown, PriorityDropdown, MemberDropdown, StateDropdown } from "c// iconsimport { DoubleCircleIcon, StateGroupIcon, UserGroupIcon } from "@plane/ui";// helper-import { renderFormattedPayloadDate } from "helpers/date-time.helper";+import { getDate, renderFormattedPayloadDate } from "helpers/date-time.helper";type Props = {workspaceSlug: string;@@ -33,7 +33,7 @@ export const InboxIssueDetailsSidebar: React.FC<Props> = observer((props) => {const projectDetails = issue ? getProjectById(issue.project_id) : null;- const minDate = issue.start_date ? new Date(issue.start_date) : null;+ const minDate = issue.start_date ? getDate(issue.start_date) : null;minDate?.setDate(minDate.getDate());const currentIssueState = projectStates?.find((s) => s.id === issue.state_id);diff --git a/web/components/issues/issue-detail/sidebar.tsx b/web/components/issues/issue-detail/sidebar.tsxindex a65cb7f164..8f565653aa 100644--- a/web/components/issues/issue-detail/sidebar.tsx+++ b/web/components/issues/issue-detail/sidebar.tsx@@ -28,12 +28,13 @@ import {IssueLabel,ArchiveIssueModal,} from "components/issues";+// componentsimport { IssueSubscription } from "./subscription";import { DateDropdown, EstimateDropdown, PriorityDropdown, MemberDropdown, StateDropdown } from "components/dropdowns";// iconsimport { ArchiveIcon, ContrastIcon, DiceIcon, DoubleCircleIcon, RelatedIcon, Tooltip, UserGroupIcon } from "@plane/ui";// helpers-import { renderFormattedPayloadDate } from "helpers/date-time.helper";+import { getDate, renderFormattedPayloadDate } from "helpers/date-time.helper";import { copyTextToClipboard } from "helpers/string.helper";import { cn } from "helpers/common.helper";import { shouldHighlightIssueDueDate } from "helpers/issue.helper";@@ -99,10 +100,10 @@ export const IssueDetailsSidebar: React.FC<Props> = observer((props) => {const isInArchivableGroup =!!stateDetails && [STATE_GROUPS.completed.key, STATE_GROUPS.cancelled.key].includes(stateDetails?.group);- const minDate = issue.start_date ? new Date(issue.start_date) : null;+ const minDate = issue.start_date ? getDate(issue.start_date) : null;minDate?.setDate(minDate.getDate());- const maxDate = issue.target_date ? new Date(issue.target_date) : null;+ const maxDate = issue.target_date ? getDate(issue.target_date) : null;maxDate?.setDate(maxDate.getDate());return (diff --git a/web/components/issues/issue-layouts/calendar/dropdowns/months-dropdown.tsx b/web/components/issues/issue-layouts/calendar/dropdowns/months-dropdown.tsxindex 2443ae17bf..f6c9dcb566 100644--- a/web/components/issues/issue-layouts/calendar/dropdowns/months-dropdown.tsx+++ b/web/components/issues/issue-layouts/calendar/dropdowns/months-dropdown.tsx@@ -12,6 +12,8 @@ import { ICycleIssuesFilter } from "store/issue/cycle";import { IModuleIssuesFilter } from "store/issue/module";import { IProjectIssuesFilter } from "store/issue/project";import { IProjectViewIssuesFilter } from "store/issue/project-views";+// helpers+import { getDate } from "helpers/date-time.helper";interface Props {issuesFilterStore: IProjectIssuesFilter | IModuleIssuesFilter | ICycleIssuesFilter | IProjectViewIssuesFilter;@@ -47,8 +49,10 @@ export const CalendarMonthsDropdown: React.FC<Props> = observer((props: Props) =const daysList = Object.keys(allDaysOfActiveWeek);- const firstDay = new Date(daysList[0]);- const lastDay = new Date(daysList[daysList.length - 1]);+ const firstDay = getDate(daysList[0]);+ const lastDay = getDate(daysList[daysList.length - 1]);++ if (!firstDay || !lastDay) return "Week view";if (firstDay.getMonth() === lastDay.getMonth() && firstDay.getFullYear() === lastDay.getFullYear())return `${MONTHS_LIST[firstDay.getMonth() + 1].title} ${firstDay.getFullYear()}`;diff --git a/web/components/issues/issue-layouts/properties/all-properties.tsx b/web/components/issues/issue-layouts/properties/all-properties.tsxindex 238d2e7445..ba4917febf 100644--- a/web/components/issues/issue-layouts/properties/all-properties.tsx+++ b/web/components/issues/issue-layouts/properties/all-properties.tsx@@ -19,7 +19,7 @@ import {StateDropdown,} from "components/dropdowns";// helpers-import { renderFormattedPayloadDate } from "helpers/date-time.helper";+import { getDate, renderFormattedPayloadDate } from "helpers/date-time.helper";import { shouldHighlightIssueDueDate } from "helpers/issue.helper";import { cn } from "helpers/common.helper";// types@@ -229,10 +229,10 @@ export const IssueProperties: React.FC<IIssueProperties> = observer((props) => {const defaultLabelOptions = issue?.label_ids?.map((id) => labelMap[id]) || [];- const minDate = issue.start_date ? new Date(issue.start_date) : null;+ const minDate = getDate(issue.start_date);minDate?.setDate(minDate.getDate());- const maxDate = issue.target_date ? new Date(issue.target_date) : null;+ const maxDate = getDate(issue.target_date);maxDate?.setDate(maxDate.getDate());return (@@ -284,7 +284,7 @@ export const IssueProperties: React.FC<IIssueProperties> = observer((props) => {<DateDropdownvalue={issue.start_date ?? null}onChange={handleStartDate}- maxDate={maxDate ?? undefined}+ maxDate={maxDate}placeholder="Start date"icon={<CalendarClock className="h-3 w-3 flex-shrink-0" />}buttonVariant={issue.start_date ? "border-with-text" : "border-without-text"}@@ -300,7 +300,7 @@ export const IssueProperties: React.FC<IIssueProperties> = observer((props) => {<DateDropdownvalue={issue?.target_date ?? null}onChange={handleTargetDate}- minDate={minDate ?? undefined}+ minDate={minDate}placeholder="Due date"icon={<CalendarCheck2 className="h-3 w-3 flex-shrink-0" />}buttonVariant={issue.target_date ? "border-with-text" : "border-without-text"}diff --git a/web/components/issues/issue-layouts/spreadsheet/columns/due-date-column.tsx b/web/components/issues/issue-layouts/spreadsheet/columns/due-date-column.tsxindex e261797af8..cc45dc7b4d 100644--- a/web/components/issues/issue-layouts/spreadsheet/columns/due-date-column.tsx+++ b/web/components/issues/issue-layouts/spreadsheet/columns/due-date-column.tsx@@ -6,9 +6,9 @@ import { useProjectState } from "hooks/store";// componentsimport { DateDropdown } from "components/dropdowns";// helpers-import { renderFormattedPayloadDate } from "helpers/date-time.helper";-import { shouldHighlightIssueDueDate } from "helpers/issue.helper";import { cn } from "helpers/common.helper";+import { getDate, renderFormattedPayloadDate } from "helpers/date-time.helper";+import { shouldHighlightIssueDueDate } from "helpers/issue.helper";// typesimport { TIssue } from "@plane/types";@@ -30,7 +30,7 @@ export const SpreadsheetDueDateColumn: React.FC<Props> = observer((props: Props)<div className="h-11 border-b-[0.5px] border-custom-border-200"><DateDropdownvalue={issue.target_date}- minDate={issue.start_date ? new Date(issue.start_date) : undefined}+ minDate={getDate(issue.start_date)}onChange={(data) => {const targetDate = data ? renderFormattedPayloadDate(data) : null;onChange(diff --git a/web/components/issues/issue-layouts/spreadsheet/columns/start-date-column.tsx b/web/components/issues/issue-layouts/spreadsheet/columns/start-date-column.tsxindex 01f7fe793a..b0ee46d4e7 100644--- a/web/components/issues/issue-layouts/spreadsheet/columns/start-date-column.tsx+++ b/web/components/issues/issue-layouts/spreadsheet/columns/start-date-column.tsx@@ -4,7 +4,7 @@ import { CalendarClock } from "lucide-react";// componentsimport { DateDropdown } from "components/dropdowns";// helpers-import { renderFormattedPayloadDate } from "helpers/date-time.helper";+import { getDate, renderFormattedPayloadDate } from "helpers/date-time.helper";// typesimport { TIssue } from "@plane/types";@@ -22,7 +22,7 @@ export const SpreadsheetStartDateColumn: React.FC<Props> = observer((props: Prop<div className="h-11 border-b-[0.5px] border-custom-border-200"><DateDropdownvalue={issue.start_date}- maxDate={issue.target_date ? new Date(issue.target_date) : undefined}+ maxDate={getDate(issue.target_date)}onChange={(data) => {const startDate = data ? renderFormattedPayloadDate(data) : null;onChange(diff --git a/web/components/issues/issue-modal/form.tsx b/web/components/issues/issue-modal/form.tsxindex e2e4e784e8..d18d53f1bf 100644--- a/web/components/issues/issue-modal/form.tsx+++ b/web/components/issues/issue-modal/form.tsx@@ -26,10 +26,10 @@ import {MemberDropdown,StateDropdown,} from "components/dropdowns";-// ui+//uiimport { Button, CustomMenu, Input, Loader, ToggleSwitch } from "@plane/ui";// helpers-import { renderFormattedPayloadDate } from "helpers/date-time.helper";+import { getDate, renderFormattedPayloadDate } from "helpers/date-time.helper";// typesimport type { TIssue, ISearchIssueResponse } from "@plane/types";@@ -236,10 +236,10 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {const startDate = watch("start_date");const targetDate = watch("target_date");- const minDate = startDate ? new Date(startDate) : null;+ const minDate = getDate(startDate);minDate?.setDate(minDate.getDate());- const maxDate = targetDate ? new Date(targetDate) : null;+ const maxDate = getDate(targetDate);maxDate?.setDate(maxDate.getDate());const projectDetails = getProjectById(projectId);diff --git a/web/components/issues/peek-overview/properties.tsx b/web/components/issues/peek-overview/properties.tsxindex 2f5a02c11e..d7723a5e07 100644--- a/web/components/issues/peek-overview/properties.tsx+++ b/web/components/issues/peek-overview/properties.tsx@@ -26,9 +26,9 @@ import {} from "components/issues";import { DateDropdown, EstimateDropdown, PriorityDropdown, MemberDropdown, StateDropdown } from "components/dropdowns";// components-import { renderFormattedPayloadDate } from "helpers/date-time.helper";// helpersimport { cn } from "helpers/common.helper";+import { getDate, renderFormattedPayloadDate } from "helpers/date-time.helper";import { shouldHighlightIssueDueDate } from "helpers/issue.helper";interface IPeekOverviewProperties {@@ -54,10 +54,10 @@ export const PeekOverviewProperties: FC<IPeekOverviewProperties> = observer((proconst isEstimateEnabled = projectDetails?.estimate;const stateDetails = getStateById(issue.state_id);- const minDate = issue.start_date ? new Date(issue.start_date) : null;+ const minDate = getDate(issue.start_date);minDate?.setDate(minDate.getDate());- const maxDate = issue.target_date ? new Date(issue.target_date) : null;+ const maxDate = getDate(issue.target_date);maxDate?.setDate(maxDate.getDate());return (diff --git a/web/components/modules/form.tsx b/web/components/modules/form.tsxindex 1dde2b85d0..ead8c06594 100644--- a/web/components/modules/form.tsx+++ b/web/components/modules/form.tsx@@ -6,7 +6,7 @@ import { DateRangeDropdown, ProjectDropdown, MemberDropdown } from "components/d// uiimport { Button, Input, TextArea } from "@plane/ui";// helpers-import { renderFormattedPayloadDate } from "helpers/date-time.helper";+import { getDate, renderFormattedPayloadDate } from "helpers/date-time.helper";// typesimport { IModule } from "@plane/types";@@ -147,8 +147,8 @@ export const ModuleForm: React.FC<Props> = (props) => {className="h-7"minDate={new Date()}value={{- from: startDateValue ? new Date(startDateValue) : undefined,- to: endDateValue ? new Date(endDateValue) : undefined,+ from: getDate(startDateValue),+ to: getDate(endDateValue),}}onSelect={(val) => {onChangeStartDate(val?.from ? renderFormattedPayloadDate(val.from) : null);diff --git a/web/components/modules/gantt-chart/modules-list-layout.tsx b/web/components/modules/gantt-chart/modules-list-layout.tsxindex c6caacc921..9e2748ec54 100644--- a/web/components/modules/gantt-chart/modules-list-layout.tsx+++ b/web/components/modules/gantt-chart/modules-list-layout.tsx@@ -7,6 +7,7 @@ import { GanttChartRoot, IBlockUpdateData, ModuleGanttSidebar } from "componentsimport { ModuleGanttBlock } from "components/modules";// typesimport { IModule } from "@plane/types";+import { getDate } from "helpers/date-time.helper";export const ModulesListGanttChartView: React.FC = observer(() => {// router@@ -32,8 +33,8 @@ export const ModulesListGanttChartView: React.FC = observer(() => {data: block,id: block.id,sort_order: block.sort_order,- start_date: block.start_date ? new Date(block.start_date) : null,- target_date: block.target_date ? new Date(block.target_date) : null,+ start_date: getDate(block.start_date),+ target_date: getDate(block.target_date),};});diff --git a/web/components/modules/module-card-item.tsx b/web/components/modules/module-card-item.tsxindex 4dec3df6ee..1fee481ce5 100644--- a/web/components/modules/module-card-item.tsx+++ b/web/components/modules/module-card-item.tsx@@ -12,7 +12,7 @@ import { CreateUpdateModuleModal, DeleteModuleModal } from "components/modules";import { Avatar, AvatarGroup, CustomMenu, LayersIcon, Tooltip } from "@plane/ui";// helpersimport { copyUrlToClipboard } from "helpers/string.helper";-import { renderFormattedDate } from "helpers/date-time.helper";+import { getDate, renderFormattedDate } from "helpers/date-time.helper";// constantsimport { MODULE_STATUS } from "constants/module";import { EUserProjectRoles } from "constants/project";@@ -135,8 +135,8 @@ export const ModuleCardItem: React.FC<Props> = observer((props) => {const completionPercentage = (moduleDetails.completed_issues / moduleTotalIssues) * 100;- const endDate = new Date(moduleDetails.target_date ?? "");- const startDate = new Date(moduleDetails.start_date ?? "");+ const endDate = getDate(moduleDetails.target_date);+ const startDate = getDate(moduleDetails.start_date);const isDateValid = moduleDetails.target_date || moduleDetails.start_date;diff --git a/web/components/modules/module-list-item.tsx b/web/components/modules/module-list-item.tsxindex 3d7468f24a..1a9b6ac3f9 100644--- a/web/components/modules/module-list-item.tsx+++ b/web/components/modules/module-list-item.tsx@@ -12,7 +12,7 @@ import { CreateUpdateModuleModal, DeleteModuleModal } from "components/modules";import { Avatar, AvatarGroup, CircularProgressIndicator, CustomMenu, Tooltip } from "@plane/ui";// helpersimport { copyUrlToClipboard } from "helpers/string.helper";-import { renderFormattedDate } from "helpers/date-time.helper";+import { getDate, renderFormattedDate } from "helpers/date-time.helper";// constantsimport { MODULE_STATUS } from "constants/module";import { EUserProjectRoles } from "constants/project";@@ -129,8 +129,8 @@ export const ModuleListItem: React.FC<Props> = observer((props) => {const completionPercentage =((moduleDetails.completed_issues + moduleDetails.cancelled_issues) / moduleDetails.total_issues) * 100;- const endDate = new Date(moduleDetails.target_date ?? "");- const startDate = new Date(moduleDetails.start_date ?? "");+ const endDate = getDate(moduleDetails.target_date);+ const startDate = getDate(moduleDetails.start_date);const renderDate = moduleDetails.start_date || moduleDetails.target_date;diff --git a/web/components/modules/sidebar.tsx b/web/components/modules/sidebar.tsxindex c8c55321c8..1dbc71977f 100644--- a/web/components/modules/sidebar.tsx+++ b/web/components/modules/sidebar.tsx@@ -25,7 +25,7 @@ import { DateRangeDropdown, MemberDropdown } from "components/dropdowns";// uiimport { CustomMenu, Loader, LayersIcon, CustomSelect, ModuleStatusIcon, UserGroupIcon } from "@plane/ui";// helpers-import { renderFormattedPayloadDate } from "helpers/date-time.helper";+import { getDate, renderFormattedPayloadDate } from "helpers/date-time.helper";import { copyUrlToClipboard } from "helpers/string.helper";// typesimport { ILinkDetails, IModule, ModuleLink } from "@plane/types";@@ -201,8 +201,10 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {});}, [moduleDetails, reset]);- const isStartValid = new Date(`${moduleDetails?.start_date}`) <= new Date();- const isEndValid = new Date(`${moduleDetails?.target_date}`) >= new Date(`${moduleDetails?.start_date}`);+ const startDate = getDate(moduleDetails?.start_date);+ const endDate = getDate(moduleDetails?.target_date);+ const isStartValid = startDate && startDate <= new Date();+ const isEndValid = startDate && endDate && endDate >= startDate;const progressPercentage = moduleDetails? Math.round((moduleDetails.completed_issues / moduleDetails.total_issues) * 100)@@ -342,26 +344,30 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {<Controllercontrol={control}name="target_date"- render={({ field: { value: endDateValue, onChange: onChangeEndDate } }) => (- <DateRangeDropdown- buttonContainerClassName="w-full"- buttonVariant="background-with-text"- minDate={new Date()}- value={{- from: startDateValue ? new Date(startDateValue) : undefined,- to: endDateValue ? new Date(endDateValue) : undefined,- }}- onSelect={(val) => {- onChangeStartDate(val?.from ? renderFormattedPayloadDate(val.from) : null);- onChangeEndDate(val?.to ? renderFormattedPayloadDate(val.to) : null);- handleDateChange(val?.from, val?.to);- }}- placeholder={{- from: "Start date",- to: "Target date",- }}- />- )}+ render={({ field: { value: endDateValue, onChange: onChangeEndDate } }) => {+ const startDate = getDate(startDateValue);+ const endDate = getDate(endDateValue);+ return (+ <DateRangeDropdown+ buttonContainerClassName="w-full"+ buttonVariant="background-with-text"+ minDate={new Date()}+ value={{+ from: startDate,+ to: endDate,+ }}+ onSelect={(val) => {+ onChangeStartDate(val?.from ? renderFormattedPayloadDate(val.from) : null);+ onChangeEndDate(val?.to ? renderFormattedPayloadDate(val.to) : null);+ handleDateChange(val?.from, val?.to);+ }}+ placeholder={{+ from: "Start date",+ to: "Target date",+ }}+ />+ );+ }}/>)}/>diff --git a/web/components/notifications/notification-card.tsx b/web/components/notifications/notification-card.tsxindex 03d849a821..c264079726 100644--- a/web/components/notifications/notification-card.tsx+++ b/web/components/notifications/notification-card.tsx@@ -119,7 +119,7 @@ export const NotificationCard: React.FC<NotificationCardProps> = (props) => {const notificationField = notification.data.issue_activity.field;const notificationTriggeredBy = notification.triggered_by_details;- if (isSnoozedTabOpen && new Date(notification.snoozed_till!) < new Date()) return null;+ if (isSnoozedTabOpen && notification.snoozed_till! < new Date()) return null;return (<Linkdiff --git a/web/components/notifications/select-snooze-till-modal.tsx b/web/components/notifications/select-snooze-till-modal.tsxindex f89b3a9634..21487a6907 100644--- a/web/components/notifications/select-snooze-till-modal.tsx+++ b/web/components/notifications/select-snooze-till-modal.tsx@@ -60,7 +60,7 @@ export const SnoozeNotificationModal: FC<SnoozeModalProps> = (props) => {if (!formDataDate) return timeStamps;- const isToday = today.toDateString() === new Date(formDataDate).toDateString();+ const isToday = today.toDateString() === formDataDate.toDateString();if (!isToday) return timeStamps;@@ -93,7 +93,7 @@ export const SnoozeNotificationModal: FC<SnoozeModalProps> = (props) => {);const minutes = parseInt(time[1]);- const dateTime = new Date(formData.date);+ const dateTime = formData.date;dateTime.setHours(hours);dateTime.setMinutes(minutes);diff --git a/web/constants/inbox.tsx b/web/constants/inbox.tsxindex 61c417eafa..644009cfe4 100644--- a/web/constants/inbox.tsx+++ b/web/constants/inbox.tsx@@ -8,7 +8,12 @@ export const INBOX_STATUS: {status: number;icon: LucideIcon;title: string;- description: (workspaceSlug: string, projectId: string, issueId: string, snoozedTillDate: Date) => JSX.Element;+ description: (+ workspaceSlug: string,+ projectId: string,+ issueId: string,+ snoozedTillDate: Date | undefined+ ) => JSX.Element;textColor: (snoozeDatePassed: boolean) => string;bgColor: (snoozeDatePassed: boolean) => string;borderColor: (snoozeDatePassed: boolean) => string;diff --git a/web/contexts/user-notification-context.tsx b/web/contexts/user-notification-context.tsxindex b55a05771e..2233fe5d85 100644--- a/web/contexts/user-notification-context.tsx+++ b/web/contexts/user-notification-context.tsx@@ -91,7 +91,7 @@ const UserNotificationContextProvider: React.FC<{const [state, dispatch] = useReducer(reducer, initialState);- const { selectedTab, snoozed, archived, readNotification, selectedNotificationForSnooze } = state;+ const { selectedTab, snoozed, archived, readNotification } = state;const params = {type: snoozed || archived || readNotification ? undefined : selectedTab,@@ -207,7 +207,7 @@ const UserNotificationContextProvider: React.FC<{(previousNotifications: any) =>previousNotifications?.map((notification: any) =>notification.id === notificationId- ? { ...notification, snoozed_till: isSnoozed ? null : new Date(dateTime!) }+ ? { ...notification, snoozed_till: isSnoozed ? null : dateTime }: notification) || [],falsediff --git a/web/helpers/date-time.helper.ts b/web/helpers/date-time.helper.tsindex 5423d4e929..74d3b72fe7 100644--- a/web/helpers/date-time.helper.ts+++ b/web/helpers/date-time.helper.ts@@ -1,5 +1,5 @@import { differenceInDays, format, formatDistanceToNow, isAfter, isEqual, isValid, parseISO } from "date-fns";-import { isNil } from "lodash";+import isNumber from "lodash/isNumber";// Format Date Helpers/**@@ -8,10 +8,11 @@ import { isNil } from "lodash";* @param {Date | string} date* @example renderFormattedDate("2024-01-01") // Jan 01, 2024*/-export const renderFormattedDate = (date: string | Date): string | null => {- if (!date) return null;+export const renderFormattedDate = (date: string | Date | undefined): string | null => {// Parse the date to check if it is valid- const parsedDate = new Date(date);+ const parsedDate = getDate(date);+ // return if undefined+ if (!parsedDate) return null;// Check if the parsed date is valid before formattingif (!isValid(parsedDate)) return null; // Return null for invalid dates// Format the date in format (MMM dd, yyyy)@@ -26,9 +27,10 @@ export const renderFormattedDate = (date: string | Date): string | null => {* @example renderShortDateFormat("2024-01-01") // Jan 01*/export const renderFormattedDateWithoutYear = (date: string | Date): string => {- if (!date) return "";// Parse the date to check if it is valid- const parsedDate = new Date(date);+ const parsedDate = getDate(date);+ // return if undefined+ if (!parsedDate) return "";// Check if the parsed date is valid before formattingif (!isValid(parsedDate)) return ""; // Return empty string for invalid dates// Format the date in short format (MMM dd)@@ -43,9 +45,10 @@ export const renderFormattedDateWithoutYear = (date: string | Date): string => {* @example renderFormattedPayloadDate("Jan 01, 20224") // "2024-01-01"*/export const renderFormattedPayloadDate = (date: Date | string): string | null => {- if (!date) return null;// Parse the date to check if it is valid- const parsedDate = new Date(date);+ const parsedDate = getDate(date);+ // return if undefined+ if (!parsedDate) return null;// Check if the parsed date is valid before formattingif (!isValid(parsedDate)) return null; // Return null for invalid dates// Format the date in payload format (yyyy-mm-dd)@@ -63,9 +66,10 @@ export const renderFormattedPayloadDate = (date: Date | string): string | null =* @example renderFormattedTime("2024-01-01 13:00:00", "12-hour") // 01:00 PM*/export const renderFormattedTime = (date: string | Date, timeFormat: "12-hour" | "24-hour" = "24-hour"): string => {- if (!date || date === "") return "";// Parse the date to check if it is valid- const parsedDate = new Date(date);+ const parsedDate = getDate(date);+ // return if undefined+ if (!parsedDate) return "";// Check if the parsed date is validif (!isValid(parsedDate)) return ""; // Return empty string for invalid dates// Format the date in 12 hour format if in12HourFormat is true@@ -92,10 +96,11 @@ export const findTotalDaysInRange = (endDate: Date | string | undefined | null,inclusive: boolean = true): number | undefined => {- if (!startDate || !endDate) return undefined;// Parse the dates to check if they are valid- const parsedStartDate = new Date(startDate);- const parsedEndDate = new Date(endDate);+ const parsedStartDate = getDate(startDate);+ const parsedEndDate = getDate(endDate);+ // return if undefined+ if (!parsedStartDate || !parsedEndDate) return;// Check if the parsed dates are valid before calculating the differenceif (!isValid(parsedStartDate) || !isValid(parsedEndDate)) return 0; // Return 0 for invalid dates// Calculate the difference in days@@ -131,6 +136,7 @@ export const calculateTimeAgo = (time: string | number | Date | null): string =>if (!time) return "";// Parse the time to check if it is validconst parsedTime = typeof time === "string" || typeof time === "number" ? parseISO(String(time)) : time;+ // return if undefinedif (!parsedTime) return ""; // Return empty string for invalid dates// Format the time in the form of amount of time passed since the event happenedconst distance = formatDistanceToNow(parsedTime, { addSuffix: true });@@ -164,7 +170,7 @@ export const isDateGreaterThanToday = (dateStr: string): boolean => {* @example getWeekNumber(new Date("2023-09-01")) // 35*/export const getWeekNumberOfDate = (date: Date): number => {- const currentDate = new Date(date);+ const currentDate = date;// Adjust the starting day to Sunday (0) instead of Monday (1)const startDate = new Date(currentDate.getFullYear(), 0, 1);// Calculate the number of days between currentDate and startDate@@ -186,10 +192,30 @@ export const checkIfDatesAreEqual = (date1: Date | string | null | undefined,date2: Date | string | null | undefined): boolean => {- if (isNil(date1) && isNil(date2)) return true;- if (isNil(date1) || isNil(date2)) return false;+ const parsedDate1 = getDate(date1);+ const parsedDate2 = getDate(date2);+ // return if undefined+ if (!parsedDate1 && !parsedDate2) return true;+ if (!parsedDate1 || !parsedDate2) return false;- const parsedDate1 = new Date(date1);- const parsedDate2 = new Date(date2);return isEqual(parsedDate1, parsedDate2);};++/**+ * This method returns a date from string of type yyyy-mm-dd+ * This method is recommended to use instead of new Date() as this does not introduce any timezone offsets+ * @param date+ * @returns date or undefined+ */+export const getDate = (date: string | Date | undefined | null): Date | undefined => {+ if (!date || date === "") return;++ if (typeof date !== "string" && !(date instanceof String)) return date;+ const [yearString, monthString, dayString] = date.substring(0, 10).split("-");+ const year = parseInt(yearString);+ const month = parseInt(monthString);+ const day = parseInt(dayString);+ if (!isNumber(year) || !isNumber(month) || !isNumber(day)) return;++ return new Date(year, month - 1, day);+};\ No newline at end of filediff --git a/web/helpers/filter.helper.ts b/web/helpers/filter.helper.tsindex 0b30f95e1c..624106ce33 100644--- a/web/helpers/filter.helper.ts+++ b/web/helpers/filter.helper.ts@@ -1,5 +1,7 @@// typesimport { IIssueFilterOptions } from "@plane/types";+import differenceInCalendarDays from "date-fns/differenceInCalendarDays";+import { getDate } from "./date-time.helper";export const calculateTotalFilters = (filters: IIssueFilterOptions): number =>filters && Object.keys(filters).length > 0@@ -14,3 +16,35 @@ export const calculateTotalFilters = (filters: IIssueFilterOptions): number =>.reduce((curr, prev) => curr + prev, 0): 0;+/**+ * @description checks if the date satisfies the filter+ * @param {Date} date+ * @param {string} filter+ * @returns {boolean}+ */+export const satisfiesDateFilter = (date: Date, filter: string): boolean => {+ const [value, operator, from] = filter.split(";");++ const dateValue = getDate(value);+ if (!from && dateValue) {+ if (operator === "after") return date >= dateValue;+ if (operator === "before") return date <= dateValue;+ }++ if (from === "fromnow") {+ if (operator === "before") {+ if (value === "1_weeks") return differenceInCalendarDays(date, new Date()) <= -7;+ if (value === "2_weeks") return differenceInCalendarDays(date, new Date()) <= -14;+ if (value === "1_months") return differenceInCalendarDays(date, new Date()) <= -30;+ }++ if (operator === "after") {+ if (value === "1_weeks") return differenceInCalendarDays(date, new Date()) >= 7;+ if (value === "2_weeks") return differenceInCalendarDays(date, new Date()) >= 14;+ if (value === "1_months") return differenceInCalendarDays(date, new Date()) >= 30;+ if (value === "2_months") return differenceInCalendarDays(date, new Date()) >= 60;+ }+ }++ return false;+};diff --git a/web/helpers/issue.helper.ts b/web/helpers/issue.helper.tsindex 831cb321ef..2af90481df 100644--- a/web/helpers/issue.helper.ts+++ b/web/helpers/issue.helper.ts@@ -1,6 +1,7 @@import { v4 as uuidv4 } from "uuid";import differenceInCalendarDays from "date-fns/differenceInCalendarDays";// helpers+import { getDate } from "./date-time.helper";import { orderArrayBy } from "helpers/array.helper";// typesimport {@@ -157,7 +158,9 @@ export const shouldHighlightIssueDueDate = (// if the issue is completed or cancelled, don't highlight the due dateif ([STATE_GROUPS.completed.key, STATE_GROUPS.cancelled.key].includes(stateGroup)) return false;- const parsedDate = new Date(date);+ const parsedDate = getDate(date);+ if (!parsedDate) return false;+const targetDateDistance = differenceInCalendarDays(parsedDate, new Date());// if the issue is overdue, highlight the due date@@ -168,6 +171,6 @@ export const renderIssueBlocksStructure = (blocks: TIssue[]): IGanttBlock[] =>data: block,id: block.id,sort_order: block.sort_order,- start_date: block.start_date ? new Date(block.start_date) : null,- target_date: block.target_date ? new Date(block.target_date) : null,+ start_date: getDate(block.start_date),+ target_date: getDate(block.target_date),}));diff --git a/web/pages/[workspaceSlug]/projects/[projectId]/pages/[pageId].tsx b/web/pages/[workspaceSlug]/projects/[projectId]/pages/[pageId].tsxindex bee4fc9c72..b7041d7c63 100644--- a/web/pages/[workspaceSlug]/projects/[projectId]/pages/[pageId].tsx+++ b/web/pages/[workspaceSlug]/projects/[projectId]/pages/[pageId].tsx@@ -21,6 +21,7 @@ import { DocumentEditorWithRef, DocumentReadOnlyEditorWithRef } from "@plane/docimport { Spinner } from "@plane/ui";// assets// helpers+import { getDate } from "helpers/date-time.helper";// typesimport { IPage } from "@plane/types";import { NextPageWithLayout } from "lib/types";@@ -282,7 +283,7 @@ const PageDetailsPage: NextPageWithLayout = observer(() => {? {action: archived_at ? unArchivePage : archivePage,is_archived: archived_at ? true : false,- archived_at: archived_at ? new Date(archived_at) : undefined,+ archived_at: archived_at ? getDate(archived_at) : undefined,}: undefined}diff --git a/web/store/cycle.store.ts b/web/store/cycle.store.tsindex ee4842539b..a9058d7ac6 100644--- a/web/store/cycle.store.ts+++ b/web/store/cycle.store.ts@@ -4,6 +4,10 @@ import { isFuture, isPast, isToday } from "date-fns";import set from "lodash/set";import sortBy from "lodash/sortBy";// types+// helpers+import { getDate } from "helpers/date-time.helper";+// mobx+// servicesimport { ICycle, CycleDateCheckData } from "@plane/types";// mobximport { RootStore } from "store/root.store";@@ -118,8 +122,9 @@ export class CycleStore implements ICycleStore {const projectId = this.rootStore.app.router.projectId;if (!projectId || !this.fetchedMap[projectId]) return null;let completedCycles = Object.values(this.cycleMap ?? {}).filter((c) => {- const hasEndDatePassed = isPast(new Date(c.end_date ?? ""));- const isEndDateToday = isToday(new Date(c.end_date ?? ""));+ const endDate = getDate(c.end_date);+ const hasEndDatePassed = endDate && isPast(endDate);+ const isEndDateToday = endDate && isToday(endDate);return c.project_id === projectId && hasEndDatePassed && !isEndDateToday;});completedCycles = sortBy(completedCycles, [(c) => c.sort_order]);@@ -134,7 +139,8 @@ export class CycleStore implements ICycleStore {const projectId = this.rootStore.app.router.projectId;if (!projectId || !this.fetchedMap[projectId]) return null;let upcomingCycles = Object.values(this.cycleMap ?? {}).filter((c) => {- const isStartDateUpcoming = isFuture(new Date(c.start_date ?? ""));+ const startDate = getDate(c.start_date);+ const isStartDateUpcoming = startDate && isFuture(startDate);return c.project_id === projectId && isStartDateUpcoming;});upcomingCycles = sortBy(upcomingCycles, [(c) => c.sort_order]);@@ -149,7 +155,8 @@ export class CycleStore implements ICycleStore {const projectId = this.rootStore.app.router.projectId;if (!projectId || !this.fetchedMap[projectId]) return null;let incompleteCycles = Object.values(this.cycleMap ?? {}).filter((c) => {- const hasEndDatePassed = isPast(new Date(c.end_date ?? ""));+ const endDate = getDate(c.end_date);+ const hasEndDatePassed = endDate && isPast(endDate);return c.project_id === projectId && !hasEndDatePassed;});incompleteCycles = sortBy(incompleteCycles, [(c) => c.sort_order]);diff --git a/web/store/project-page.store.ts b/web/store/project-page.store.tsindex 072605bc34..8a739e4739 100644--- a/web/store/project-page.store.ts+++ b/web/store/project-page.store.ts@@ -73,8 +73,8 @@ export class ProjectPageStore implements IProjectPageStore {const allProjectIds = Object.keys(this.projectPageMap[projectId]);return allProjectIds.sort((a, b) => {- const dateA = new Date(this.projectPageMap[projectId][a].created_at).getTime();- const dateB = new Date(this.projectPageMap[projectId][b].created_at).getTime();+ const dateA = this.projectPageMap[projectId][a].created_at.getTime();+ const dateB = this.projectPageMap[projectId][b].created_at.getTime();return dateB - dateA;});}@@ -84,8 +84,8 @@ export class ProjectPageStore implements IProjectPageStore {if (!projectId || !this.projectArchivedPageMap[projectId]) return [];const archivedPages = Object.keys(this.projectArchivedPageMap[projectId]);return archivedPages.sort((a, b) => {- const dateA = new Date(this.projectArchivedPageMap[projectId][a].created_at).getTime();- const dateB = new Date(this.projectArchivedPageMap[projectId][b].created_at).getTime();+ const dateA = this.projectArchivedPageMap[projectId][a].created_at.getTime();+ const dateB = this.projectArchivedPageMap[projectId][b].created_at.getTime();return dateB - dateA;});}@@ -127,25 +127,21 @@ export class ProjectPageStore implements IProjectPageStore {if (!this.projectPageIds || !projectId) return;const today: string[] = this.projectPageIds.filter((page) =>- isToday(new Date(this.projectPageMap[projectId][page].updated_at))+ isToday(this.projectPageMap[projectId][page].updated_at));const yesterday: string[] = this.projectPageIds.filter((page) =>- isYesterday(new Date(this.projectPageMap[projectId][page].updated_at))+ isYesterday(this.projectPageMap[projectId][page].updated_at));const this_week: string[] = this.projectPageIds.filter((page) => {const pageUpdatedAt = this.projectPageMap[projectId][page].updated_at;- return (- isThisWeek(new Date(pageUpdatedAt)) &&- !isToday(new Date(pageUpdatedAt)) &&- !isYesterday(new Date(pageUpdatedAt))- );+ return isThisWeek(pageUpdatedAt) && !isToday(pageUpdatedAt) && !isYesterday(pageUpdatedAt);});const older: string[] = this.projectPageIds.filter((page) => {const pageUpdatedAt = this.projectPageMap[projectId][page].updated_at;- return !isThisWeek(new Date(pageUpdatedAt)) && !isYesterday(new Date(pageUpdatedAt));+ return !isThisWeek(pageUpdatedAt) && !isYesterday(pageUpdatedAt);});return { today, yesterday, this_week, older };