﻿# INVESTIGATION.md
Date: 2025-10-04
Feature: Messaging - Add Date Display
Type: Enhancement

## ISSUE DESCRIPTION
Messages currently only show time (e.g., "7:11:44 AM") without the date.
Users cannot distinguish messages from today vs. previous days.

## CURRENT BEHAVIOR
- Displays: timestamp only (toLocaleTimeString)
- Example: "7:11:44 AM"
- No indication of which day the message was sent

## DESIRED BEHAVIOR
- Show date for messages not from today
- Options:
  1. Always show date + time (e.g., "Oct 4, 2025 7:11:44 AM")
  2. Smart display: "Today 7:11 AM" / "Yesterday 7:11 AM" / "Oct 2, 7:11 AM"
  3. Group messages by date with headers

## INVESTIGATION FINDINGS
(To be filled after checking current code)

## INVESTIGATION FINDINGS

### Current Implementation (Line ~280)
\\\javascript
const timestamp = new Date(msg.created_at).toLocaleTimeString();
\\\

### What API Provides
- Field: \created_at\ (ISO format string)
- Example: "2025-10-04T07:11:44.000Z"
- Contains: Full date and time information

### Technical Approach
Create helper function to format timestamps smartly:
- Check if message is from today  show time only
- Check if from yesterday  show "Yesterday HH:MM AM/PM"
- Older messages  show "MMM D, HH:MM AM/PM"

### Files to Modify
- app/templates/messages/chat.html (line ~280)
- Add formatMessageTimestamp() function

### No Backend Changes Needed
API already returns full timestamp with date.
