|Posted by Jamal Nasir on February 7, 2012 at 3:45 AM|
Date.new(Time.now.year, 12, 31)
The above line will create a date with the current year, 12 months and 31 days.
This will subtract the current month number of month from 12. For example;
If it is Febuary (2), the above line of code will give you 10.
last_day_of_month= (Date.new(Time.now.year, 12, 31) << (12-Time.now.month)).day
So, the above line will give you the last day of month.