Is it a leap year : Time Calculation « Time « Ruby






Is it a leap year


class Time

  def Time.leap? year
    if year % 400 == 0
      true
    elsif year % 100 == 0
      false
    elsif year % 4 == 0
      true
    else
      false
  end

end

 








Related examples in the same category

1.You can see the difference in two Time objects by subtracting them:
2.Add seconds and multiples of seconds to add to a time with +
3.Doing Time Arithmetic
4.Finding the Day of the Week