Leap year
This phrase tests whether each item in its simple integer argument represents a leap year. It is valid for all dates since the Gregorian reform which occurred in 1582-3 AD in Catholic Europe, 1752-3 AD in protestant Europe and the English-speaking world and at various times around the world until the Eastern Orthodox Churches reached a compromise with it in the early 20th Century. It is valid until the year 2800 CE for the Orthodox Churches and 4000 CE, whose leap status is yet to be determined by consensus, for the rest.
0≠.=4 100 400∘.|ia
Examples
⎕FX⍕2 1⍴'r←LeapYear ia' 'r←0≠.=4 100 400∘.|ia' im←1900 2000 2100∘.+¯4 ¯1 0 1 4 im 1896 1899 1900 1901 1904 1996 1999 2000 2001 2004 2096 2099 2100 2101 2104 LeapYear im 1 0 0 0 1 1 0 1 0 1 1 0 0 0 1 ⌽2⍴¯1⌽iv←1753+⍳50 ⍝ beyond 1800 1753 1802 ⍝ first and last (LeapYear iv)/iv ⍝ excludes 1800 1756 1760 1764 1768 1772 1776 1780 1784 1788 1792 1796 ⌽2⍴¯1⌽iv←100×16+⍳24 ⍝ all centuries 1600 3900 ⍝ first and last (LeapYear iv)/iv ⍝ leap only every 4th 1600 2000 2400 2800 3200 3600
Specialities
...
Compatibility
CheckedWith: APL2, APLX, Dyalog, NARS2000
Test Cases
Show test cases
Test my code, both Examples and Test Cases.
See also: ...
Mentor: PhilLast
Tags: <LeapYear> <Dates>