Skip to content

Instantly share code, notes, and snippets.

@scruss
Created September 26, 2022 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scruss/03d3e4deb9b156eeb5fb6753e5febaa0 to your computer and use it in GitHub Desktop.
Save scruss/03d3e4deb9b156eeb5fb6753e5febaa0 to your computer and use it in GitHub Desktop.
quakerdate.sh - return today's (or a specified) date in Quaker (Society of Friends) customary date format
#!/usr/bin/env bash
# quakerdate - use GNU date to generate Quaker (Society of Friends)
# customary date format. Any args will be passed as the date to print
# scruss, 2022-09
# Mon 26 Sep 2022 -> Second day, the twenty-sixth of ninth month 2022
ordinals=(none First Second Third Fourth Fifth Sixth Seventh Eighth \
Ninth Tenth Eleventh Twelfth Thirteenth Fourteenth \
Fifteenth Sixteenth Seventeenth Eighteenth Nineteenth \
Twentieth Twenty-first Twenty-second Twenty-third \
Twenty-fourth Twenty-fifth Twenty-sixth Twenty-seventh \
Twenty-eighth Twenty-ninth Thirtieth Thirty-first)
datestr="now"
# use any args to specify date other than today
if
[ $# -ge 0 ]
then
datestr="$*"
fi
# read values with leading zeroes removed
read -r dow dom mon year < <(date --date="$datestr" +"%w %d %m %Y" |\
sed 's/ 0/ /g;')
# date %w returns 0-6 and we want 1-7. Also lowercase later ordinals
echo "${ordinals[$((dow + 1))]}" "day, the" "${ordinals[$dom],}" "of" \
"${ordinals[$mon],}" "month" "$year"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment