Hey guys, I have some code here:
http://github.com/cjwoodward/proper_time_zones I have removed a bunch of other tests but I'd be interested to get the one test working. To test it get the code out and run bacon test.rb Then change the system time to 7am and re-run the tests. I'd love to here that I am doing stupid things (most likely to be the case). Cheers, Carl. Carl Woodward 0412218979 [email protected] On Tue, Oct 6, 2009 at 9:50 PM, Ryan Bigg <[email protected]> wrote: > If all times in the DB are UTC then you should be able to do > loaded_on.utc... I feel as if I'm missing a crucial point of this. Your > "solution" seems too complex. > > 2009/10/6 Carl Woodward <[email protected]> >> >> Hey guys, >> >> Jeremy and I have been having discussions about the right way to get >> time zones working in rails. >> >> We are storing dates as UTC and displaying the time back works fine. >> >> The problem occurs when you need to query for items on a date. We end >> up with code like: >> >> named_scope :by_date, lambda{ |loaded_on| >> {:conditions => ["date(preferred_time + interval '10 hour') = >> date(?)", loaded_on.to_date]} >> } >> >> NOTE: we are using postgres. >> >> Or: >> >> Time.zone.local_to_utc loaded_at.to_date.to_time >> >> >> All of which are crap. >> >> We are even thinking of putting this stuff into a plugin and making it >> happen automagically but I struggle to believe that this problem >> hasn't been solved before. In other apps that I have done before I >> tend to just hack it till it works but I would really like to solve >> this problem. >> >> I'm just wondering if anyone has a nicer solution for this stuff? >> >> Let me know? >> >> Cheers, >> Carl. >> >> >> Carl Woodward >> 0412218979 >> [email protected] >> >> > > > > -- > Ryan Bigg > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en -~----------~----~----~----~------~----~------~--~---
