From: zverok.offline@... Date: 2016-03-24T08:36:28+00:00 Subject: [ruby-core:74526] [Ruby trunk Feature#12211] introduce Date#first_of_month and Date#last_of_month Issue #12211 has been updated by Victor Shepelev. IMHO, consistent approach would be "allow Date/Time to be rounded to any component", there are many uses for this. Maybe something like `ceil`/`floor`/`round` methods set with Symbol argument? Like `floor(:month)` and `ceil(:month)`? ---------------------------------------- Feature #12211: introduce Date#first_of_month and Date#last_of_month https://bugs.ruby-lang.org/issues/12211#change-57651 * Author: Shunichi Arai * Status: Open * Priority: Normal * Assignee: ---------------------------------------- Proposes new methods Date#first_of_month and Date#last_of_month which can be very helpful in reporting applications which need the first and the last day of a month very frequently. ~~~ class Date def first_of_month Date.new(year, month, 1) end def last_of_month next_month.first_of_month.prev_day end end ~~~ Current way to do it `Date.new(date.year, date.month, 1)` is not elegant and short enough for this simple and common operation. -- https://bugs.ruby-lang.org/ Unsubscribe: