I didn't bother to localize "week" in the header.
Unicode line and bold format may not work in some consoles.
Code: Select all
#!/bin/bash
DW=$(date +%w) # day of week
CW=$(date +%U) # week number of today since year start
SW=$(date -d "tomorrow $(date +%d) days ago" +%U) # week number of 1st day of month since year start
MW=$((CW-SW+1)) # week number of today since month start
sunday=$(date -d "$(date +%u) days ago" +%F) # date of current week's sunday (= first date in line)
date +"%B %Y, week $MW%n──────────────────────────"
echo $(
for i in {0..6}; do
date -d "$sunday + $i day" +%a
done
)
for i in {0..6}; do
((i!=DW))&& format="${format}%3d " || format="${format}\e[1;41;97m%3d\e[0m "
done
printf "$format" $(
for i in {0..6}; do
date -d "$sunday + $i day" +%d
done
)