Calendar

Rivet comes with a Calendar package that provides 3 classes for printing calendar tables in various forms.

The Calendar class prints ascii calendar tables

package require Calendar

set c [Calendar #auto]
set c_txt [$c emit]
puts $c_txt
      Jul 2010
 Su Mo Tu We Th Fr Sa 
              1  2  3
  4  5  6  7  8  9 10
 11 12 13 14 15 16 17
 18 19 20 21 22 23 24
 25 26 27 28 29 30 31

When it comes to writing web pages HtmlCalendar is much fancier than Calendar. HtmlCalendar allows output customization of the cal table by controlling the markup and its attributes.

package require Calendar

proc ::cal_cell_attributes { day month year weekday } {
    if {$weekday == 3} {
        return [list class curr_wkday]
    }
}

set htmlc [HtmlCalendar #auto]
set html_txt [$htmlc emit -container {table class calendar} -current_weekday 3 \
                          -cell_function cal_cell_attributes ]
puts $html_txt

with some CSS styling would print

Almost the whole HTML of HtmlCalendar can be customized. See the manual page for package Calendar for further reading

Last Modified: 28-11-2018 15:39:22 UTC
Design downloaded from free website templates.