On 23 August 2011 12:00, Jim Ruther Nill <[email protected]> wrote:
>
>
> On Tue, Aug 23, 2011 at 4:00 PM, Colin Law <[email protected]> wrote:
>>
>> On 23 August 2011 08:55, Jim Ruther Nill <[email protected]> wrote:
>> > Hi guys,
>> >
>> > This ugrade to 3.0.10 is giving me headaches.  Using 3.0.3, the time
>> > zone
>> > was set at Brisbane.  All
>> > times parsed from the params are correctly parsed, ie
>> > in the browser, the time is set to Aug 23, 2011 2:52pm so in the server,
>> > you'd expect the param to be
>> > Tue, 23 Aug 2011 14:52:00 EST +10:00.  This is in Rails 3.0.3 and works
>> > great.
>> > In Rails 3.0.10, the same time would parse to Wed, 24 Aug 2011 00:52:00
>> > EST
>> > +10:00, an offset of 10 hours,
>> > which is caused by the +10 offset of Brisbane's timezone with UTC.
>> > What's the correct behavior? Any advice on how to get the behavior in
>> > 3.0.3? Thanks!
>>
>> Assuming the date is being posted from a form, what are the actual
>> values in the params hash and how are you parsing that?
>>
>
> Hey Colin,
> Yes, the dates are being posted from the form.  And I don't do any special
> parsing, I just assign the
> params to a record using either #new or #update_attributes.  To make it
> clearer,
> @post = Post.new params[:post] # params[:post][:start_at] contains the time
> string from the form
> Assuming that params[:post][:start_at] = Aug 23, 2011 2:52pm
>>> @post.start_at # Tue, 23 Aug 2011 14:52:00 EST +10:00 for 3.0.3
>>> @post.start_at # Wed, 24 Aug 2011 00:52:00 EST +10:00 for 3.0.10

So it appears that 3.0.3 is taking the string as local time, but
3.0.10 was taking it as UTC.  I would have thought that assuming UTC
was probably the best choice for rails to make, as it has no way of
knowing what timezone the user is in.  It is a bit dangerous to allow
the user to enter a string and then let Rails parse it (if that is
what you are doing).  There are many ways the user could enter an
invalid string.  Make sure you catch the exceptions.  If you know what
timezone the user is in then you could append that to the start_at
string in params before using it.

Colin

>
>>
>> Colin
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails: Talk" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>
>
>
>
> --
> -------------------------------------------------------------
> visit my blog at http://jimlabs.heroku.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to