From: David Vallner Date: 2006-01-17T06:13:00+09:00 Subject: Re: [newbie] this month, the next month, and the one after that On Mon, 16 Jan 2006 21:55:40 +0100, James Edward Gray II wrote: > On Jan 16, 2006, at 2:29 PM, David Vallner wrote: > >> Mind you, DateTime::MONTHNAMES is one-indexed, starting from January, > > We can fix that. ;) > >> so you'll have to do some index-shiftingto wrap around the end of the >> array correctly. And since there's very little I hate more than >> shifting array indices around, the exercise is left to the reader ;P > > Okay, I'll bite: > > >> current = Time.now.strftime("%B") > => "January" > >> require "date" > => true > >> months = (Date::MONTHNAMES + Date::MONTHNAMES).compact > => ["January", "February", "March", "April", "May", "June", "July", > "August", "September", "October", "November", "December", "January", > "February", "March", "April", "May", "June", "July", "August", > "September", "October", "November", "December"] > >> three_months = months[months.index(current), 3] > => ["January", "February", "March"] > > James Edward Gray II > > Ye gods, that's so idiot-proof it ain't pretty anymore amd I let my brain spin around index shifts.. I've been doing WAAAY too much Java at work. Help, my 1337 R�by h@xx0r skills are disappearing! *sic* David Vallner