Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is pretty clever and I admire the author for coming up with an elegant way to show the mapping of week days to dates. I'd be particularly interested to see the algorithm behind it. Date computations are very tricky.

A few years ago I made script to generate a one page calendar because the ones they hand out at work are particularly ugly. In addition to showing the date<->weekday mapping I also wanted it to show holidays and pay periods. This is one of the (few) things stuck on my wall.

https://intrepidhero.gitlab.io/mkcal/cal2020.html

https://gitlab.com/intrepidhero/mkcal



Generate grid (it's static);

Find first weekday of month using your favourite algorithm;

Print month's name above the column that begins with that weekday.


favourite algorithm is left as an exercise to the reader. ;-)


Favorite algorithm can be as simple as "look at the first day of each month on a normal calendar".


Date computations like this are not at all tricky.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: