NEED ALGORITHM TO CALANDAR PRGM TO GIVE WEEK 
Author Message
 NEED ALGORITHM TO CALANDAR PRGM TO GIVE WEEK

The easiest way to figure out the day of the week is to just count
days from a known date.  Every seven days is the same day of the
week as the first known date.  If you use Jan 1, 1900, which was a
Monday, the function DaysSince1900 is fairly easy:

  FUNCTION DaysSince1900 (y,m,d:  WORD):  WORD;
  BEGIN
    DaysSince1900 := 365*(y-1900) + INTEGER(y-1901) DIV 4 +
                     JulianDate(y,m,d)
  END {DaysSince1900};

  FUNCTION JulianDate(y, m, d:  WORD):  WORD;
    CONST
      julian:  ARRAY[0..12] OF WORD =
               (0,31,59,90,120,151,181,212,243,273,304,334,365);
  BEGIN
    jd := julian[m-1] + d;
    IF  (m > 2) AND (y MOD 4 = 0) AND (y <> 1900) AND (y <> 2100)
    THEN INC (jd);
    JulianDate := jd
  END {JulianDate};

  Now:  DaysSince1900(y,m,d) MOD 7 returns day-of-week index.  
        0=Sunday, 1=Monday, etc. since Jan 1, 1900 was a Monday.

--
Earl F. Glynn



Sat, 04 Apr 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Week function needed

2. better temp conversion prgm ?

3. cs1a needs if then else help, please give!!

4. I need an algorithm!

5. Gaussian Smoothing/Blur Algorithm Needed.

6. Needed : Tp7/Freepascal source for a trapdoor encryption algorithm

7. need algorithm for sphere collision

8. need algorithm for sphere collision for billiard game

9. need algorithm for sphere collision for billiard game

10. need algorithm for sphere collision for snooker(billiard) game

11. Need RSA encryption algorithm

12. antialiasing algorithm needed

 

 
Powered by phpBB® Forum Software