summaryrefslogtreecommitdiff
path: root/config/eww/scripts/day_format.sh
blob: a3e715af615a0ae0a4c2a039afe180a756c8474a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh
day_of_month=$(date +"%d")
day_of_month=$(echo $day_of_month | sed 's/^0*//')
if [[ $day_of_month -ge 11 && $day_of_month -le 13 ]]; then
    suffix="th"
else
    case $((day_of_month % 10)) in
        1) suffix="st" ;;
        2) suffix="nd" ;;
        3) suffix="rd" ;;
        *) suffix="th" ;;
    esac
fi
echo "${day_of_month}${suffix}"