Comment on Monday SOTD Thread, March 31, 2025 (#657)

<- View Parent
snooting@sub.wetshaving.social ⁨1⁩ ⁨week⁩ ago

Something like this would probably work (untested):

# Get the day of month as a number
day=$(date +%-d)

# Determine the correct suffix
case $day in
    1|21|31) suffix="st";;
    2|22) suffix="nd";;
    3|23) suffix="rd";;
    *) suffix="th";;
esac

# Print the date with the ordinal suffix
formatted_date=$(date +"%B %-d$suffix, %Y")

source
Sort:hotnewtop