fix due date off-by-one west of UTC
all six reads now go through one helper, which also handles the ISO stamps Trello imports keep
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { useState, useRef, useEffect, useCallback } from "react";
|
||||
import { Plus } from "lucide-react";
|
||||
import { parse } from "date-fns";
|
||||
import { parseDueDate } from "@/lib/due-date";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import { OverlayScrollbarsComponent, type OverlayScrollbarsComponentRef } from "overlayscrollbars-react";
|
||||
import { staggerContainer } from "@/lib/motion";
|
||||
@@ -97,8 +97,7 @@ export function BoardView() {
|
||||
if (filters.dueDate !== "all") {
|
||||
const now = new Date();
|
||||
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
// dueDate is 'yyyy-MM-dd', which new Date() reads as UTC midnight
|
||||
const due = card.dueDate ? parse(card.dueDate, "yyyy-MM-dd", now) : null;
|
||||
const due = card.dueDate ? parseDueDate(card.dueDate) : null;
|
||||
if (filters.dueDate === "none" && due != null) return false;
|
||||
if (filters.dueDate === "overdue" && (!due || due >= today)) return false;
|
||||
if (filters.dueDate === "today") {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useState, useRef, useEffect } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { format, parse } from "date-fns";
|
||||
import { format } from "date-fns";
|
||||
import { motion, useReducedMotion, AnimatePresence } from "framer-motion";
|
||||
import { fadeSlideUp, springs } from "@/lib/motion";
|
||||
import { parseDueDate } from "@/lib/due-date";
|
||||
import { useSortable } from "@dnd-kit/sortable";
|
||||
import { CSS } from "@dnd-kit/utilities";
|
||||
import type { Card, Label, Priority } from "@/types/board";
|
||||
@@ -26,10 +27,10 @@ import { useBoardStore } from "@/stores/board-store";
|
||||
|
||||
function getDueDateStatus(dueDate: string | null): { color: string; bgColor: string; label: string } | null {
|
||||
if (!dueDate) return null;
|
||||
const dueDay = parseDueDate(dueDate);
|
||||
if (!dueDay) return null;
|
||||
const now = new Date();
|
||||
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
// dueDate is 'yyyy-MM-dd', which new Date() reads as UTC midnight
|
||||
const dueDay = parse(dueDate, "yyyy-MM-dd", now);
|
||||
const diffDays = Math.ceil((dueDay.getTime() - today.getTime()) / (1000 * 60 * 60 * 24));
|
||||
|
||||
if (diffDays < 0) {
|
||||
@@ -92,6 +93,7 @@ export function CardThumbnail({ card, boardLabels, columnId, onCardClick, isFocu
|
||||
}, [isFocused]);
|
||||
|
||||
const hasDueDate = card.dueDate != null;
|
||||
const dueDate = card.dueDate ? parseDueDate(card.dueDate) : null;
|
||||
const dueDateStatus = getDueDateStatus(card.dueDate);
|
||||
|
||||
function handleClick() {
|
||||
@@ -179,12 +181,12 @@ export function CardThumbnail({ card, boardLabels, columnId, onCardClick, isFocu
|
||||
role="img"
|
||||
/>
|
||||
)}
|
||||
{dueDateStatus && card.dueDate && (
|
||||
{dueDateStatus && dueDate && (
|
||||
<span
|
||||
className={`font-mono text-xs rounded px-1 py-0.5 ${dueDateStatus.color} ${dueDateStatus.bgColor}`}
|
||||
aria-label={`Due: ${format(new Date(card.dueDate), "MMM d")} - ${dueDateStatus.label}`}
|
||||
aria-label={`Due: ${format(dueDate, "MMM d")} - ${dueDateStatus.label}`}
|
||||
>
|
||||
{format(new Date(card.dueDate), "MMM d")}
|
||||
{format(dueDate, "MMM d")}
|
||||
</span>
|
||||
)}
|
||||
{card.checklist.length > 0 && (
|
||||
|
||||
@@ -5,6 +5,7 @@ import { LabelDots } from "@/components/board/LabelDots";
|
||||
import { ChecklistBar } from "@/components/board/ChecklistBar";
|
||||
import { format, isPast, isToday } from "date-fns";
|
||||
import { springs } from "@/lib/motion";
|
||||
import { parseDueDate } from "@/lib/due-date";
|
||||
|
||||
interface CardOverlayProps {
|
||||
card: Card;
|
||||
@@ -13,7 +14,7 @@ interface CardOverlayProps {
|
||||
|
||||
export function CardOverlay({ card, boardLabels }: CardOverlayProps) {
|
||||
const hasDueDate = card.dueDate != null;
|
||||
const dueDate = hasDueDate ? new Date(card.dueDate!) : null;
|
||||
const dueDate = card.dueDate ? parseDueDate(card.dueDate) : null;
|
||||
const overdue = dueDate != null && isPast(dueDate) && !isToday(dueDate);
|
||||
|
||||
const rotate = useMotionValue(0);
|
||||
|
||||
@@ -2,6 +2,7 @@ import { format, formatDistanceToNow, isPast, isToday } from "date-fns";
|
||||
import { X } from "lucide-react";
|
||||
import { useBoardStore } from "@/stores/board-store";
|
||||
import { CalendarPopover } from "@/components/card-detail/CalendarPopover";
|
||||
import { parseDueDate } from "@/lib/due-date";
|
||||
|
||||
interface DueDatePickerProps {
|
||||
cardId: string;
|
||||
@@ -11,7 +12,7 @@ interface DueDatePickerProps {
|
||||
export function DueDatePicker({ cardId, dueDate }: DueDatePickerProps) {
|
||||
const updateCard = useBoardStore((s) => s.updateCard);
|
||||
|
||||
const dateObj = dueDate ? new Date(dueDate) : null;
|
||||
const dateObj = dueDate ? parseDueDate(dueDate) : null;
|
||||
const overdue = dateObj != null && isPast(dateObj) && !isToday(dateObj);
|
||||
|
||||
function handleSelect(date: Date) {
|
||||
|
||||
Reference in New Issue
Block a user