[object Object]

← back to Commercialrealestate

condos viewer: DRY date rendering into fmtDateTime/dateTimeSpan — fix modal date-only regression (Cody gate), guard Invalid Date, ISO in title everywhere

e0227f6c8017adc420cfee0baad24e07461a7a5e · 2026-08-03 09:38:52 -0700 · Steve Abrams

Files touched

Diff

commit e0227f6c8017adc420cfee0baad24e07461a7a5e
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon Aug 3 09:38:52 2026 -0700

    condos viewer: DRY date rendering into fmtDateTime/dateTimeSpan — fix modal date-only regression (Cody gate), guard Invalid Date, ISO in title everywhere
---
 public/condos.html | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/public/condos.html b/public/condos.html
index 8708870..8f79531 100644
--- a/public/condos.html
+++ b/public/condos.html
@@ -216,13 +216,19 @@ function reinitResize(){
   delete tbl.dataset.crDone; tbl.style.tableLayout=''; tbl.style.width='';
   if(window.ColResize && window.ColResize.refresh) window.ColResize.refresh();
 }
+// ── one canonical date+time formatter for EVERY surface — card chip, list cell, and
+// detail modal all route through this (Steve HARD rule: created timestamps render date
+// AND time, full ISO in title=). Guards Invalid Date / null → '' so callers hide cleanly. ──
+function fmtDateTime(v){ if(v==null||v==='') return ''; const d=new Date(v); if(isNaN(d)) return ''; return d.toLocaleString(undefined,{year:'numeric',month:'short',day:'numeric',hour:'numeric',minute:'2-digit'}); }
+function isoOf(v){ const d=new Date(v); return isNaN(d)?'':d.toISOString(); }
+function dateTimeSpan(v){ const s=fmtDateTime(v); return s?`<span title="${esc(isoOf(v))}">${esc(s)}</span>`:''; }
 function fval(c,f){ return f.calc?f.calc(c):c[f.k]; }
 function fcell(c,f){ const v=fval(c,f);
   if(f.badge) return statusBadge(c.warrantable_status||c.warrant_signal||'—');
   if(v==null||v==='') return '—';
   if(f.money) return '$'+(+v).toLocaleString()+(f.suf||'');
   if(f.num) return (+v).toLocaleString();
-  if(f.date){ try{ const d=new Date(v); return '<span title="'+esc(d.toISOString())+'">'+d.toLocaleString(undefined,{year:'numeric',month:'short',day:'numeric',hour:'numeric',minute:'2-digit'})+'</span>'; }catch(e){ return '—'; } }
+  if(f.date){ return dateTimeSpan(v)||'—'; }
   return esc(v)+(f.suf||'');
 }
 
@@ -304,10 +310,8 @@ function noteBox(c){
 // record was added, date AND time, visible on the card — not toggle-gated. Mirrors the
 // design-curator .when chip). Full ISO in title=. Falls back to last_seen; hidden if neither.
 function whenChip(c){
-  const t=c.created_at||c.last_seen; if(!t) return '';
-  const d=new Date(t); if(isNaN(d)) return '';
-  const s=d.toLocaleString(undefined,{year:'numeric',month:'short',day:'numeric',hour:'numeric',minute:'2-digit'});
-  return `<div class="when" title="${esc(d.toISOString())}" style="font-size:10px;color:var(--mut,#8b949e);margin-top:6px">🕓 Added ${esc(s)}</div>`;
+  const t=c.created_at||c.last_seen; const s=fmtDateTime(t); if(!s) return '';
+  return `<div class="when" title="${esc(isoOf(t))}" style="font-size:10px;color:var(--mut,#8b949e);margin-top:6px">🕓 Added ${esc(s)}</div>`;
 }
 
 // ---- renderers ----
@@ -481,7 +485,7 @@ function openDetail(id){
     +line('Age (yrs)',c.year_built?(NOW_YEAR-c.year_built):'')
     +line('Broker',c.broker_name?`<a class="dl" href="/crcp.html?brokerName=${encodeURIComponent(c.broker_name)}">${esc(c.broker_name)}</a>`:c.broker_name)
     +line('Firm',c.firm_name?`<a class="dl" href="/crcp.html?firm=${encodeURIComponent(c.firm_name)}">${esc(c.firm_name)}</a>`:c.firm_name)
-    +line('Added',c.created_at?(function(){try{return new Date(c.created_at).toLocaleDateString(undefined,{year:'numeric',month:'short',day:'numeric'});}catch(e){return '';}})():'')
+    +line('Added',dateTimeSpan(c.created_at))
     +'</div>'
     +(c.warrant_source?'<div class="src">'+esc(c.warrant_source)+'</div>':'');
 }

← f7b6b05 condos viewer: always-on created date+time chip on cards + d  ·  back to Commercialrealestate  ·  condos viewer: city + firm datums drill to filtered view (no aa830f9 →