#!/usr/local/bin/gentee -r
text  calendar( uint year )
\{ datetime  stime
   stime.setdate( 1, 1, year )
}<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Calendar for year \(stime.year)</TITLE>
<STYLE TYPE="text/css">
<!--
BODY {background: #FFF; font-family: Verdana;}
H1 {text-align: center; margin: 5px;}
TABLE {border: 0; border-spacing: 7px;}
TD {padding: 3px; border: 1px solid; text-align: center;}
#copy {font-size: smaller; text-align: center;}
-->
</STYLE>
</HEAD>
<BODY><H1>\(stime.year)</H1>
<TABLE ALIGN=CENTER>\{ 

   uint i j k month dayofweek firstday
   str  stemp
   
   firstday = firstdayofweek()
   
   dayofweek = stime.dayofweek
   fornum i = 0, 4
   {
      @"\l<TR>"
      fornum j = 1, 4
      {
         month = i * 3 + j
         @"\l<TD>\(nameofmonth( stemp,  month ))
<PRE>"
         fornum k = firstday, firstday + 7
         {
            @"  \( abbrnameofday( stemp, k ).setlen( 2 ))"
         }
         @"  \l"
         @"    ".repeat( ( 7 + dayofweek - firstday ) % 7 )

         uint day = 1
         uint lines
         while day <= daysinmonth( year, month )
         {
            if !dayofweek : @"<FONT COLOR=red>"
            @str( day++ ).fillspacel( 4 )
            if !dayofweek : @"</FONT>"

            dayofweek = ( dayofweek + 1 ) % 7
            if dayofweek == firstday 
            {
               @"  \l"
               lines++
            }
         }
         @"    ".repeat( ( 7 + firstday - dayofweek ) % 7 )

         while lines++ < 7 :  @"  \l"
         @"</PRE>"
      }   
   }
}
</TABLE>
<BR><DIV id="copy">Generated with Gentee Programming Language</DIV>
</BODY></HTML>\!
/*
text  calendar( uint year )
\{ datetime  stime
   stime.setdate( 1, 1, year ) }
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Calendar for year \(stime.year) </TITLE></HEAD>
<BODY BGCOLOR=#FFFFFF><CENTER>
<FONT SIZE=+3 FACE="Verdana"><B>\(stime.year)</B></FONT>
<TABLE BORDER=0 CELLPADDING=10 CELLSPACING=0>
\{ 
   uint i j k month dayofweek firstday
   str  stemp
   
   firstday = firstdayofweek()
   dayofweek = stime.dayofweek
   fornum i = 0, 4
   {
      @"<TR>"
      fornum j = 1, 4
      {
         month = i * 3 + j
         @"<TD WIDTH=33%><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=1 BGCOLOR=#000000 WIDTH=100%><TR><TD BGCOLOR=#FFFFFF ALIGN=CENTER><FONT FACE=\"Verdana\">\(nameofmonth( stemp,  month ))</FONT>
         <PRE>"
         fornum k = firstday, firstday + 7
         {
            @"  \( abbrnameofday( stemp, k ).setlen( 2 ))"
         }
         @"  \l"
         @"    ".repeat( ( 7 + dayofweek - firstday ) % 7 )

         uint day = 1
         uint lines
         while day <= daysinmonth( year, month )
         {
            if !dayofweek : @"<FONT COLOR=#FF0000>"
            @str( day++ ).fillspacel( 4 )
            if !dayofweek : @"</FONT>"

            dayofweek = ( dayofweek + 1 ) % 7
            if dayofweek == firstday 
            {
               @"  \l"
               lines++
            }
         }
         @"    ".repeat( ( 7 + firstday - dayofweek ) % 7 )

         while lines++ < 7 :  @"  \l"
         @"</PRE></TD></TR></TABLE></TD>"
      }   
      @"</TR>"
   }
}
</TR></TABLE>&nbsp;<BR>
Generated with Gentee Programming Language
</BODY></HTML>
\!
*/
func main< main >
{
   str   out
   str   year
   
   congetstr( "Enter a year: ", year )
   out @ calendar( uint( year ))
   out.write( "calendar.htm" )
   shell( "calendar.htm" )
}
