A company decides that whenever Xmas falls on a Sunday they will give their workers all extra paid holidays so that, together with any public holidays, workers will not have to work the following week (between the 25th of December and the first of January).



Task

In what years between 2008 and 2121 will the 25th of December be a Sunday?

Using any standard date handling libraries of your programming language;
compare the dates calculated with the output of other languages to discover any anomalies in the handling of dates which may be due to, for example, overflow in types used to represent dates/times similar to   y2k   type problems.




; Determine if a Gregorian calendar year is leap 
to leap? :year
  output (and 
    equal? 0 modulo :year 4
    not member? modulo :year 400 [100 200 300]
  )
end
 
; Convert Gregorian calendar date to a simple day count from 
; day 1 = January 1, 1 CE 
to day_number :year :month :day
  local "elapsed make "elapsed difference :year 1
  output (sum  product 365 :elapsed
              int quotient :elapsed 4
              minus int quotient :elapsed 100
              int quotient :elapsed 400
              int quotient difference product 367 :month 362 12
              ifelse lessequal? :month 2 0 ifelse leap? :year -1 -2
              :day)
end
 
; Find the day of the week from a day number; 0 = Sunday through 6 = Saturday
to day_of_week :day_number
  output modulo :day_number 7
end
 
; True if the given day is a Sunday
to sunday? :year :month :day
  output equal? 0 day_of_week day_number :year :month :day
end
 
; Put it all together to answer the question posed in the problem
print filter [sunday? ? 12 25] iseq 2008 2121
bye