From: Rob Biedenharn Date: 2007-09-27T21:00:28+09:00 Subject: Re: Finding the last Sunday of a month On Sep 27, 2007, at 7:46 AM, Lloyd Linklater wrote: > Jeremy Hinegardner wrote: >> Well this has been answered fully now, but just for fun, how about >> the >> fully gem driven method: >> >> % cat last_sun_jan.rb >> require 'rubygems' >> require 'chronic' >> require 'facet/times' >> require 'facet/time/to_date' >> >> last_sunday_in_jan = (Chronic.parse("1st Sunday in February", >> :context => :future) - 7.days).to_date >> >> puts last_sunday_in_jan >> >> % ruby last_sun_jan.rb >> 2008-01-27 > > That is really cool, Jeremy, except that the last Sunday in January is > the 28th, not the 27th. Other than that, cool stuff! :) Not in 2008, it's the 27th then. -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com