December 04, 2020, 11:12:00 AM

Author Topic: [bb] Get the day of the week by Kevin_ [ 1+ years ago ]  (Read 378 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Get the day of the week by Kevin_ [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
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
  1. ; Get the day of the week example by Prof.
  2. ;
  3. Graphics 640,480,32,2
  4. SetBuffer BackBuffer()
  5.  
  6. Day$=GetDayOfTheWeek(15,04,2004) ; <- Put any date in here
  7.  
  8. Text 10,10,Day$
  9. Flip
  10. WaitKey()
  11. End
  12.  
  13.  
  14. Function GetDayOfTheWeek$(day,month,year)
  15.  ; Returns the day of the week.
  16.  ; day, month & year are integers i.e. 15 04 2004
  17.   a=(14-month)/12
  18.   y=year-a
  19.   m=month+(12*a)-2
  20.   d=(day+y+(y/4)-(y/100)+(y/400)+((31*m)/12))Mod 7  ;Ooouch!
  21.   Select d
  22.     Case 0:Weekday$="Sunday"
  23.     Case 1:Weekday$="Monday"
  24.     Case 2:Weekday$="Tuesday"
  25.     Case 3:Weekday$="Wednesday"
  26.     Case 4:Weekday$="Thursday"
  27.     Case 5:Weekday$="Friday"
  28.     Case 6:Weekday$="Saturday"
  29.     Default:Weekday=""
  30.   End Select
  31.   Return Weekday$
  32. 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">


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal