Sha256: 0c33b4b1e32fc9dcb1e04a39d71ec8bfa8b365489aa239cd861093221f12c7d9

Contents?: true

Size: 457 Bytes

Versions: 3

Compression:

Stored size: 457 Bytes

Contents

#--
# Credit goes to Ken Kunz.
#++
class Date
  # Returns the number of days in the date's month.
  #
  #   require 'facet/date/days_in_month'
  #
  #   Date.new(2004,2).days_in_month #=> 28
  #
  def days_in_month
     Date.civil(year, month, -1).day
  end
end


#__TEST__

if __FILE__ == $0
  require 'test/unit'
  class TestCase < Test::Unit::TestCase
    def test_days_in_month
      assert_equal( 31, Date.new(2004,1).days_in_month )
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-0.7.0 lib/facet/date/days_in_month.rb
facets-0.7.1 lib/facet/date/days_in_month.rb
facets-0.7.2 lib/facet/date/days_in_month.rb