home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / Programme_zum_Heft / Programmieren / Kurztests / ACE / Prgs / ShellUtils / day.b < prev    next >
Text File  |  1994-01-10  |  765b  |  50 lines

  1. '..Compute the day of the week for dates after 
  2. '..the start of the Gregorian Calendar.
  3.  
  4. shortint d,m,y
  5. dim dy$(7)
  6.  
  7. for i=1 to 7
  8.  read dy$(i)
  9. next
  10.  
  11. data Sunday,Monday,Tuesday,Wednesday
  12. data Thursday,Friday,Saturday
  13.  
  14. if argcount<>3 then
  15.   print "usage: day dd mm yyyy"
  16.   stop
  17. else
  18.   d=val(arg$(1))
  19.   m=val(arg$(2))
  20.   y=val(arg$(3))
  21. end if
  22.  
  23. if d < 1 or d > 31 then
  24.   print "The day must be from 1 to 31."
  25.   stop
  26. end if
  27.  
  28. if m < 1 or m > 12 then
  29.   print "The month must be from 1 to 12."
  30.   stop
  31. end if
  32.  
  33. if y <= 1582 then
  34.   print "The year must be after 1582."
  35.   stop
  36. end if
  37.  
  38. '..calculate day
  39. k=int(0.6+(1/m))
  40. l=y-k
  41. o=m+12*k
  42. p=l/100
  43. z1=int(p/4)
  44. z2=int(p)
  45. z3=int((5*l)/4)
  46. z4=int(13*(o+1)/5)
  47. z=z4+z3-z2+z1+d-1
  48. z=z-(7*int(z/7))+1
  49. print "The day of the week is ";dy$(z);"."
  50.