47 lines
1.8 KiB
Plaintext
47 lines
1.8 KiB
Plaintext
/* NetRexx ************************************************************
|
|
* 30.08.2012 Walter Pachl derived from Rexx version 3
|
|
* omitting dead code left there
|
|
**********************************************************************/
|
|
options replace format comments java crossref savelog symbols
|
|
Numeric digits 20
|
|
nr5fwe=0
|
|
years_without_5fwe=0
|
|
mnl='Jan Mar May Jul Aug Oct Dec'
|
|
ml='1 3 5 7 8 10 12'
|
|
Loop j=1900 To 2100
|
|
year_has_5fwe=0
|
|
Loop mi=1 To ml.words()
|
|
m=ml.word(mi)
|
|
jd=greg2jul(j,m,1)
|
|
IF jd//7=4 Then Do /* 1st m j is a Friday */
|
|
nr5fwe=nr5fwe+1
|
|
year_has_5fwe=1
|
|
If j<=1905 | 2095<=j Then
|
|
Say mnl.word(mi) j 'has 5 full weekends'
|
|
End
|
|
End
|
|
If j=1905 Then Say '...'
|
|
if year_has_5fwe=0 Then years_without_5fwe=years_without_5fwe+1
|
|
End
|
|
Say ' '
|
|
Say nr5fwe 'occurrences of 5 full weekends in a month'
|
|
Say years_without_5fwe 'years without 5 full weekends'
|
|
exit
|
|
|
|
method greg2jul(yy,mm,d) public static returns Rexx
|
|
/***********************************************************************
|
|
* Converts a Gregorian date to the corresponding Julian day number
|
|
* 19891101 Walter Pachl REXXified algorithm published in CACM
|
|
* (Fliegel & vanFlandern, CACM Vol.11 No.10 October 1968)
|
|
***********************************************************************/
|
|
numeric digits 12
|
|
/***********************************************************************
|
|
* The published formula:
|
|
* res=d-32075+1461*(yy+4800+(mm-14)%12)%4+,
|
|
* 367*(mm-2-((mm-14)%12)*12)%12-3*((yy+4900+(mm-14)%12)%100)%4
|
|
***********************************************************************/
|
|
mma=(mm-14)%12
|
|
yya=yy+4800+mma
|
|
result=d-32075+1461*yya%4+367*(mm-2-mma*12)%12-3*((yya+100)%100)%4
|
|
Return result /* return the result */
|