HRScripts

calendargen at trunk
Login

calendargen at trunk

File calendargen artifact 2497ec72e6 on branch trunk


#!/usr/opt/bin/tclsh

if {$argc!=1 || ![string is integer -strict [set N [lindex $argv 0]]] || $N<1
} {puts stderr \
"Usage:
$argv0 num
Outputs to stdout .calendar template with given num of entries per day"
exit}

# Edit this
puts "#include \"/usr/home/user/.calendar/allyears\""

proc mname {num} {
set loc en_US
set date [clock scan 1970-[format %02d $num]-01 -format %Y-%m-%d]
return [string toupper [clock format $date -format %B -locale $loc]]}

set ndays [list 31 31 29 31 30 31 30 31 31 30 31 30 31] ;# 0 = 12 = Dec

for {set m 1} {$m <= 12} {incr m} {
 puts ""
 puts "/* .[format %02d $m]. [mname $m] */"
 puts ""
 set D [lindex $ndays $m]
 for {set d 1} {$d <= $D} {incr d} {
  set M $N
  while {$M} {puts "$m/$d\t% "; incr M -1}
  puts ""
}}