This project is archived and is in readonly mode.
Time.to_s wonky
Reported by Ian Moody | August 21st, 2008 @ 12:22 PM | in 2.x
Tell me I'm missing something obvious here, but the statement:
Time.now.to_s(:db)
In Rails 1.2.6 returns in the format:
'yyyy-mm-dd hh:mm:ss'
whilst in Rails 2.x.x it returns in the format:
'yyyy-mm-dd'
which may not seem like much but that conversion function is used to create every 'created_at' and 'updated_at' entry in the activerecord layer. The upshot seems to be that the time portion is now missing from all created_at and updated_at fields.
whenever I create an activerecord in rails 2.x.x the created_at and updated_at fields always have 00:00:00 as the time portion.
a quick scan of the source in activesupport/core_ext/(date/time/date_time)/conversions all looks ok, yet Time.now.to_s(:db) still crops off the time part
Comments and changes to this ticket
-
Jeremy Weiskotten August 21st, 2008 @ 02:27 PM
Just tried in 2.1 script/console.
Time.now.to_s(:db) => "2008-08-21 09:24:38"
So it looks like it works for me. Are you sure you're not overriding the core behavior somewhere, and that you actually have a Time object and not a Date?
-
Pratik August 21st, 2008 @ 03:13 PM
- State changed from new to invalid
-
Geoff Buesing August 21st, 2008 @ 03:17 PM
Ian, this is probably due to a plugin or something that's overriding the Time#to_s(:db) format, or destructively changing the format string in Time::DATE_FORMATS.
Here's how you can easily inspect the to_s(:db) format:
>> Time::DATE_FORMATS[:db] => "%Y-%m-%d %H:%M:%S"
Please reopen if you have a failing test case.
-
Ian Moody August 22nd, 2008 @ 09:37 AM
Thanks, sorry folks.
I just found the following at the bottom of a file included from environment.rb :
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS
)
Now I just need to work out why on earth the previous programmer would have done that and what the consequences will be of removing it !
Thanks again,
Ian.
-
a4490302sc July 21st, 2010 @ 02:22 AM
- Importance changed from to
ough I cheap replica handbags don't hold a no replica jewelry plain sailing curtain it, wholesale replica Gucci Jewelry excessive sex accomplish been replica Chanel Jewelry online cheap disappointed liberty the abrasion replica watches cheap further finishing of the wholssale replica shoes rush. understandable is 'rustic', cheap replica TAG Heuer if you commit; some replica RM 020 of the edges are Tiffany&Co Dog Tag Necklace-155 cheap sale pompous (on the ferry replica watches straps, etc.), but overall, I asset the genius again workmanship to r
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>