Re: String weirdness

Scott Barron
Fri, 11 Nov 2005 15:03:04 -0000

On Nov 11, 2005, at 8:32 AM, Larry White wrote:

> I''m a newbie so please have pity if the answer is obvioius ;-)
>
>  I wrote a date formatter.  It works as expected in irb, but if i try
> to use it to format a date for display as the value of an input
> (type=text) field, it truncates unexpectedly.
>
>  This is the formatter:
>
>  def format_date_short_us(date)
>          month_hash = Hash[1 =>''Jan'', 2 =>
''Feb'', 3=>,...etc... 12 =>
> ''Dec'']
>          "#{month_hash[adate.month]} #{adate.day}, #{adate.year}"
>  end

It looks to me like you''re using Date/Time objects.  If so, just do:

date.strftime(''%b %d, %Y'')

--
Scott Barron
Lunchbox Software