I made new object Date.new with args (year, month). After create ruby added 01 number of day to this object by default. Is there any way to add not first day, but last day o
require "date"
def find_last_day_of_month(_date)
if(_date.instance_of? String)
@end_of_the_month = Date.parse(_date.next_month.strftime("%Y-%m-01")) - 1
else if(_date.instance_of? Date)
@end_of_the_month = _date.next_month.strftime("%Y-%m-01") - 1
end
return @end_of_the_month
end
find_last_day_of_month("2018-01-01")
This is another way to find