last changed by Faen · v1.0.0: refactored and hardened existing code, added python support, added man pages and shell completions, added makefile
| #!/bin/sh
doy=$(date +%j | sed 's/^0*//')
y=$(date +%y)
letters="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if [ "$doy" -eq 365 ]; then
printf "%s+00\n" "$y"
elif [ "$doy" -eq 366 ]; then
printf "%s+01\n" "$y"
else
mIndex=$(( (doy - 1) / 14 ))
dom=$(( (doy - 1) % 14 + 1 ))
mChar=$(echo "$letters" | cut -c $((mIndex + 1)))
printf "%s%s%02d\n" "$y" "$mChar" "$dom"
fi
|