|
I include these subroutines as I have no idea of the current availability of such data. The code used to determine leap years is embedded but not rigid -- it will fail in 2100.
(Click for a rigid version)
Here is the introduction: |
Year% = 2013 CALL DatesOfMons(Year%,DoM$) |
|
DoM$ is the returned long string of the Dates of Mondays within the year The subroutine: |
'==============================================================
SUB DatesOfMons(Year%,DoM$)
' Accepts Year% as integer of the year concerned eg 2013
' Returns DoM$ -- the string of the dates of Mondays in the year eg:
' 7 Jan | 14 Jan | 21 Jan | 28 Jan | 4 Feb | 11 Feb | 18 Feb |---etc
DDat$ ="MonTueWedThuFriSatSunJan3Feb0Mar3Apr2May3Jun2Jul3Aug3Sep2Oct3Nov2Dec3"
' The numeral following each month is the number of days over 28 in the
' preceeding month
IF Year% = 4*INT(Year%/4) THEN MID$(Mn$,8,1)="1"
' If leapyear, February has 1 day more than 28
' NB: Simplified algorithm OK until 2100
YD% = Year% - 1989 'Number of years since 1989
LYD% = YD% + INT((YD%)/4) 'Add extra days in leapyears.
Jan1% = LYD% - 7 * INT(LYD%/7)
IF Jan1% < 1 THEN Jan1% = Jan1% + 7 'Jan1% is weekday% of 1st Jan
'Thus if Jan1% = 7, 1st Jan is a
'Sunday & following Monday will be
'2nd Jan
Mon% = 9 - Jan1% 'Mon% is date of 1st day in January
DoM$ = "" 'String of Mondays
b$ = " |" 'Blank for dates of Mondays
FOR m% = 1 TO 12
m$ = MID$(DDat$,4*m% + 18,3) '3 alpha definition of current month.
e$ = MID$(DDat$,4*m% + 21,1) 'Excess days over 28 in month
LastDate% = 28 + INT(VAL(e$)) 'Last date in current month
DO
Mon$ = STR$(Mon%)
IF Mon% > 9 THEN Mon$ = MID$(Mon$,2,2)
MID$(b$,2,2) = Mon$
MID$(b$,5,3) = m$
DoM$ = DoM$ + b$
Mon% = Mon% + 7 'Increment date in month to next Monday.
LOOP UNTIL Mon% > LastDate%
Mon% = Mon% - LastDate% 'Date of next Monday in next month
NEXT
END SUB
'----------------------------------------------------------------------------
|
|
We now have DoM$, a long string with all the dates of mondays in the year. I like to store this
string in a file "mons####.dat" (#### is year) for display and annotation. I place this file in
folder$
NB: I always have a folder "PO" (post office) at root level with link from desktop where I can temporarily store any files before dragging to final destination. |
Year% = 2013 DoM$ = Long string of Dates of Mondays in year Folder$ = "\po\" WeeksPerLine% = 5 CALL FileMons(Year%,WeeksPerLine%,DoM$,Folder$) |
| The subroutine: |
'----------------------------------------------------------------------------
SUB FileMons(Year%,wpl%,DoM$,Fold$)
' Accepts Year% as integer of the year concerned eg 2013
' Accepts Dom$ -- the string of the dates of Mondays in the year eg:
' 7 Jan | 14 Jan | 21 Jan | 28 Jan | 4 Feb | 11 Feb |--etc
' Accepts wpl% as the number of weeks/line in new format.
' Accepts Fold$ as the folder to contain the formatted version
' of DoM$ headed by the year concerned.
' Returns file "mons####.dat" (where #### is year) in folder Fold$
F$ = "Mons####.dat"
MID$(F$,5,4) = MID$(STR$(Year%),2,4)
Fle$ = Fold$ + f$
OPEN "O",#1,Fle$
PRINT#1, "Mondays in";Year%
d$ = DoM$
DO UNTIL LEN(d$) < 11
'then format with wpl% weeks per line.
PRINT#1, MID$(d$,1,wpl%*11) : d$ = MID$(d$,78,LEN(d$))
LOOP
CLOSE #1
END SUB
'----------------------------------------------------------------------------
|
| Running the above subroutine results in the file \po\mons2013.dat: |
Mondays in 2013 7 Jan | 14 Jan | 21 Jan | 28 Jan | 4 Feb | 25 Feb | 4 Mar | 11 Mar | 18 Mar | 25 Mar | 15 Apr | 22 Apr | 29 Apr | 6 May | 13 May | 3 Jun | 10 Jun | 17 Jun | 24 Jun | 1 Jul | 22 Jul | 29 Jul | 5 Aug | 12 Aug | 19 Aug | 9 Sep | 16 Sep | 23 Sep | 30 Sep | 7 Oct | 28 Oct | 4 Nov | 11 Nov | 18 Nov | 25 Nov | 16 Dec | 23 Dec | 30 Dec | |