Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Challenge: Compute the number of Tuesdays since a given date
#12
Let me trya again

The parameters are year, month, day, ut (universal time zone my is GMT-3 so is -3, in GMT is 0 Big Grin ).

When i put fix(a) i mean it to be the greatest integer less than a. Ej. 1.34 -> 1, -2.3 -> -3, 1.75 -> 1, -2.7 -> -3.

I tune my programin knowing that may 25th of 1810 was friday. Then i try current date and my birthday date.

Code:
a#  = JulianDate#(2004, 6, 11, 0) '-> current date is friday
b# = JulianDate#(1900, 1, 1, 0) '-> date to test
d& = FIX(a# - b#) ' -> days elapsed
PRINT "January 1th, 1900 was ";
SELECT CASE d& MOD 7 ' -> we get day of the week
  CASE 0: PRINT "friday" '-> same day of the week
  CASE 1: PRINT "thursday" '-> b is the day after so b is thursday
  CASE 2: PRINT "wednesday" '-> and so on
  CASE 3: PRINT "tuesday"
  CASE 4: PRINT "monday"
  CASE 5: PRINT "sunday"
  CASE 6: PRINT "saturday"
END SELECT

Google "julian date" and pick up Eric Weisstein's world of astronomy. I dont know why the link doesnt work i copy from the address bar :???:.

I think it should work.
Reply


Messages In This Thread
Challenge: Compute the number of Tuesdays since a given date - by xhantt - 06-11-2004, 08:58 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)