Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Respect Time.zone #6

merged 7 commits into from Mar 9, 2012


None yet
2 participants

bradseefeld commented Mar 9, 2012

This addresses the bug filed here: asterite/rgviz#1

Specs included.

I didnt 'fix' date parsing. I wasnt sure if this is something that should be addressed as I typically do not consider time zones when working with Date's. I am thinking the current date parsing is the expected behavior.


asterite commented Mar 9, 2012

Looks fine. GitHub says I can't merge it automatically, probably because I commited to master (I just overwrote Rgviz::Parser, but I like your way of subclassing it better).

How can I merge the two forks?


bradseefeld commented Mar 9, 2012

I am not entirely sure. I have not accepted a pull request before... I imagine there is a way to manually resolve the conflict? If not, you could always revert the commit.


bradseefeld commented Mar 9, 2012

I was reading on this a bit and I think the common approach is for me to merge the upstream master and resolve conflicts. My latest commit merges your changes.

asterite added a commit that referenced this pull request Mar 9, 2012

@asterite asterite merged commit 53f627a into asterite:master Mar 9, 2012


asterite commented Mar 9, 2012

There, I just pushed version 0.63 of this gem. I use to push gems often... I hope that doesn't slow down rubygems. :-P


asterite commented Apr 20, 2012

Hi Brad,

I'm not sure the pull request is correct. Try doing this:

  1. In spec/rgviz_rails/executor_spec.rb add the following to the before(:each) block:

    Time.zone = "Cairo"

Run the specs. You will see two tests fail because the label is incorrect. For the labels I use strftime of the parsed date/time values, but since you are changing their time by subtracting the timezone offset, it fails.

I'm not sure what's the point of subtracting the timezone offset. What's wrong about using Time.zone.parse to parse the time? If you are on a Rails app that's what you would expect to use... no? You wrote "TimeWithZone is not formatted as UTC when its used in ActiveRecord" but why do you need this? Is this a requirement of your app?

I need to understand more about this... I added the project to travis ci and it failed because Time.zone must be set to something different than GMT.


bradseefeld commented Apr 20, 2012

I had not given any consideration to labels. :(

My comments regarding TimeZoneWith might be best understood with an example. Suppose 1:00am is sent to the server in a query. If we use Time.zone.parse, this would be parsed as 1:00am PST (my timezone) and would be correct. The parsed time object is a TimeWithZone. When this value gets used in SQL via ActiveRecord, it has a string value of "1:00am" again. The correct value should be 1:00am - 7 hours (the UTC offset for PST). Essentially, TimeWithZone does not respect the timezone that our db is in. So SQL queries end up being off by some offset.

The goal of subtracting the offset is to get the time into the correct UTC time since this is the internal representation of Time anyway. I am on vacation now so I wont be able to really look into this further until next week. If this is urgent, hopefully my comments help shed some light on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment