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.

.utc modifies time object

#4543

A call to utc modifies the object itself.


t = Time.now => Thu May 06 16:15:14 +0200 2010 t.utc => Thu May 06 14:15:14 UTC 2010 t => Thu May 06 14:15:14 UTC 2010

It shouldn't be like that or the method should be called .utc!

Reported by SukiSan · May 6th, 2010 @ 03:19 PM

State: invalid
Milestone: none
Assigned to: Ryan Bigg Ryan Bigg
Importance: Low

Activity

  1. SukiSan
    SukiSan
    • No changes were found…

    May 6th, 2010 @ 03:20 PM

  2. SukiSan
    SukiSan
    • Tag changed from utc time zone to utc

    hurk, sorry for bad format and the useless change - I'm new here :-)

    t = Time.now
    => Thu May 06 16:15:14 0200 2010

    t.utc
    => Thu May 06 14:15:14 UTC 2010

    t
    => Thu May 06 14:15:14 UTC 2010

    May 6th, 2010 @ 03:26 PM

  3. ronin-18448 (at lighthouseapp)
    ronin-18448 (at lighthouseapp)

    I don't think this is a Rails problem, Time is a Ruby class. This has nothing to do with Rails if I'm right.

    May 6th, 2010 @ 04:14 PM

  4. Neeraj Singh
    Neeraj Singh

    As Simon said it is ruby that is exhibiting the behavior mentioned by Suki.

    Suki: In your test the time displayed in the first case and time displayed in the third case is the same time. The only thing is that first one has time in local format and the third one is in UTC format. But the value of t has not changed the way it displays the internal data has changed.

    May 6th, 2010 @ 04:39 PM

  5. SukiSan
    SukiSan

    Well, yeah sure...

    The thing that actually confused me was

    date = Time.local(2010, 3, 1)
    date.utc
    date.end_of_month.utc # == end of feb

    Even that makes sense now. Altough it is confusing that .utc has side effects on the object.

    May 6th, 2010 @ 07:05 PM

  6. Dan Pickett
    Dan Pickett
    • Assigned user set to Ryan Bigg

    Passing to Ryan for cleanup. This is a Ruby behavior so this issue should likely be marked as "invalid" or "wontfix"

    May 9th, 2010 @ 06:46 PM

  7. Ryan Bigg
    Ryan Bigg
    • State changed from new to invalid

    May 9th, 2010 @ 10:17 PM