TGC Codebase Backup



Function returning day of the week by Rich Dersheimer

25th Apr 2017 18:45
Summary

Send it a date in YYYY-MM-DD format, it returns the day of the week for that date. Written in AGK2.



Description

Wow, this code base really doesn't work so well. The code is all one line.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    // returns the day of the week, date$ is YYYY-MM-DD format
function DayOfWeek(date$)
	Seconds=GetUnixFromDate(Val(Left(date$,4)),Val(Mid(date$,6,2)),Val(Right(date$,2)),0,0,0)
	Day = mod(Seconds/86400,7)
	select Day
		case 0
			Day$ = "Thursday"
		endcase
		
		case 1
			Day$ = "Friday"
		endcase
		
		case 2
			Day$ = "Saturday"
		endcase
		
		case 3
			Day$ = "Sunday"
		endcase
		
		case 4
			Day$ = "Monday"
		endcase
		
		case 5
			Day$ = "Tuesday"
		endcase
		
		case 6
			Day$ = "Wednesday"
		endcase		
	endselect  
endfunction Day$