From: Rob Biedenharn Date: 2008-02-28T05:14:11+09:00 Subject: Re: Getting number of days in a month On Feb 27, 2008, at 2:17 PM, Gregory Seidman wrote: > On Thu, Feb 28, 2008 at 03:29:54AM +0900, Brian Adkins wrote: >> On Feb 27, 1:00 pm, Gregory Seidman >> wrote: >>> On Thu, Feb 28, 2008 at 02:49:54AM +0900, Brian Adkins wrote: >>>> On Feb 27, 11:40 am, Gregory Seidman >>> +r...@anthropohedron.net> >>>> wrote: >>>>> On Thu, Feb 28, 2008 at 01:17:22AM +0900, Shandy Nantz wrote: >>>>>> This is probably an easy question but I am trying to get at the >>>>>> number >>>>>> of days that are in a month. I have this calendar that I have >>>>>> built, the >>>>>> idea being that when a month turns from February to March, for >>>>>> example, >>>>>> the calendar should redisplay itself properly formated showing >>>>>> the new >>>>>> month and the correct number of days. I have it so that it starts >>>>>> counting the days on the right day of the week, but I have to >>>>>> know when >>>>>> to stop counting. Any ideas, Thanks, >>> >>>>> {code removed} >>>>>> -S >>>>> --Greg >>> >>>> might want to try running that before posting >>> >>> Ah, details. Change the last line of the method to: >>> >>> (next_month + next_month.mday).mday >>> >>> Anyhow, it's worth noting that ActiveSupport includes >>> Time.days_in_month. >>> >>> --Greg >> >> You still didn't run it, did you? > > Don't sigh at me. I wrote some code off the cuff and fired it off. I > also > didn't include unit tests. Yes, it was buggy and inefficient, but it > got > across the approach I was using. The point is applicable to *everyone*: "Don't present code that you haven't actually run unless you *say* that you haven't run it." You'll just end up confusing the OP or other readers that may benefit from the code. If you're trying to illustrate a point or an approach, say so or make it quite clear that your code is incomplete or intended as pseudo-code (particularly if it appears to be valid syntax). -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com