2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,38 +1,31 @@
|
|||
/*REXX program finds months with 5 weekends in them (given a date range)*/
|
||||
month. =31 /*month days; Feb. is done later.*/
|
||||
month.4=30; month.6=30; month.9=30; month.11=30 /*30-day months*/
|
||||
parse arg yStart yStop . /*get the "start" & "stop" years.*/
|
||||
if yStart=='' then yStart=1900 /*if not specified, use default. */
|
||||
if yStop =='' then yStop =2100 /* " " " " " */
|
||||
years=yStop-yStart+1 /*calculate the # of yrs in range*/
|
||||
haps=0 /*num of five weekends happenings*/
|
||||
!.=0 /*if a year has any five-weekends*/
|
||||
do y=yStart to yStop /*process the years specified. */
|
||||
do m=1 for 12; wd.=0 /*process each month, each year. */
|
||||
if m==2 then month.2=28+leapyear(y) /*handle #days in Feb*/
|
||||
do d=1 for month.m; dat_=y"-"right(m,2,0)'-'right(d,2,0)
|
||||
/*REXX program finds months that contain five weekends (given a date range). */
|
||||
month. =31; month.2=0 /*month days; February is skipped. */
|
||||
month.4=30; month.6=30; month.9=30; month.11=30 /*all the months with thirty-days. */
|
||||
parse arg yStart yStop . /*get the "start" and "stop" years.*/
|
||||
if yStart=='' | yStart=="," then yStart= 1900 /*Not specified? Then use the default.*/
|
||||
if yStop =='' | yStop =="," then yStop = 2100 /* " " " " " " */
|
||||
years=yStop - yStart + 1 /*calculate the number of yrs in range.*/
|
||||
haps=0 /*number of five weekends happenings. */
|
||||
!.=0; @5w= 'five-weekend months' /*flag if a year has any five-weekends.*/
|
||||
do y=yStart to yStop /*process the years specified. */
|
||||
do m=1 for 12; wd.=0 /*process each month and also each year*/
|
||||
do d=1 for month.m; dat_= y"-"right(m,2,0)'-'right(d,2,0)
|
||||
parse upper value date('W', dat_, "I") with ? 3
|
||||
wd.?=wd.?+1 /*? is the 1st 2 chars of weekday*/
|
||||
end /*d*/ /*WD.su = # of Sundays in a month*/
|
||||
if wd.su\==5 | wd.fr\==5 | wd.sa\==5 then iterate /*5 W.E.s?*/
|
||||
wd.?=wd.?+1 /*? is the first two chars of weekday.*/
|
||||
end /*d*/ /*WD.su = number of Sundays in a month.*/
|
||||
if wd.su\==5 | wd.fr\==5 | wd.sa\==5 then iterate /*five weekends ?*/
|
||||
say 'There are five weekends in' y date('M', dat_, "I")
|
||||
haps=haps+1; !.y=1 /*bump ctr; indicate yr has 5 WEs*/
|
||||
haps=haps+1; !.y=1 /*bump counter; indicate yr has 5 WE's.*/
|
||||
end /*m*/
|
||||
end /*y*/
|
||||
say
|
||||
say 'There were ' haps " occurrence"s(haps) 'of five-weekend months in year's(years) yStart'──►'yStop
|
||||
say "There were " haps ' occurrence's(haps) "of" @5w 'in year's(years) yStart"──►"yStop
|
||||
say; #=0
|
||||
do y=yStart to yStop; if !.y then iterate /*skip if OK*/
|
||||
#=#+1
|
||||
say 'Year ' y " doesn't have any five-weekend months."
|
||||
do y=yStart to yStop; if !.y then iterate /*skip if OK.*/
|
||||
#=#+1; say 'Year ' y " doesn't have any" @5wem'.'
|
||||
end /*y*/
|
||||
say
|
||||
say "There are " # ' year's(#) "that haven't any five─weekend months in year"s(years) yStart'──►'yStop
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*──────────────────────────────────LEAPYEAR subroutine─────────────────*/
|
||||
leapyear: procedure; parse arg y /*year could be: Y, YY, YYY, YYYY*/
|
||||
if length(y)==2 then y=left(right(date(),4),2)y /*adjust for YY year.*/
|
||||
if y//4\==0 then return 0 /* not ÷ by 4? Not a leap year.*/
|
||||
return y//100\==0 | y//400==0 /*apply 100 and 400 year rule. */
|
||||
/*──────────────────────────────────S subroutine────────────────────────*/
|
||||
s: if arg(1)==1 then return arg(3); return word(arg(2) 's',1) /*plural*/
|
||||
say "There are " # ' year's(#) "that haven't any" @5w 'in year's(years) yStart'──►'yStop
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
s: if arg(1)==1 then return arg(3); return word(arg(2) 's',1) /*pluralizer.*/
|
||||
|
|
|
|||
|
|
@ -1,43 +1,37 @@
|
|||
/*REXX program finds months with 5 weekends in them (given a date range)*/
|
||||
month. =31 /*month days; Feb. is done later.*/
|
||||
month.4=30; month.6=30; month.9=30; month.11=30 /*30-day months*/
|
||||
/*REXX program finds months that contain five weekends (given a date range). */
|
||||
month. =31; month,2=0 /*month days; February is skipped. */
|
||||
month.4=30; month.6=30; month.9=30; month.11=30 /*all the months with thirty-days. */
|
||||
@months='January February March April May June July August September October November December'
|
||||
parse arg yStart yStop . /*get the "start" & "stop" years.*/
|
||||
if yStart=='' then yStart=1900 /*if not specified, use default. */
|
||||
if yStop =='' then yStop =2100 /* " " " " " */
|
||||
years=yStop-yStart+1 /*calculate the # of yrs in range*/
|
||||
haps=0 /*num of five weekends happenings*/
|
||||
!.=0 /*if a year has any five-weekends*/
|
||||
do y=yStart to yStop /*process the years specified. */
|
||||
do m=1 for 12; wd.=0 /*process each month in each year*/
|
||||
if m==2 then month.2=28+leapyear(y) /*handle # days in Feb.*/
|
||||
parse arg yStart yStop . /*get the "start" and "stop" years.*/
|
||||
if yStart=='' | yStart=="," then yStart= 1900 /*Not specified? Then use the default.*/
|
||||
if yStop =='' | yStop =="," then yStop = 2100 /* " " " " " " */
|
||||
years=yStop - yStart + 1 /*calculate the number of yrs in range.*/
|
||||
haps=0 /*number of five weekends happenings. */
|
||||
!.=0; @5w= 'five-weekend months' /*flag if a year has any five-weekends.*/
|
||||
do y=yStart to yStop /*process the years specified. */
|
||||
do m=1 for 12; wd.=0 /*process each month and also each year*/
|
||||
do d=1 for month.m
|
||||
?=dow(m,d,y) /*get day-of-week for mm/dd/yyyy.*/
|
||||
wd.?=wd.?+1 /*?: 1=Sun, 2=Mon, ∙∙∙ 7=Sat */
|
||||
?=dow(m,d,y) /*get the day-of-week for mm/dd/yyyy*/
|
||||
wd.?=wd.?+1 /*?: 1=Sun, 2=Mon, 3=Tue ∙∙∙ 7=Sat.*/
|
||||
end /*d*/
|
||||
if wd.1\==5 | wd.6\==5 | wd.7\==5 then iterate /*5 WEs ? */
|
||||
say 'There are five weekends in' y word(@months,m)
|
||||
haps=haps+1; !.y=1 /*bump ctr; indicate yr has 5 WEs*/
|
||||
end /*m*/
|
||||
if wd.1\==5 | wd.6\==5 | wd.7\==5 then iterate /*not a weekend ? */
|
||||
say 'There are five weekends in' y word(@months, m)
|
||||
haps=haps+1; !.y=1 /*bump counter; indicate yr has 5 WE's.*/
|
||||
end /*m*/
|
||||
end /*y*/
|
||||
say
|
||||
say 'There were ' haps " occurrence"s(haps) 'of five-weekend months in year's(years) yStart'──►'yStop
|
||||
say 'There were ' haps " occurrence"s(haps) 'of' @5w "in year"s(years) yStart'──►'yStop
|
||||
#=0; say
|
||||
do y=yStart to yStop; if !.y then iterate /*skip if OK*/
|
||||
do y=yStart to yStop; if !.y then iterate /*skip if OK.*/
|
||||
#=#+1
|
||||
say 'Year ' y " doesn't have any five-weekend months."
|
||||
end /*y*/
|
||||
say
|
||||
say "There are " # ' year's(#) "that haven't any five─weekend months in year"s(years) yStart'──►'yStop
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*──────────────────────────────────DOW─────────────────────────────────*/
|
||||
dow: procedure; parse arg m,d,y; if m<3 then do; m=m+12; y=y-1; end
|
||||
yL=left(y,2); yr=right(y,2); w=(d+(m+1)*26%10+yr+yr%4+yL%4+5*yL) // 7
|
||||
if w==0 then w=7; return w /*Sunday=1, Monday=2, ... Saturday=7*/
|
||||
/*──────────────────────────────────LEAPYEAR subroutine─────────────────*/
|
||||
leapyear: procedure; parse arg y /*year could be: Y, YY, YYY, YYYY*/
|
||||
if length(y)==2 then y=left(right(date(),4),2)y /*adjust for YY year.*/
|
||||
if y//4\==0 then return 0 /* not ÷ by 4? Not a leap year.*/
|
||||
return y//100\==0 | y//400==0 /*apply 100 and 400 year rule. */
|
||||
/*──────────────────────────────────S subroutine────────────────────────*/
|
||||
s: if arg(1)==1 then return arg(3); return word(arg(2) 's',1) /*plural*/
|
||||
say "There are " # ' year's(#) "that haven't any" @5w 'in year's(years) yStart'──►'yStop
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
dow: procedure; parse arg m,d,y; if m<3 then do; m=m+12; y=y-1; end
|
||||
yL=left(y,2); yr=right(y,2); w=(d+(m+1)*26%10+yr+yr%4+yL%4+5*yL) // 7
|
||||
if w==0 then w=7; return w /*Sunday=1, Monday=2, ... Saturday=7 */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
s: if arg(1)==1 then return arg(3); return word(arg(2) 's',1) /*pluralizer.*/
|
||||
|
|
|
|||
|
|
@ -1,28 +1,30 @@
|
|||
/*REXX program finds months with 5 weekends in them (given a date range)*/
|
||||
month. =31 /*month days; Feb. is skipped. */
|
||||
month.4=30; month.6=30; month.9=30; month.11=30 /*30-day months*/
|
||||
yStart=1900; yStop=2100 /*define start and stop years. */
|
||||
haps=0 /*num of five weekends happenings*/
|
||||
!.=0 /*if a year has any five-weekends*/
|
||||
do y=yStart to yStop /*process the years specified. */
|
||||
do m=1 for 12; wd.=0 /*each month except Feb, each yr.*/
|
||||
if m==2 then iterate /*if month is February, skip it. */
|
||||
do d=1 for month.m; dat_=y"-"right(m,2,0)'-'right(d,2,0)
|
||||
/*REXX program finds months that contain five weekends (given a date range). */
|
||||
month. =31; month.2=0 /*month days; February is skipped. */
|
||||
month.4=30; month.6=30; month.9=30; month.11=30 /*all the months with thirty-days. */
|
||||
parse arg yStart yStop . /*get the "start" and "stop" years.*/
|
||||
if yStart=='' | yStart=="," then yStart= 1900 /*Not specified? Then use the default.*/
|
||||
if yStop =='' | yStop =="," then yStop = 2100 /* " " " " " " */
|
||||
years=yStop - yStart + 1 /*calculate the number of yrs in range.*/
|
||||
haps=0 /*number of five weekends happenings. */
|
||||
!.=0; @5w= 'five-weekend months' /*flag if a year has any five-weekends.*/
|
||||
do y=yStart to yStop /*process the years specified. */
|
||||
do m=1 for 12; wd.=0 /*process each month and also each year*/
|
||||
do d=1 for month.m; dat_= y"-"right(m, 2, 0)'-'right(d, 2, 0)
|
||||
parse upper value date('W', dat_, "I") with ? 3
|
||||
wd.?=wd.?+1 /*? is 1st 2 chars of tge weekday*/
|
||||
end /*d*/ /*WD.su=# of Sundays in the month*/
|
||||
if wd.su\==5 | wd.fr\==5 | wd.sa\==5 then iterate /*5 W.E.s?*/
|
||||
say 'There are five weekends in' y date('M', dat_, "I")
|
||||
haps=haps+1; !.y=1 /*bump ctr; indicate yr has 5 WEs*/
|
||||
wd.?=wd.?+1 /*?: 1=Sun, 2=Mon, 3=Tue ∙∙∙ 7=Sat.*/
|
||||
end /*d*/ /*WD.su=number of Sundays in the month.*/
|
||||
if wd.su\==5 | wd.fr\==5 | wd.sa\==5 then iterate /*is this a weekend ? */
|
||||
say 'There are five weekends in' y date('M', dat_, "I")
|
||||
haps=haps+1; !.y=1 /*bump counter; indicate yr has 5 WE's.*/
|
||||
end /*m*/
|
||||
end /*y*/
|
||||
say
|
||||
say 'There were ' haps " occurrences of five-weekend months in years" yStart'──►'yStop; say
|
||||
#=0
|
||||
do y=yStart to yStop; if !.y then iterate /*skip if OK*/
|
||||
#=#+1
|
||||
say 'Year ' y " doesn't have any five-weekend months."
|
||||
end /*y*/
|
||||
say 'There were ' haps " occurrence"s(haps) 'of' @5w "in year"s(years) yStart'──►'yStop
|
||||
#=0; say
|
||||
do y=yStart to yStop; if !.y then iterate /*skip if OK.*/
|
||||
#=#+1
|
||||
say 'Year ' y " doesn't have any five-weekend months."
|
||||
end /*y*/
|
||||
say
|
||||
say "There are " # " years that haven't any five─weekend months in years" yStart'──►'yStop
|
||||
/*stick a fork in it, we're done.*/
|
||||
say "There are " # ' year's(#) "that haven't any" @5w 'in year's(years) yStart'──►'yStop
|
||||
/*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
|
|
@ -1,23 +1,27 @@
|
|||
/*REXX program finds months with 5 weekends in them (given a date range)*/
|
||||
month.=31; yStart=1900; yStop=2100 /*month days; range of years. */
|
||||
month.2=0; month.4=0; month.6=0; month.9=0; month.11=0 /*¬31 day months*/
|
||||
haps=0 /*num of five weekends happenings*/
|
||||
!.=0 /*if a year has any five-weekends*/
|
||||
do y=yStart to yStop /*process the years specified. */
|
||||
do m=1 for 12; if month.m==0 then iterate /*test 31-day mons*/
|
||||
dat_=y"-"right(m,2,0)'-01' /*get date in the proper format. */
|
||||
if left(date('W',dat_,"I"),2)\=='Fr' then iterate /*Friday?*/
|
||||
say 'There are five weekends in' y date('M', dat_, "I")
|
||||
haps=haps+1; !.y=1 /*bump ctr; indicate yr has 5 WEs*/
|
||||
end /*m*/
|
||||
end /*y*/
|
||||
/*REXX program finds months that contain five weekends (given a date range). */
|
||||
month. =31 /*days in "all" the months. */
|
||||
month.2=0; month.4=0; month.6=0; month.9=0; month.11=0 /*not 31 day months.*/
|
||||
month.4=30; month.6=30; month.9=30; month.11=30 /*all the months with thirty-days. */
|
||||
parse arg yStart yStop . /*get the "start" and "stop" years.*/
|
||||
if yStart=='' | yStart=="," then yStart= 1900 /*Not specified? Then use the default.*/
|
||||
if yStop =='' | yStop =="," then yStop = 2100 /* " " " " " " */
|
||||
years=yStop - yStart + 1 /*calculate the number of yrs in range.*/
|
||||
haps=0 /*number of five weekends happenings. */
|
||||
!.=0; @5w= 'five-weekend months' /*flag if a year has any five-weekends.*/
|
||||
do y=yStart to yStop /*process the years specified. */
|
||||
do m=1 for 12; if month.m==0 then iterate /*only test 31-day months.*/
|
||||
dat_= y"-"right(m,2,0)'-01' /*get the date in the desired format. */
|
||||
if left(date('W',dat_,"I"),2)\=='Fr' then iterate /*isn't not a Friday? */
|
||||
say 'There are five weekends in' y date('M', dat_, "I")
|
||||
haps=haps+1; !.y=1 /*bump counter; indicate yr has 5 WE's.*/
|
||||
end /*m*/
|
||||
end /*y*/
|
||||
say
|
||||
say 'There were ' haps " occurrences of five-weekend months in years" yStart'──►'yStop; say
|
||||
#=0
|
||||
do y=yStart to yStop; if !.y then iterate /*skip if OK*/
|
||||
#=#+1
|
||||
say 'Year ' y " doesn't have any five-weekend months."
|
||||
end /*y*/
|
||||
say 'There were ' haps " occurrence"s(haps) 'of' @5w "in year"s(years) yStart'──►'yStop
|
||||
#=0; say
|
||||
do y=yStart to yStop; if !.y then iterate /*skip if OK.*/
|
||||
#=#+1
|
||||
say 'Year ' y " doesn't have any five-weekend months."
|
||||
end /*y*/
|
||||
say
|
||||
say "There are " # " years that haven't any five─weekend months in years" yStart'──►'yStop
|
||||
/*stick a fork in it, we're done.*/
|
||||
say "There are " # ' year's(#) "that haven't any" @5w 'in year's(years) yStart'──►'yStop
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue