08-01-2008
3,653,
12
Join Date: Mar 2008
Last Activity: 28 March 2011, 6:41 AM EDT
Location: /there/is/only/bin/sh
Posts: 3,653
Thanks Given: 0
Thanked 12 Times in 10 Posts
As you should be able to tell from the variable names, it handles leap years. % is the modulo operator (commonly called "remainder" in primary school). In other words, if the year is evenly divisible by 4 (modulo is zero, so the conditional (( (year % 4) )) returns false; we invert that value with the exclamation mark) but not by 100 except if it's also divisible by 400, it's a leap year, and so February will have 29 days.