Class: Date
- Defined in:
- lib/nano/date/to_s.rb,
lib/nano/date/stamp.rb,
lib/nano/date/to_date.rb,
lib/nano/date/to_time.rb,
lib/nano/date/days_in_month.rb,
lib/nano/date/days_of_month.rb
Instance Method Summary collapse
-
#days_in_month ⇒ Object
Returns the number of days in the date’s month.
- #days_of_month ⇒ Object
-
#to_date ⇒ Object
To be able to keep Dates and Times interchangeable on conversions.
-
#to_s(format = nil) ⇒ Object
(also: #stamp)
An improved #to_s method that cane take an optional format flag of :short or :long.
-
#to_time(form = :local) ⇒ Object
Convert Date to Time.
Instance Method Details
#days_in_month ⇒ Object
10 11 12 |
# File 'lib/nano/date/days_in_month.rb', line 10 def days_in_month Date.civil(year, month, -1).day end |
#days_of_month ⇒ Object
3 4 5 |
# File 'lib/nano/date/days_of_month.rb', line 3 def days_of_month (1..days_in_month).to_a end |
#to_date ⇒ Object
To be able to keep Dates and Times interchangeable on conversions.
6 7 8 |
# File 'lib/nano/date/to_date.rb', line 6 def to_date self end |
#to_s(format = nil) ⇒ Object Also known as: stamp
An improved #to_s method that cane take an optional format flag of :short or :long.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/nano/date/to_s.rb', line 6 def to_s(format = nil) case format when :short strftime("%e %b").strip when :long strftime("%B %e, %Y").strip else stamp end end |