This project is archived and is in readonly mode.

#942 ✓stale

ActiveResource time changed

Reported by Graphity | August 30th, 2008 @ 08:30 AM | in 3.x

It's like described in WhyNotWiki: You have an ActiveRecord model with a date attibute. When calling the show action in the controller in format xml, the dates shows up correctly.

But when you have a service that uses ActiveResource to get you model, the time is 2 hours before the one you entered.

For a workaround I tried to generate a, (old_time.hour+2), ...) but that doesn't handle hours past 22 (raises an ArgumentError (out of range).

Comments and changes to this ticket

  • Graphity

    Graphity August 30th, 2008 @ 08:42 AM

    Oh, ok, I just saw that adding hours is done by old_time+2.hours Ok, but the bug remains...

  • Geoff Buesing

    Geoff Buesing August 30th, 2008 @ 01:03 PM

    Ideally, you'd be able to pull together a failing test case to prove this. Second best would be some script/console output that shows the issue.

    Also let us know which version of Rails you're using, and, if you're setting config.time_zone, what that's set to. Thanks.

  • Graphity

    Graphity August 30th, 2008 @ 09:34 PM

    Ok, I built two RoR Applications (Producer and Consumer). And now I'm uploading both of them in one ZIP ( Try the XML Output, you'll see two different times in the created-at attribute. Sorry if that's the wrong way but it's my first bug report.

  • Graphity

    Graphity September 6th, 2008 @ 11:01 AM

    To add to my workaround: First I added the 2hours in a method in controllers/application.rb which, of course, is wrong. Those 2h should be added in the model resulting in a line like def start attributes["start"] = attributes["start"] + 2.hours end

    where start is the attribute of type Time.

    Oh yes, I' using Rail 2.0.2

  • Graphity

    Graphity September 10th, 2008 @ 10:35 AM

    Hm, ok, I just deployed my app to the server and realized there is NO time-shifting. A friend suggested to look at the timezones and, really, there is the difference: My dev-system displays in its XML sth like 2008-09-06T17:45:08+02:00 where my production system displays 2008-09-10T11:28:29+00:00 (mind the +00:00 and +02:00 at the end).

  • Graphity

    Graphity September 10th, 2008 @ 11:05 AM

    Ok, so, my current workaround is:

    def start
      attributes["start"] = attributes["start"] +

    in my model.

    I realized, while using the rails console, the server which gets the date from the DB displays

    start: 2008-09-10 11:48:00

    while the server which gets the date from ARes displays

    start: 2008-09-10 09:48:00 Z

    The timezone in the dev-system says its GMT+1 in Daylight Savings Time while the production-system says UTC

  • Dan Barry

    Dan Barry October 12th, 2008 @ 10:50 PM

    There has been a whole bunch of time zone magic added in Rails 2.1, so you may want to consider upgrading to take advantage of this. Geoff's article about this explains all the new improvements.

  • Pratik

    Pratik January 18th, 2009 @ 06:57 AM

    • State changed from “new” to “incomplete”
  • Ryan Bigg

    Ryan Bigg April 10th, 2010 @ 11:27 AM

    • Assigned user set to “Mikel Lindsaar”

    The times returned from the controller should be UTC by default, unless you are setting / config.time_zone to something else.

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 05:05 PM

    • State changed from “incomplete” to “open”
    • Importance changed from “” to “”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 05:05 PM

    • State changed from “open” to “stale”

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=""></a>