From: ara.t.howard@... Date: 2006-01-17T08:15:51+09:00 Subject: Re: [newbie] this month, the next month, and the one after that On Tue, 17 Jan 2006, Detlef Reichl wrote: > OK > > ���: p(Time::mktime(2006,(13%12))) > Sun Jan 01 00:00:00 CET 2006 harp:~ > irb irb(main):001:0> p(Time::mktime(2006,(48%12))) ArgumentError: argument out of range from (irb):1:in `mktime' from (irb):1 you need t = Time::now n = 48 n = (t.month + n) % 12 (n == 0 ? t : Time::mktime(1970, n)).strftime('%b') sorry, couldn't resist! ;-) > >> i prefer the stupid approach: >> >> harp:~ > cat a.rb >> class Time >> def this_month >> strftime '%b' >> end >> def next_month n = 1 >> t = dup >> s = 60 * 60 * 24 >> n.times{ m = t.month; t += s until t.month != m } > > Outch :-) found no good logic? who cares, lets do it with brute force hey! i said it was stupid ;-) cheers. -a -- strong and healthy, who thinks of sickness until it strikes like lightning? preoccupied with the world, who thinks of death, until it arrives like thunder? -- milarepa