diff --git a/client/components/MobileTrackerRow.jsx b/client/components/MobileTrackerRow.jsx index bb84375..b583f80 100644 --- a/client/components/MobileTrackerRow.jsx +++ b/client/components/MobileTrackerRow.jsx @@ -1,7 +1,7 @@ import React, { useMemo, useRef, useState } from 'react'; import { AlertCircle, Pencil, Settings2 } from 'lucide-react'; import { toast } from 'sonner'; -import { cn, fmt, fmtDate } from '@/lib/utils'; +import { cn, fmt, fmtDate, localDateString } from '@/lib/utils'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { StatusBadge } from './StatusBadge'; @@ -24,7 +24,7 @@ const ROW_STATUS_CLS = { function paymentDateForTrackerMonth(year, month, dueDay) { const now = new Date(); if (year === now.getFullYear() && month === now.getMonth() + 1) { - return fmtDate(new Date().toISOString().slice(0, 10)); + return localDateString(); } const daysInMonth = new Date(year, month, 0).getDate(); diff --git a/client/components/tracker/OverdueCommandCenter.jsx b/client/components/tracker/OverdueCommandCenter.jsx index 0f850e3..2cbf141 100644 --- a/client/components/tracker/OverdueCommandCenter.jsx +++ b/client/components/tracker/OverdueCommandCenter.jsx @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import { AlertCircle, ChevronDown, BellOff, SkipForward, CreditCard } from 'lucide-react'; import { toast } from 'sonner'; import { api } from '@/api.js'; -import { cn, fmt } from '@/lib/utils'; +import { cn, fmt, localDateString } from '@/lib/utils'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '@/components/ui/collapsible'; @@ -16,7 +16,7 @@ import { function snoozeUntil(days) { const d = new Date(); d.setDate(d.getDate() + days); - return d.toISOString().slice(0, 10); + return localDateString(d); } function daysOverdueLabel(dueDate) { @@ -142,7 +142,7 @@ function OverdueRow({ row, year, month, onPayNow, onRefresh }) { } export default function OverdueCommandCenter({ rows, year, month, refresh, onPayNow }) { - const todayStr = new Date().toISOString().slice(0, 10); + const todayStr = localDateString(); const [isOpen, setIsOpen] = useState(true); const overdueRows = rows.filter(r => diff --git a/client/lib/utils.js b/client/lib/utils.js index caf08c3..60cb252 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -15,8 +15,15 @@ export function fmtDate(dateStr) { return `${parseInt(m)}/${parseInt(d)}/${y}`; } +export function localDateString(date = new Date()) { + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + return `${year}-${month}-${day}`; +} + export function todayStr() { - return new Date().toISOString().slice(0, 10); + return localDateString(); } export function fmtUptime(seconds) { diff --git a/client/pages/SubscriptionsPage.jsx b/client/pages/SubscriptionsPage.jsx index 6071b8f..7f30cb8 100644 --- a/client/pages/SubscriptionsPage.jsx +++ b/client/pages/SubscriptionsPage.jsx @@ -25,7 +25,7 @@ import { X, } from 'lucide-react'; import { api } from '@/api'; -import { cn, fmt, fmtDate } from '@/lib/utils'; +import { cn, fmt, fmtDate, localDateString } from '@/lib/utils'; import { scheduleLabel } from '@/lib/billingSchedule'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; @@ -125,7 +125,7 @@ function subscriptionNextDueDate(item, now = new Date()) { date = new Date(date.getFullYear(), date.getMonth() + step, dueDay); } } - return date.toISOString().slice(0, 10); + return localDateString(date); } function decorateSavedSubscriptionBill(bill, categories) { diff --git a/client/pages/TrackerPage.jsx b/client/pages/TrackerPage.jsx index 2ca93b4..c40b177 100644 --- a/client/pages/TrackerPage.jsx +++ b/client/pages/TrackerPage.jsx @@ -8,7 +8,7 @@ import { useSearchPanelPreference } from '@/hooks/useSearchPanelPreference'; import BillModal from '@/components/BillModal'; import { makeBillDraft } from '@/lib/billDrafts'; import { scheduleLabel, scheduleValue } from '@/lib/billingSchedule'; -import { cn, fmt } from '@/lib/utils'; +import { cn, fmt, localDateString } from '@/lib/utils'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import SearchFilterPanel from '@/components/SearchFilterPanel'; @@ -54,13 +54,6 @@ function fmtBalanceAge(isoStr) { return parseUtc(isoStr).toLocaleString(undefined, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }); } -function localDateString(date = new Date()) { - const year = date.getFullYear(); - const month = String(date.getMonth() + 1).padStart(2, '0'); - const day = String(date.getDate()).padStart(2, '0'); - return `${year}-${month}-${day}`; -} - function settingEnabled(value, fallback = true) { if (value === undefined || value === null || value === '') return fallback; return value === true || value === 'true';