From: David Vallner Date: 2006-01-17T05:29:23+09:00 Subject: Re: [newbie] this month, the next month, and the one after that On Mon, 16 Jan 2006 20:45:18 +0100, Mason Kessinger wrote: > What I want to do is simple. > > I'd like code that prints out the name of this month (January) the next > month (February) and the one after that (March) > > I've been able to print this month: > > <% t = Time.now %> > <%= t.strftime(" This Month is: %B") %> > > But I can't figure out how to get the next months to print out! > My first guess would be requiring "datetime", and then looking up the month name per DateTime::MONTHNAMES[t.month + 1]. Mind you, DateTime::MONTHNAMES is one-indexed, starting from January, 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 When I think about it, DateTime::MONTHNAMES[1..12][t.month % 12] should work perfectly for the next month, with (t.month + 1) for the one after that, etc. David Vallner