From: William James Date: 2007-09-27T00:25:06+09:00 Subject: Re: Finding the last Sunday of a month On Sep 26, 8:44 am, Peter Bailey wrote: > Hello, > I need to find the date for the last Sunday in January, for any year. I > need this for a budgetary script I'm trying to write. Using the > Date/Time module, I've done this so far. > > require 'date' > now = DateTime.now > year = now.year > d = Date.new(now.year, 1, 31) > puts d.wday > > yields: 3 Just for fun: y=`cal`[/\d+/] d = `cal 1 #{y}`.scan(/^.{20}$/)[-1]. split[-1].to_i