What day is today? Monday? Sunday?

BlitzMax Forums/BlitzMax Programming/What day is today? Monday? Sunday?

anyone know a better way to get it?


'day one for each month (year 1980)  2,5,6,2,4,7,2,5,1,3,6,1
Local base_day:Int[] =[0  ,0,4,5,1,3,6,1,4,0,2,5,0]
Local a:Float
Local months:String ="Jan01 Feb02 Mar03 Apr04 May05 Jun06 Jul07 Aug08 Sep09 Oct10 Nov11 Dec12"

year =Int(Right$(CurrentDate$(),4))
month =Int(Mid$(months,Instr(months,Mid$(CurrentDate$(),4,3))+3,2))
day =Int(Left$(CurrentDate$(),2))


a=(year-1980)/4#
b=(a-(Int a))*4

'+1+1+1+2 normal
'+2+1+1+1 for january, february     
If month>2 Then
	If b=4 Then b=5
Else
	If b>0 Then b:+1
EndIf

b:+day
c=((base_day[month]+(Int a)*5)+b) - (Int(((base_day[month]+(Int a)*5)+b)/7)*7)

Print
Print "Year: "+year+" Month: "+month+" Day: "+day
Print
Print "SUN MON TUE WED THU FRI SAT"
Print Left$("                            ",c*4)+"<*>" 'do you know a better way to tab? like tab(c*4) or spc(c*4)
Print
Print "or..."
Print
If c=0 Then c=6 Else c:-1
Print "MON TUE WED THU FRI SAT SUN"
Print Left$("                            ",c*4)+"<*>"
Print




'-----------------------------------------------------------------
'how many days have the month?
Local maxdays:Int[]=[0   ,31,28,31,30,31,30,31,31,30,31,30,31]
If (year Mod 4)=0 Then maxdays[2]=29

'now you can build a calendar
Print
Print " ---------------------------"
Print " MON TUE WED THU FRI SAT SUN"

'show me the first day
b:-day; c=((base_day[month]+(Int a)*5)+b) - (Int(((base_day[month]+(Int a)*5)+b)/7)*7)

d=0 'day counter
For weeks=0 To 5; line$=""
For days=1 To 7
If weeks*7+days > c And d < maxdays[month] Then
	d:+1; If d=day Then line$:+Right$(" <"+d+">",4) Else line$:+Right$("  "+d+" ",4)
Else
	line$:+"    "
EndIf
Next; Print line$
Next