Most years have 52 weeks, some have 53, according to ISO8601.



Task

Write a function which determines if a given year is long (53 weeks) or not, and demonstrate it.




 
\Long year
code Rem=2, CrLf=9, IntIn=10, IntOut=11, Text=12, Clear=40;
integer S, E, Y;
 
  function integer Weekday(Y);
  \Weekday of Y-12-31, 0 Sunday
  integer Y;
  return Rem((Y + Y / 4 - Y / 100 + Y / 400) / 7);
 
  function integer IsLongYear(Y);
  integer Y;
  return 4 = Weekday(Y) ! 3 = Weekday(Y - 1);
 
begin
Clear;   
Text(0, "****     List of ISO long years     ****");
CrLf(0);
Text(0, "Start year: "); S:= IntIn(0);
Text(0, "End year: "); E:= IntIn(0);
CrLf(0);
for Y:= S, E do
  if IsLongYear(Y) then [IntOut(0, Y); Text(0, " ")];
CrLf(0);
end
 