RosettaCodeData/Task/Five-weekends/PL-I/five-weekends.pli

26 lines
840 B
Plaintext

weekends: procedure options (main); /* 28/11/2011 */
declare tally fixed initial (0);
declare (d, dend, dn) fixed (10);
declare (date_start, date_end) picture '99999999';
declare Leap fixed (1);
date_start = '01011900';
do date_start = date_start to '01012100';
d = days(date_start, 'DDMMYYYY');
date_end = date_start + 30110000;
dend = days(date_end, 'DDMMYYYY');
Leap = dend-d-364;
do dn = d, d+59+Leap, d+120+Leap, d+181+Leap, d+212+Leap,
d+273+Leap, d+334+Leap;
if weekday(dn) = 6 then
do;
put skip list (daystodate(dn, 'MmmYYYY') || ' has 5 weekends' );
tally = tally + 1;
end;
end;
end;
put skip list ('Total number of months having 3-day weekends =', tally);
end weekends;