[LRUG] How does Rails decide how to parse ambiguous dates?
John Winters
john at sinodun.org.uk
Tue Jul 26 07:34:06 PDT 2011
On 26/07/11 14:48, Paul Robinson wrote:
> On 26 Jul 2011, at 14:20, John Winters wrote:
>
>> You make reference to "helpers" - can you provide any pointers to
>> those? I keep find myself going round and round in the documentation
>> in the area of Date/Time/DateTime, with one bit referring to another
>> bit, which refers you to a third bit and then back to the start, with
>> none of them providing the hard information.
>
>
> Oh Lord, this is actually a bit of a mess for complex cases, but if your
> use case is simple, it's dead easy.
>
> You might want to get familiar with i18n:
>
> http://guides.rubyonrails.org/i18n.html
[snip]
I've taken a look at that, but I *think* it's heading off in a different
direction from what I'm trying to achieve, and from searching other
queries found on the web it appears it doesn't even achieve what I want.
That covers how to get different date formats to appear for different
users, *in the body of your pages*. What it doesn't appear to do is
cover how to get different date formats to appear by default in your
fields. I've set up a skeletal test and whilst I can get:
my_date.to_s
to produce different strings depending on the format which I set up, a
text field still staunchly displays:
2011-07-26
regardless of any formats specified.
I'm currently digging through the Rails source (which is hard on the
eyes) trying to find out exactly what conversion the field helpers are
using, and whether it can be changed by configuration options.
Eventually I expect I'll get bored and just use the sledgehammer
approach which I started with, but I really hate that kind of messy
solution.
Cheers,
John
More information about the Chat
mailing list