Home

cal2html: Simple HTML calendar generator for Linux

If you want to make a simple month calendar in your Web pages, you can use the following program which is a ‘post-processor’ for the Linux cal command. Usage:

cal [month year] | cal2html [ > myfile ]

Calendars can be made in various languages by preceding this command with a LANG directive. E.g. the following command creates a French (UTF-8 coded) HTML calendar for August, 1848 (if you do not specify month and year, the calendar will be for the current month):

LANG=fr_FR.UTF-8 cal 8 1848 | cal2html 

This generates HTML code which is displayed in a browser like this:

Août 1848
dilumamejevesa
1 2 3 4 5
6 7 8 9101112
13141516171819
20212223242526
2728293031

I’m glad cal has this multilingual capability because I needed it for my wife’s Japanese blog. The ‘locale’ for the language you want to use must, of course, be installed on your system.

All formatting of the table (colours, alignment, font …) must be done in CSS. The cal2html program itself only produces the most basic HTML.

This is the source code of the program: cal2html.c. This could be done much easier in perl, I suppose, but I happen to be more familiar with C. Compile it with cc -o cal2html cal2html.c and then do as root: mv cal2html /usr/local/bin.

Home