Logo

Programming-Idioms

  • D
  • C
  • Cobol
  • Pascal

Idiom #342 Leap year?

Determine if the current year is a leap year.

SysUtils
if IsLeapYear(SomeYear) then writeln('SomeYear is a leap year')
final thisYear = DateTime.now().year;
final isLeap = DateTime(year, 2, 29).month == 2;

2, 29 will become 3, 1 in non-leap years.

New implementation...
< >
steenslag