Weekday

Blitz3D Forums/Blitz3D Beginners Area/Weekday

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

you can do it in Blitz aswell :
Dim splitresult$(100)
Dim monthname$(12)
monthname(1)="Jan"
monthname(2)="Feb"
monthname(3)="Mar"
monthname(4)="Apr"
monthname(5)="May"
monthname(6)="Jun"
monthname(7)="Jul"
monthname(8)="Aug"
monthname(9)="Sep"
monthname(10)="Okt"
monthname(11)="Nov"
monthname(12)="Dec"

Dim dayname$(7)
dayname(0)="Monday"
dayname(1)="Tuesday"
dayname(2)="Wednesday"
dayname(3)="Thursday"
dayname(4)="Friday"
dayname(5)="Saturday"
dayname(6)="Sunday"

;first split the currentdate into Day, month and year
split(" ",CurrentDate())

Global SDP_day = splitresult(0)
Global SDP_month = FindMonth(splitresult(1)) ;becaus month is not a number .. convert
Global SDP_year = splitresult(2)

days = weekday(SDP_day,SDP_month,SDP_year)
Print "Day: "+days
Print "Dayname:"+dayname(days)
WaitKey

Function FindMonth(fm$)
  For i=1 To 12
  If fm$=monthname(i) Then Return i
  Next
End Function

Function weekday(d,m,y)
  jd=( 1461 * ( y + 4800 + ( m - 14 ) / 12 ) ) / 4 + ( 367 * ( m - 2 - 12 * ( ( m - 14 ) / 12 ) ) ) / 12 - ( 3 * ( ( y + 4900 + ( m - 14 ) / 12 ) / 100 ) ) / 4 + d - 32075
  Return jd Mod 7
End Function

Function split(seperator$,txt$)
	pos=Instr(txt$,seperator$,1)	
	While (pos)
		splitresult(count)=Left(txt$,pos-Len(seperator))
		
		txt$=Right(txt$,Len(txt$)-pos-Len(seperator)+1)
		pos=Instr(txt$,seperator$,1)
		count=count+1
	Wend
	splitresult(count)=txt$
	
	Return count
End Function