REBOL [
	Title: "HTML calendar"
	Date: 3-Dec-2003
	Author: "Bohdan Lechnowsky"
	File: %html-calendar.r
	Purpose: {
		Creates an HTML file containing the current calendar month and displays it in
		the browser
	}
	Library: [
		level: 'intermediate
		platform: 'all
		type: []
		domain: [html web]
		tested-under: none
		support: none
		license: none
		see-also: none
	]
]

date: now/date
colwidth: 100
dayrowcol: "806080"
daytextcol: "FFFFFF"
wkendcol: "FFCCCC"
wkdaycol: "FFFFFF"
notthismonthcol: "808080"
outfilename: %month.html

html: copy rejoin [{}]

days: head remove back tail insert head copy system/locale/days last system/locale/days

foreach day days [
	append html rejoin [{}]
]

append html {}

sdate: date
sdate/day: 0

loop sdate/weekday // 7 + 1 [append html {}]

while [sdate/day: sdate/day + 1 sdate/month = date/month][
	append html rejoin [
		{}
	]
	if sdate/weekday = 6 [append html {}]
]

loop 7 - sdate/weekday [append html rejoin [{}]]

append html {
} pick system/locale/months date/month { } date/year {
} copy/part day 3 {
} sdate/day {
} write outfilename html browse outfilename