by s0fasurfa · 1y ago · 0 comments
If you want to follow UNIX philosophy, why don't you write an augmenter/converter tool `caug` that adds "computed" information such as week number, weekday or even relative date?
> cat calendar-src.txt
2025
====
03-01 9-12 project groups
> cat calendar-src.txt | caug
2025-03-01 w09 09:00-12:00 project groups +tomorrow
+thisweek
> cat calendar-src.txt | caug | grep "thisweek"
2025-03-01 w09 09:00-12:00 project groups +tomorrow
+thisweekWith some traditional GUI calendar software, I was often hunting and miscopying week numbers. Some software also had a weird (non ISO-8601) idea of week numbers.
In case you need calendar.txt after 2033, I wrote a small tool [2] to generate more templates.
[1] https://terokarvinen.com/2021/calendar-txt/calendar-txt-unti...
[2] https://terokarvinen.com/2021/calendar-txt/calendartxt-gener...
usage: weeks YYYY-MM-DD YYYY-MM-DD
weeks () {
one_day=$((60 * 60 * 24))
unix_from=$(date +%s --date="$1")
unix_to=$(date +%s --date="$2")
while [ $unix_from -lt $unix_to ]
do
echo @$unix_from
unix_from=$((unix_from + one_day))
done | date +'%F w%V %a' -f -
unset -v one_day unix_from unix_to
}
seriously, what's a compressed 1.2MB small tool?Static binaries generated by Go are indeed large, even if the source code here is under 30 lines with support to some additional minor features (US and Finnish day names, command line help, optional week headings, day counts and parameter handling).
Here are some more scripts to generate calendar.txt date format: