diff --git a/public/js/utils/helpers.js b/public/js/utils/helpers.js index 7aadfef..ec4d9b8 100644 --- a/public/js/utils/helpers.js +++ b/public/js/utils/helpers.js @@ -4,11 +4,10 @@ */ export function formatDate(date) { - const d = new Date(date); - const month = String(d.getMonth() + 1).padStart(2, '0'); - const day = String(d.getDate()).padStart(2, '0'); - const year = d.getFullYear(); - return `${month}/${day}/${year}`; + if (!date) return '—'; + const parts = String(date).split('T')[0].split('-'); + if (parts.length !== 3) return String(date); + return `${parts[1]}/${parts[2]}/${parts[0]}`; } export function setDefaultDate() { diff --git a/public/js/views/accounting-view.js b/public/js/views/accounting-view.js index 573968d..af958c7 100644 --- a/public/js/views/accounting-view.js +++ b/public/js/views/accounting-view.js @@ -881,7 +881,8 @@ function renderTaxPeriodsTable() { else if (pStatus === 'external' || pStatus === 'paid') { statusHtml = 'Paid'; statusColor = 'bg-green-100 text-green-800'; } else { statusHtml = 'Open'; statusColor = 'bg-yellow-100 text-yellow-800'; } - const monthLabel = new Date(p.period_start).toLocaleDateString('en-US', { year: 'numeric', month: 'long' }); + const [py, pm] = String(p.period_start).split('T')[0].split('-'); + const monthLabel = new Date(Number(py), Number(pm) - 1).toLocaleDateString('en-US', { year: 'numeric', month: 'long', timeZone: 'UTC' }); const adj = parseFloat(p.adjustment_amount) || 0; const adjStr = adj !== 0 ? (adj > 0 ? `−$${adj.toFixed(2)}` : `+$${Math.abs(adj).toFixed(2)}`) : '—'; const netPaid = parseFloat(p.net_paid) || parseFloat(p.tax_collected) || 0; @@ -970,7 +971,7 @@ async function openTaxPeriodDetail(startDate, endDate, existingPeriod) { const today = todayISO(); const [y, m] = startDate.split('-').map(Number); - const monthLabel = new Date(y, m - 1).toLocaleDateString('en-US', { year: 'numeric', month: 'long' }); + const monthLabel = new Date(y, m - 1).toLocaleDateString('en-US', { year: 'numeric', month: 'long', timeZone: 'UTC' }); detailEl.innerHTML = `
diff --git a/src/utils/helpers.js b/src/utils/helpers.js index 09bb0ad..d9745ef 100644 --- a/src/utils/helpers.js +++ b/src/utils/helpers.js @@ -3,11 +3,10 @@ */ function formatDate(date) { - const d = new Date(date); - const month = String(d.getMonth() + 1).padStart(2, '0'); - const day = String(d.getDate()).padStart(2, '0'); - const year = d.getFullYear(); - return `${month}/${day}/${year}`; + if (!date) return '—'; + const parts = String(date).split('T')[0].split('-'); + if (parts.length !== 3) return String(date); + return `${parts[1]}/${parts[2]}/${parts[0]}`; } function formatMoney(val) {