#!/usr/bin/env bash if [[ -z "$1" ]]; then cat << EOF reldate - Format or adjust dates Usage: reldate Examples: reldate "2025-12-12" # Output: 2025-12-12 reldate "+1d" # Output: tomorrow's date reldate "-1w" # Output: date 1 week ago reldate "+2m" # Output: date 2 months from now reldate "-1y" # Output: date 1 year ago Adjustments: d = days, w = weeks, m = months, y = years Use + for future, - for past EOF exit 1 fi if [[ "$1" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then date -j -f "%Y-%m-%d" "$1" "+%Y-%m-%d" 2>/dev/null || echo "Invalid date: $1" else date -v "$1" "+%Y-%m-%d" fi