Class: Date
- Inherits:
-
Object
- Object
- Date
- Defined in:
- lib/time_win/date_ext.rb
Class Method Summary collapse
Class Method Details
.days_in_month(year, month) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/time_win/date_ext.rb', line 8 def days_in_month year, month case month when 1 then 31 when 2 then leap?(year) ? 29 : 28 when 3 then 31 when 4 then 30 when 5 then 31 when 6 then 30 when 7 then 31 when 8 then 31 when 9 then 30 when 10 then 31 when 11 then 30 when 12 then 31 else raise("Invalid month: #{month}") end end |
.days_in_year(year) ⇒ Object
4 5 6 |
# File 'lib/time_win/date_ext.rb', line 4 def days_in_year year leap?(year) ? 366 : 365 end |