First convert January 2, 2003 to its JD form. Then add 7 successively to this JD to get JD's of all Thursdays. Use the conversion routine to find the Gregorian calendar date of each. If the day of the month is greater than 28, it is a 5th Thursday.
In the following code fragment, JD, MO, DA and YE are global variables used by the conversion subroutines.
mo = 1: da = 2: ye = 2003
GOSUB GregToJD
jd0 = jd
CLS
FOR jd = jd0 TO jd0 + 365.25 * 10 STEP 7
GOSUB JDtoGreg
IF da > 28 THEN
PRINT USING "## ## ####"; mo; da; ye
END IF
NEXT
END
By the way, subroutines that work to do those called functions in Basic are for example (old and not very elegant, but they work):
GregToJD:
REM :greg mo/da/ye --> jd at noon
GOSUB jul.to.jd
jd = jd + 2 - INT(cw(1) / 100) + INT(cw(1) / 400)
RETURN
jul.to.jd:
REM :jul mo/da/ye --> jd at noon
cw(0) = mo: cw(1) = ye: IF mo < 3 THEN cw(0) = mo + 12: cw(1) = ye - 1
jd = INT(365.25 * cw(1)) + INT(30.61 * (cw(0) + 1)) + da + 1720995!
RETURN
JDtoGreg:
REM:noon jd-->greg mo/da/ye
cw(0) = INT((jd - 1867216.25#) / 36524.25)
cw(0) = jd + 1 + cw(0) - INT(cw(0) / 4)
GOTO common.from.jd
jd.to.jul:
REM : noon jd-->jul mo/da/ye
cw(0) = jd
common.from.jd:
cw(0) = cw(0) + 1524
cw(1) = INT((cw(0) - 122.1) / 365.25)
cw(2) = INT(365.25 * cw(1))
cw(3) = INT((cw(0) - cw(2)) / 30.6001)
da = cw(0) - cw(2) - INT(30.61 * cw(3))
ye = cw(1) - 4716
mo = cw(3) - 1: IF mo > 12 THEN mo = mo - 12: ye = ye + 1
RETURN
By the way, the results:
1 30 2003
5 29 2003
7 31 2003
10 30 2003
1 29 2004
4 29 2004
7 29 2004
9 30 2004
12 30 2004
3 31 2005
6 30 2005
9 29 2005
12 29 2005
3 30 2006
6 29 2006
8 31 2006
11 30 2006
3 29 2007
5 31 2007
8 30 2007
11 29 2007
1 31 2008
5 29 2008
7 31 2008
10 30 2008
1 29 2009
4 30 2009
7 30 2009
10 29 2009
12 31 2009
4 29 2010
7 29 2010
9 30 2010
12 30 2010
3 31 2011
6 30 2011
9 29 2011
12 29 2011
3 29 2012
5 31 2012
8 30 2012
11 29 2012
|