Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

text_field tag has incorrect time

#1380

I'm working on an app where I have my time_zone set to something not UTC: config.time_zone = 'Central Time (US & Canada)'

When I go to edit a model in my app for that time zone, text_field returns the incorrect time. The datetime_select tag returns the correct time though.

So pretty much, this works and returns the time based on the offset:

= f.datetime_select :posted_at

and this one doesn't:

= f.text_field :posted_at

Thanks and keep up the good work!

Reported by David Parker · November 15th, 2008 @ 06:58 PM

State: wontfix
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Geoff Buesing
    Geoff Buesing
    • State changed from new to wontfix

    Hmm, I agree that's not what you'd expect to see, but it would be pretty hard to fix this, given that text_field is built with the _before_type_cast version of the attribute.

    But even if we could fix this, I'm skeptical that the default presentation would be valuable -- the user would see a value like this:

    
    2008-11-20 17:35:09 -0600
    

    ... a db-like output, with an offset string -- I think you'd want friendlier formatting for the user.

    You can currently achieve this via text_field_tag -- something like:

    
    text_field_tag "post[publish_at]", @post.publish_at.to_s(:my_friendly_format)
    

    December 2nd, 2008 @ 01:05 AM

  2. David Parker
    David Parker

    Thanks for checking this out Geoff.

    December 2nd, 2008 @ 01:15 AM