Clicky

20171116

Month calendar with vertical outlined weeks

VBscript is still boo, boo but some things are really simple to build in VBscript. Here is a calendar program with vertical outlined weeks, week numbers and even consideration for leap years (until the year 2100).

Use:

 C:\Scripts\> cscript //nologo calendar.vbs MM-YYYY

--- 8< ---------------------------------------------

Function Print(s)
    if len(s)=1 then wscript.stdout.write " "
    wscript.stdout.write s & "  "
end Function

Datum        = wscript.arguments(0)
dayOfTheWeek = DatePart("w",datum)
weekNumber   = DatePart("ww",datum, vbSunday ,vbFirstFourDays)
ArrayStart   = dayOfTheWeek - ((dayOfTheWeek -1) * 2)
monthNumber  = Month(Datum)
WeekDays     = Array("Su","Mo","Tu","We","Th","Fr","Sa")
DaysInMonth  = Array(31,28,31,30,31,30,31,31,30,31,30,31)
monthNames   = Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

'--- Adjust values...
if DaysInMonth(monthNumber-1) + (dayOfTheWeek-1) > 35 then NuOfWeeks = 6 else NuOfWeeks = 5
if Year(Datum) mod 4=0 then DaysInMonth(1)=29

wscript.echo vbCrLf & "Calendar of: " & monthNames(monthNumber-1) & "-" & year(Datum) & vbCrLf
'--- Print weeknumbers
Print " "
for w = 0 to (NuOfWeeks-1) : Print (weekNumber + w) : next
wscript.echo ""
for w = 0 to (NuOfWeeks) : Print "--" : next
wscript.echo ""

'--- Print calendar...
Column = 0
for i = ArrayStart to ArrayStart + 6
    Print Weekdays(Column)
    Column = Column + 1
    for j = 0 to 5
        dayNumber = i + (j * 7)
        if (dayNumber >= 1) and (dayNumber <= DaysInMonth(monthNumber-1)) then Print DayNumber else Print " "
    next
    wscript.echo ""
next
 

No comments :

Post a Comment

Real Time Web Analytics