Methods
Public Instance methods
Returns the number of days in the date‘s month.
Date.new(2004,2).days_in_month #=> 28 CREDIT: Ken Kunz.
[ show source ]
# File lib/lore/facets/date.rb, line 61 def days_in_month Date.civil(year, month, -1).day end
[ show source ]
# File lib/lore/facets/date.rb, line 65 def days_of_month (1..days_in_month).to_a end
Get the month name for this date object
CREDIT Benjamin Oakes
[ show source ]
# File lib/lore/facets/date.rb, line 73 def month_name MONTHNAMES[self.month] end
An enhanched to_s method that cane take an optional format flag of :short or :long.
This method is also aliased as
to_s
[ show source ]
# File lib/lore/facets/date.rb, line 41 def stamp(format = nil) case format when :short strftime("%e %b").strip when :long strftime("%B %e, %Y").strip else strftime("%Y-%m-%d") # standard to_s end end
To be able to keep Dates and Times interchangeable on conversions.
[ show source ]
# File lib/lore/facets/date.rb, line 29 def to_date self end
Alias for stamp
Convert Date to Time.
[ show source ]
# File lib/lore/facets/date.rb, line 35 def to_time(form = :local) ::Time.send(form, year, month, day) end