1 /******************************************************************************
2 *
3 * Copyright (C) 2005, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * ID: calendar 17.10.06 0.0.A.
11 *
12 * Author: Alexey Krivonogov ( gentee )
13 *
14 ******************************************************************************/
15
16 text calendar( uint year )
17 \{ datetime stime
18 stime.setdate( 1, 1, year )
19 }<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
20 <HTML><HEAD><TITLE>Calendar for year \(stime.year)</TITLE>
21 <STYLE TYPE="text/css">
22 <!--
23 BODY {background: #FFF; font-family: Verdana;}
24 H1 {text-align: center; margin: 5px;}
25 TABLE {border: 0; border-spacing: 7px;}
26 TD {padding: 3px; border: 1px solid; text-align: center;}
27 #copy {font-size: smaller; text-align: center;}
28 -->
29 </STYLE>
30 </HEAD>
31 <BODY><H1>\(stime.year)</H1>
32 <TABLE ALIGN=CENTER>\{
33
34 uint i j k month dayofweek firstday
35 str stemp
36
37 firstday = firstdayofweek()
38 dayofweek = stime.dayofweek
39 fornum i = 0, 4
40 {
41 @"\l<TR>"
42 fornum j = 1, 4
43 {
44 month = i * 3 + j
45 @"\l<TD>\(nameofmonth( stemp, month ))
46 <PRE>"
47 fornum k = firstday, firstday + 7
48 {
49 @" \( abbrnameofday( stemp, k ).setlen( 2 ))"
50 }
51 @" \l"
52 @" ".repeat( ( 7 + dayofweek - firstday ) % 7 )
53
54 uint day = 1
55 uint lines
56 while day <= daysinmonth( year, month )
57 {
58 if !dayofweek : @"<FONT COLOR=red>"
59 @str( day++ ).fillspacel( 4 )
60 if !dayofweek : @"</FONT>"
61
62 dayofweek = ( dayofweek + 1 ) % 7
63 if dayofweek == firstday
64 {
65 @" \l"
66 lines++
67 }
68 }
69 @" ".repeat( ( 7 + firstday - dayofweek ) % 7 )
70
71 while lines++ < 7 : @" \l"
72 @"</PRE>"
73 }
74 }
75 }
76 </TABLE>
77 <BR><DIV id="copy">Generated with Gentee Programming Language</DIV>
78 </BODY></HTML>\!
79
80 func main< main >
81 {
82 str out
83 str year
84
85 congetstr( "Enter a year: ", year )
86 out @ calendar( uint( year ))
87 out.write( "calendar.htm" )
88 shell( "calendar.htm" )
89 }
90
Редактировать