moving some aliases into dedicated scripts
This commit is contained in:
parent
00b0b76637
commit
f38cccf8f2
4 changed files with 34 additions and 30 deletions
28
home/bin/executable_reldate
Normal file
28
home/bin/executable_reldate
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
cat << EOF
|
||||
reldate - Format or adjust dates
|
||||
|
||||
Usage: reldate <date|adjustment>
|
||||
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue