I''ve run into the following issue: My app has multiple users from multiple timezones. In the majority of cases, I want datetime columns to take into account the user''s timezone. This works fine. However, for *one* particular datetime field, I want users to enter the arrival date & time of a flight that is arriving into a country in a different timezone to the user''s timezone. Hence I don''t want any timezone conversion done on this particular field. e.g. a user in Germany enters the data for a flight that will arrive in New Zealand on January 1st at 2:00pm. When a different user views this data, I want it to say 2:00pm, regardless of the user''s timezone. I don''t see that the datetime_select helper allows me to specify a timezone for the time I am selecting; but anyway, I don''t want the user to have to enter a timezone. I suppose the easiest (only?) solution is to store the data in separate date and time fields in the database, and use separate date_select and time_select helpers. Any comments? Should this functionality be something that datetimes / datetime_select should support? Cheers Dave --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Dave, You can currently opt out of time zone aware attributes for specific attributes like so: class Flight < ActiveRecord::Base ... self.skip_time_zone_conversion_for_attributes [:departure_time, :arrival_time] ... end With this setup, no time zone conversions will be done for Flight#departure_time and #arrival time. Does this give you what you need? Geoff On Nov 25, 6:42 pm, Dave Rothlisberger <droth...@gmail.com> wrote:> I''ve run into the following issue: > > My app has multiple users from multiple timezones. In the majority of > cases, I want datetime columns to take into account the user''s > timezone. This works fine. > > However, for *one* particular datetime field, I want users to enter > the arrival date & time of a flight that is arriving into a country in > a different timezone to the user''s timezone. Hence I don''t want any > timezone conversion done on this particular field. > > e.g. a user in Germany enters the data for a flight that will arrive > in New Zealand on January 1st at 2:00pm. When a different user views > this data, I want it to say 2:00pm, regardless of the user''s timezone. > > I don''t see that the datetime_select helper allows me to specify a > timezone for the time I am selecting; but anyway, I don''t want the > user to have to enter a timezone. > > I suppose the easiest (only?) solution is to store the data in > separate date and time fields in the database, and use separate > date_select and time_select helpers. > > Any comments? Should this functionality be something that datetimes / > datetime_select should support? > > Cheers > Dave--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Dave Rothlisberger
2008-Nov-26 16:13 UTC
Re: Handling cases when a timezone isn''t applicable
Yes! That''s exactly what I need. Thank you very much -- far nicer than overriding arrival_time and arrival_time= which is what I had ended up doing. On Nov 26, 1:12 am, Geoff B <gbues...@gmail.com> wrote:> Dave, > > You can currently opt out of time zone aware attributes for specific > attributes like so: > > class Flight < ActiveRecord::Base > ... > self.skip_time_zone_conversion_for_attributes > [:departure_time, :arrival_time] > ... > end > > With this setup, no time zone conversions will be done for > Flight#departure_time and #arrival time. > > Does this give you what you need? > > Geoff > > On Nov 25, 6:42 pm, Dave Rothlisberger <droth...@gmail.com> wrote: > > > I''ve run into the following issue: > > > My app has multiple users from multiple timezones. In the majority of > > cases, I want datetime columns to take into account the user''s > > timezone. This works fine. > > > However, for *one* particular datetime field, I want users to enter > > the arrival date & time of a flight that is arriving into a country in > > a different timezone to the user''s timezone. Hence I don''t want any > > timezone conversion done on this particular field. > > > e.g. a user in Germany enters the data for a flight that will arrive > > in New Zealand on January 1st at 2:00pm. When a different user views > > this data, I want it to say 2:00pm, regardless of the user''s timezone. > > > I don''t see that the datetime_select helper allows me to specify a > > timezone for the time I am selecting; but anyway, I don''t want the > > user to have to enter a timezone. > > > I suppose the easiest (only?) solution is to store the data in > > separate date and time fields in the database, and use separate > > date_select and time_select helpers. > > > Any comments? Should this functionality be something that datetimes / > > datetime_select should support? > > > Cheers > > Dave--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---