Forty-five 2025 plans, assessments, design scenarios, status reports and superseded business docs move to docs/archive/ (same relative path). Each described a plan or a snapshot as if it were the running system: strict:false, a five-table schema, an "organization" entity, price_sats, a Gemini /api/chat widget, a /auth/forgot-password page, Google Places, building group labels and contract voting flows that never landed. Fixed in place: NAVIGATION_UX_DESIGN.md (referenced by .claude/rules) gains a status note naming what shipped and where; GENERIC_API_HANDLERS.md lists the handler options the code actually takes; datetime_standards.md points at scripts/dev/; CONTRIBUTING.md describes the auto-merge shipping flow. Inbound links repointed (SECURITY.md at the root, SUPABASE_SCHEMA_GUIDE.md for schema). Claude-Session: https://claude.ai/code/session_01PJkbo18cRNXtgPWZN2S9cD Co-authored-by: Claude <noreply@anthropic.com>
3.8 KiB
Date and Time Standards
Created: June 5, 2025 Last Modified: June 5, 2025 Last Modified Summary: Initial creation
Overview
This document outlines the standards for handling dates and times in the OrangeCat project. We provide scripts to ensure consistent date/time usage across the project.
Available Scripts
Node.js Script (scripts/dev/get_current_datetime.js)
This script provides the current date and time in various formats and can be used in Node.js applications.
// Import the datetime utilities
const datetime = require('./scripts/dev/get_current_datetime.js');
// Use the exported values
console.log(datetime.dateOnly); // YYYY-MM-DD
console.log(datetime.timeOnly); // HH:mm:ss
console.log(datetime.fullDateTime); // YYYY-MM-DD HH:mm:ss
console.log(datetime.iso); // ISO format
console.log(datetime.unixTimestamp); // Unix timestamp
Shell Script (scripts/dev/get_current_datetime.sh)
This script provides the current date and time in various formats and can be used in shell scripts.
# Source the script to get the variables
source ./scripts/dev/get_current_datetime.sh
# Use the exported variables
echo $DATE_ONLY # YYYY-MM-DD
echo $TIME_ONLY # HH:mm:ss
echo $FULL_DATETIME # YYYY-MM-DD HH:mm:ss
echo $ISO # ISO format
echo $UNIX_TIMESTAMP # Unix timestamp
Date/Time Formats
-
ISO Format (
YYYY-MM-DDTHH:mm:ss.sssZ)- Used for API responses
- Used for database timestamps
- Example:
2025-06-05T14:30:00.000Z
-
Date Only (
YYYY-MM-DD)- Used for documentation dates
- Used for file naming
- Example:
2025-06-05
-
Time Only (
HH:mm:ss)- Used for time displays
- Used for logging
- Example:
14:30:00
-
Full DateTime (
YYYY-MM-DD HH:mm:ss)- Used for user-facing displays
- Used for logs
- Example:
2025-06-05 14:30:00
-
Unix Timestamp
- Used for calculations
- Used for sorting
- Example:
1749215400
Best Practices
-
Documentation Dates
- Always use the
YYYY-MM-DDformat - Include both creation and last modified dates
- Include a summary of changes
- Always use the
-
API Responses
- Use ISO format for timestamps
- Include timezone information
- Use UTC for consistency
-
Database
- Store timestamps in UTC
- Use ISO format for queries
- Include timezone information
-
User Interface
- Use the user's local timezone
- Format dates according to user's locale
- Show relative time when appropriate
Usage in Documentation
When creating or modifying documentation, use the following format:
**Created**: YYYY-MM-DD
**Last Modified**: YYYY-MM-DD
**Last Modified Summary**: Brief description of changes
Usage in Code
When working with dates in code:
-
JavaScript/TypeScript
import { dateOnly, timeOnly } from './scripts/dev/get_current_datetime.js'; // Use the imported values const createdAt = dateOnly; const lastModified = dateOnly; -
Shell Scripts
source ./scripts/dev/get_current_datetime.sh # Use the exported variables echo "Created: $DATE_ONLY" echo "Last Modified: $DATE_ONLY"
Timezone Handling
-
Server-side
- Always use UTC
- Convert to local time only for display
- Store timezone information with dates
-
Client-side
- Use the user's local timezone
- Convert UTC to local time for display
- Handle daylight saving time changes
Validation
Always validate dates using the following rules:
- Check for valid date format
- Ensure dates are not in the future (unless specifically required)
- Validate timezone information
- Handle invalid dates gracefully
Error Handling
When dealing with dates:
- Always use try-catch blocks
- Provide meaningful error messages
- Log date-related errors
- Handle timezone conversion errors