String weirdness

Larry White
Fri, 11 Nov 2005 13:32:21 -0000

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

Within IRB, passing in Date.today returns:
=> "Nov 11, 2005"

The html result using Date.today is:
"Nov"

This is the invocation from html:

<input type="text"
name="st_date"
id="f_date_c"
value=<%= format_date_short_us(@project.st_date) %> />

Any help is greatly appreciated. thanks.


_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org