[LRUG] How does Rails decide how to parse ambiguous dates?

Murray Steele murray.steele at gmail.com
Tue Jul 26 09:48:18 PDT 2011


On 26 July 2011 17:43, John Winters <john at sinodun.org.uk> wrote:

> On 26/07/11 17:36, Matthew Rudy Jacobs wrote:
>
>>
>>    Because I have some fairly naive users, and getting them to use a
>>    computer at all can be a bit of a struggle.  Seriously - I have
>>    users whose tension levels go through the roof if even asked to sit
>>    at a keyboard.  Asking them to adapt to a new date format is just
>>    too much.
>>
>> I suggest to use names of months, instead of month numbers then
>>
>> "20" + "September" + "2012"
>>
>> is unambiguous, and user-friendly, in america and the uk.
>>
>
> Yes, that's a nice idea, but it still leaves unanswered the question of how
> to get an existing date formatted like that in the text field.
>
> As far as I've been able to discover, Rails provides no facilities to
> control that formatting, and what you'll get in your field by default is the
> raw database format.  Obviously there are lots of ways of overriding this,
> but what I've been trying to do is find the Correct Rails Way(TM) to achieve
> it.
>
> The best I've come up with so far is the ":value => ..." way I detailed
> earlier.  I'm surprised the framework doesn't provide anything better, but
> I'll keep looking for a while longer just in case.
>
>
Not necessarily better, but there are the date_select and time_select
helpers.  They give you a series of drop downs instead of a text field and
Rails magically works out how to translate the 3 or 6 values they provide
into a single date object.

Or you could embellish the text field with a JS calendar picker.


>
> Cheers,
> John
> ______________________________**_________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/**listinfo.cgi/chat-lrug.org<http://lists.lrug.org/listinfo.cgi/chat-lrug.org>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20110726/2b99b80c/attachment-0003.html>


More information about the Chat mailing list