I need a date/time object due to domain requirements although at this point I don't care about the time object, I just want it to be midnight. There are other ways for the user to enter data into this table where the time element becomes relevant.
Where do I have the rails source? Also do you know what file/class handles receiving a post request from a form? If anyone else is interested here's the code I'm using to reset the time to midnight. @gas_reading = @user.gas_readings.build(params[:gas_reading]) @gas_reading.start_date = @gas_reading.start_date.change(:hour => 0, :min => 0, :second => 0) unless @gas_reading.start_date.nil? @gas_reading.end_date = @gas_reading.end_date.change(:hour => 0, :min => 0, :second => 0) unless @gas_reading.end_date.nil? On Oct 14, 1:34 pm, Marnen Laibow-Koser <li...@ruby-forum.com> wrote: > voidstar wrote in post #950126: > > > Hey, > > Thanks for the reply, I could easily write some code to discard the > > time field, which is what I'll probably do now > > You don't have to discard anything. Just ignore it. > > Check Rails' field types; I think if you define the field in the > migration as date instead of datetime, you will get a Date object from > the DB, not the DateTime you currently have. > > > but I'd just like to > > know how rails is doing this, I guess is should go about downloading > > the rails source and grok it myself. > > You've already got the Rails source. > > > > > I'm in GMT but using daylight savings. > > > I guess if I just reset the time members of the DateTime object its > > returning to me I'm relatively insulated from errors if this > > translation changes in a future release. > > There's no need to reset. There's no translation, really; Rails is > creating a DateTime object, so it needs a time value. Again, you're > overthinking it and persuading yourself into more complex code than is > actually necessary. > > > > > Thanks > > Barry > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...@marnen.org > > -- > Posted viahttp://www.ruby-forum.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 rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.