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")
Another way scripting in bash kinda sucks: you can’t call off to nice easy to use libraries that make this sort of thing trivial :)
Monday, March 31, 2025
Green Fig into Oro Valley worked quite well. An easy, comfortable shave to start the week and end the month. Congrats again to Catie's Bubbles for the March Madness win!
Have a great day all.
🍳 Created with Neovim & sotd.nvim 🍳