Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Time.zone is not respected when parsing dates #1
When I submit a query such as SELECT * WHERE created_at >= datetime 'March 08, 2012 03:00:00' I would expect the parsing of that timestamp to respect the time zone set in Time.zone.
I tried to fix this first in rgviz-rails Rgviz::Executor#column_value before realizing this was the wrong method :( The method I am looking for is Rgviz::Parser#parse_atomic_column but I am not sure how to fix it. Time.zone seems to be a rails enhancement and rgviz is supposed to work without rails. So, I think the fix should go in rgviz-rails, but I am not coming up with a good way to do it. Thoughts?
Hmmm... it seems to be a Rails problem, I think. Take a look at this:
I see this in config/application.rb:
Shouldn't the default be what Time.now.zone returns instead of UTC?
What you can do, for your specific app, is to set the TZ environment variable:
It's bad that you have to specify it in the environment variable and in the Rails configuration, though.
Do you think setting the env var is enough, or we think of something else? Maybe put the date/time parsing logic in public, overridable methods in Rgviz::Parser, and let rgviz-rails override them. I think defining a configuration for this might be overkill. :-P
What do you think?
Also, can I put your name, Brad Seefeld, in the list of contributors? :-)
Yes, you may put my name in the contributors.
I am not so sure its a Rails problem. I am still getting accustomed to how they manage time zones, but I think its the expected behavior. How I understand it:
So what I would want to do in
I think the safest (though maybe not cleanest) solution is to define the parsing as methods which can be overriten, and override them in rgviz-rails. If another framework does it in another way, it just needs to override that method, no need to change the code again.