date-calculation — Claude Code rule: what it does, how to install
date-calculation stops the assistant from calculating dates mentally by enforcing system tools like date and python3. Helps avoid arithmetic mistakes on leap years and intervals.
MIT ★ 880 updated 2026-09-03
.claude/rules/date-calculation.mdWhat date-calculation does
Language models regularly hallucinate date arithmetic. This rule blocks mental calculations, forbidding the assistant from guessing weekdays or manual business day intervals.
Every calculation must run through system binaries. The instructions provide platform-specific date commands for macOS and Linux to handle offsets, while directing complex duration arithmetic to python3 one-liners using datetime.
What it helps with
- find the weekday for a specific date via the date utility
- calculate day intervals between two dates using python3
- determine target dates N days in the future or past
- prevent arithmetic hallucinations around leap years and month ends
Example prompts for the agent
- Find out what day of the week March 15, 2026 falls on.
- Calculate the number of days between February 6, 2026 and December 31, 2026.
- Show me the date exactly 30 days from today.
How to install date-calculation
Manually: put the files in place
.claude/rules/date-calculation.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/date-calculation.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/date-calculation.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/date-calculation.mdManually: put the files in place
.clinerules/date-calculation.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about date-calculation
How do I install date-calculation in Claude Code?
Create the file at .claude/rules/date-calculation.md inside your repository and add the rule contents.
What does date-calculation do?
It forces Claude Code to run terminal commands like date or python3 for calendar math instead of doing arithmetic in memory.
Which tools are required for date calculations under this rule?
The rule relies on the system date utility across macOS and Linux, as well as python3 with the standard datetime module for multi-date spans.
Source text
date-calculation.md · MIT
# Date & Time Calculation (CRITICAL)
## Absolute Rule
NEVER calculate dates/times mentally. ALWAYS use system tools.
LLMs frequently make errors in date arithmetic. Use Bash or Python for ALL date calculations: day-of-week, durations, D-day, leap years, month-end, etc.
## Required Patterns
### Current Date/Time
```bash
date '+%Y-%m-%d %A %H:%M:%S %Z'
```
### Day of Week (macOS)
```bash
date -j -f '%Y-%m-%d' '2026-03-15' '+%A'
```
### Day of Week (Linux)
```bash
date -d '2026-03-15' '+%A'
```
### N Days From Now (macOS)
```bash
date -j -v+30d '+%Y-%m-%d %A' # 30 days later
date -j -v-7d '+%Y-%m-%d %A' # 7 days ago
```
### N Days From Now (Linux)
```bash
date -d '+30 days' '+%Y-%m-%d %A' # 30 days later
date -d '-7 days' '+%Y-%m-%d %A' # 7 days ago
```
### Complex Date Calculations (Python)
```bash
python3 -c "
from datetime import datetime, timedelta
# Days between two dates
d1 = datetime(2026, 2, 6)
d2 = datetime(2026, 12, 31)
print(f'{(d2-d1).days} days')
"
```
## Forbidden
- Mental arithmetic for dates
- Guessing day-of-week
- Manual business day calculations
## Required
- Always use `date` command or `python3`
© sangrokjung · MIT · sangrokjung/claude-forge