Hello, I''ve Googled and searched for this for many hours now and couldn''t find an answer although I did find a lot about timezones and rails. Specifically I''m attaching a basic Rails CRUD frontend onto a legacy database. The datetime fields in the database are stored as Eastern Standard Time. There is a lot of legacy code that uses this database and is expecting to get back times in EST, so I can''t change them to UTC. Is there a way in Rails to tell ActiveRecord to use Eastern for storing the datetime fields? I''ve tried a number of combinations for config.time_zone and config.active_record.default_timezone. FYI, rake time:zones:local returns * UTC -06:00 * Central Time (US & Canada). Any ideas would be greatly appreciated. Thanks, -Jonathan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2010-Mar-26 21:25 UTC
Re: Timezone issue with legacy data stored in Eastern time
On 26 March 2010 18:58, J Graham <jkgraham-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > I''ve Googled and searched for this for many hours now and couldn''t > find an answer although I did find a lot about timezones and rails. > > Specifically I''m attaching a basic Rails CRUD frontend onto a legacy > database. The datetime fields in the database are stored as Eastern > Standard Time. There is a lot of legacy code that uses this database > and is expecting to get back times in EST, so I can''t change them to > UTC. > > Is there a way in Rails to tell ActiveRecord to use Eastern for > storing the datetime fields? > > I''ve tried a number of combinations for config.time_zone and > config.active_record.default_timezone. FYI, rake time:zones:local > returns * UTC -06:00 * Central Time (US & Canada).You could use filters to offset the times by six hours on save and read. Alternatively you could tell rails that it is working in UTC then local and UTC times will be the same. If all your times are actually then in EST all will be well. Just don''t let on to rails that you are lying to it. You might have to fiddle a bit if you do Time.now though. There may well be better ways though. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Lasse Bunk
2010-Mar-26 21:43 UTC
Re: Timezone issue with legacy data stored in Eastern time
Jonathan, You could use "Eastern Time (US & Canada)" as your timezone? Like this: config.time_zone = ''Eastern Time (US & Canada)'' Would this do the trick? /Lasse 2010/3/26 J Graham <jkgraham-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> Hello, > > I''ve Googled and searched for this for many hours now and couldn''t > find an answer although I did find a lot about timezones and rails. > > Specifically I''m attaching a basic Rails CRUD frontend onto a legacy > database. The datetime fields in the database are stored as Eastern > Standard Time. There is a lot of legacy code that uses this database > and is expecting to get back times in EST, so I can''t change them to > UTC. > > Is there a way in Rails to tell ActiveRecord to use Eastern for > storing the datetime fields? > > I''ve tried a number of combinations for config.time_zone and > config.active_record.default_timezone. FYI, rake time:zones:local > returns * UTC -06:00 * Central Time (US & Canada). > > Any ideas would be greatly appreciated. > > Thanks, > -Jonathan > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2010-Mar-27 08:47 UTC
Re: Timezone issue with legacy data stored in Eastern time
On 26 March 2010 21:43, Lasse Bunk <lassebunk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Jonathan, > > You could use "Eastern Time (US & Canada)" as your timezone? Like this: > > config.time_zone = ''Eastern Time (US & Canada)'' > > Would this do the trick?No, because it expects the times in the db to be in UTC and will convert them (wrongly) to EST on reading and writing. Colin> /Lasse > > 2010/3/26 J Graham <jkgraham-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> >> Hello, >> >> I''ve Googled and searched for this for many hours now and couldn''t >> find an answer although I did find a lot about timezones and rails. >> >> Specifically I''m attaching a basic Rails CRUD frontend onto a legacy >> database. The datetime fields in the database are stored as Eastern >> Standard Time. There is a lot of legacy code that uses this database >> and is expecting to get back times in EST, so I can''t change them to >> UTC. >> >> Is there a way in Rails to tell ActiveRecord to use Eastern for >> storing the datetime fields? >> >> I''ve tried a number of combinations for config.time_zone and >> config.active_record.default_timezone. FYI, rake time:zones:local >> returns * UTC -06:00 * Central Time (US & Canada). >> >> Any ideas would be greatly appreciated. >> >> Thanks, >> -Jonathan >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Lasse Bunk
2010-Mar-27 11:47 UTC
Re: Timezone issue with legacy data stored in Eastern time
Jonathan? 2010/3/27 Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>> On 26 March 2010 21:43, Lasse Bunk <lassebunk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Jonathan, > > > > You could use "Eastern Time (US & Canada)" as your timezone? Like this: > > > > config.time_zone = ''Eastern Time (US & Canada)'' > > > > Would this do the trick? > > No, because it expects the times in the db to be in UTC and will > convert them (wrongly) to EST on reading and writing. > > Colin > > > > /Lasse > > > > 2010/3/26 J Graham <jkgraham-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >> > >> Hello, > >> > >> I''ve Googled and searched for this for many hours now and couldn''t > >> find an answer although I did find a lot about timezones and rails. > >> > >> Specifically I''m attaching a basic Rails CRUD frontend onto a legacy > >> database. The datetime fields in the database are stored as Eastern > >> Standard Time. There is a lot of legacy code that uses this database > >> and is expecting to get back times in EST, so I can''t change them to > >> UTC. > >> > >> Is there a way in Rails to tell ActiveRecord to use Eastern for > >> storing the datetime fields? > >> > >> I''ve tried a number of combinations for config.time_zone and > >> config.active_record.default_timezone. FYI, rake time:zones:local > >> returns * UTC -06:00 * Central Time (US & Canada). > >> > >> Any ideas would be greatly appreciated. > >> > >> Thanks, > >> -Jonathan > >> > >> -- > >> You received this message because you are subscribed to the Google > Groups > >> "Ruby on Rails: Talk" group. > >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> To unsubscribe from this group, send email to > >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > >> For more options, visit this group at > >> http://groups.google.com/group/rubyonrails-talk?hl=en. > >> > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > > For more options, visit this group at > > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.