Skip to main content
← Back to Blog

The Markdown File That Teaches AI How to Handle Dates

Stop getting inconsistent date formatting from Claude and GPT

Z

ZVN

·7 min read
#ai#typescript#developer-experience

Every time you ask an AI assistant to write code that displays a date, you're playing format roulette:

// Attempt #1
const date = new Date(timestamp).toLocaleDateString()

// Attempt #2
const date = format(timestamp, 'yyyy-MM-dd')

// Attempt #3
const date = moment(timestamp).format('MMM D, YYYY')

The AI is guessing. It doesn't know your project conventions.

There's a simple fix: tell it.

The Whenny-Dates-Agents.md File

When you initialize Whenny, it generates a markdown file specifically designed for AI consumption:

# Date Handling Guide for AI Agents

This project uses **Whenny** for all date formatting.
Import from `@/lib/whenny` (NOT moment, dayjs, or date-fns).

## Quick Reference

| Use Case | Code | Output |
|----------|------|--------|
| Card dates | `whenny(date).sm` | "Feb 6" |
| Full dates | `whenny(date).lg` | "February 6th, 2024" |
| Timestamps | `whenny(date).relative()` | "5m ago" |

## DO NOT
- Import from moment, dayjs, or date-fns
- Use new Date().toLocaleDateString()
- Write custom format strings

Why This Works

AI assistants read your project files for context. When they encounter a task involving dates, they'll find this file, read your conventions, and generate matching code.

Before (Without the Guide)

Claude generates: format(post.createdAt, 'MMMM d, yyyy')

After (With the Guide)

Claude generates: whenny(post.createdAt).md

Consistent with your existing codebase. Every time.


Next up: The timestamp trap - why your calendar component shows the wrong date.