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.

This project is archived and is in readonly mode.

Time.to_s wonky

#877

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

Reported by Ian Moody · August 21st, 2008 @ 12:22 PM

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

Activity

  1. Jeremy Weiskotten
    Jeremy Weiskotten

    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?

    August 21st, 2008 @ 02:27 PM

  2. Pratik
    Pratik
    • State changed from new to invalid

    August 21st, 2008 @ 03:13 PM

  3. Pratik
  4. Geoff Buesing
    Geoff Buesing

    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.

    August 21st, 2008 @ 03:17 PM

  5. Ian Moody
    Ian Moody

    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.

    August 22nd, 2008 @ 09:37 AM

  6. a4490302sc
    a4490302sc
    • 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

    July 21st, 2010 @ 02:22 AM