[bb] Get the day of the week by Kevin_ [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:40

Previous topic - Next topic

BlitzBot

Title : Get the day of the week
Author : Kevin_
Posted : 1+ years ago

Description : Short function to work out the day of the week based on a numerical date.

Code :
Code (blitzbasic) Select
; Get the day of the week example by Prof.
;
Graphics 640,480,32,2
SetBuffer BackBuffer()

Day$=GetDayOfTheWeek(15,04,2004) ; <- Put any date in here

Text 10,10,Day$
Flip
WaitKey()
End


Function GetDayOfTheWeek$(day,month,year)
 ; Returns the day of the week.
 ; day, month & year are integers i.e. 15 04 2004
  a=(14-month)/12
  y=year-a
  m=month+(12*a)-2
  d=(day+y+(y/4)-(y/100)+(y/400)+((31*m)/12))Mod 7  ;Ooouch!
  Select d
    Case 0:Weekday$="Sunday"
    Case 1:Weekday$="Monday"
    Case 2:Weekday$="Tuesday"
    Case 3:Weekday$="Wednesday"
    Case 4:Weekday$="Thursday"
    Case 5:Weekday$="Friday"
    Case 6:Weekday$="Saturday"
    Default:Weekday=""
  End Select
  Return Weekday$
End Function


Comments :


Rafery(Posted 1+ years ago)

 thanks Prof


virtlands(Posted 1+ years ago)

 That 'Day of the Week' code adds a nice touch to any program thanks to the professor.This was posted 9 years ago; I wonder if that professor is still around.  ?[img]imagizer.imageshack.us/a/img705/2383/theprofessor86x132.html">