I am storing a Time record w a timezone like : an event at 9:30 in Paris time (rdb:1) Time.zone = "Europe/Paris" "Europe/Paris" (rdb:1) Time.new(2012, 12, 3, 9, 30, 0).in_time_zone("Europe/Paris") Mon, 03 Dec 2012 09:30:00 CET +01:00 Now I want to store another event occurring also at 9:30 but in London time /London" (rdb:1) Time.new(2012, 12, 3, 9, 30, 0).in_time_zone("Europe/London") Mon, 03 Dec 2012 08:30:00 GMT +00:00 which is wrong .... I want this event at 9:30 GMT !! what''s wrong there ? thanks for feedback -- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/KbjGqEvgFW0J. For more options, visit https://groups.google.com/groups/opt_out.
Time. New uses the default system timezone when no one is given, so u say that you want 9:30 of your systems timezone in GMT, which is probably 8:30 GMT, depending on your local time zone. You have to add the corresponding parameter to Time. New. Take a look at its documentation. Am 03.12.2012 12:10 schrieb "Erwin" <yves_dufour-ee4meeAH724@public.gmane.org>:> I am storing a Time record w a timezone like : an event at 9:30 in > Paris time > > (rdb:1) Time.zone = "Europe/Paris" > "Europe/Paris" > (rdb:1) Time.new(2012, 12, 3, 9, 30, 0).in_time_zone("Europe/Paris") > Mon, 03 Dec 2012 09:30:00 CET +01:00 > > Now I want to store another event occurring also at 9:30 but in London time > /London" > (rdb:1) Time.new(2012, 12, 3, 9, 30, 0).in_time_zone("Europe/London") > Mon, 03 Dec 2012 08:30:00 GMT +00:00 > > which is wrong .... I want this event at 9:30 GMT !! > > what''s wrong there ? > thanks for feedback > > -- > 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 > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/KbjGqEvgFW0J. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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 https://groups.google.com/groups/opt_out.
Thanks Norbert, my issue is that I don''t see how to do that : As per the doc I can defined the time_zone to be used for a specific block (rdb:1) Time.use_zone("Europe/London"){ Time.now.in_time_zone } Mon, 03 Dec 2012 14:33:24 GMT +00:00 (rdb:1) Time.use_zone("Europe/Paris"){ Time.now.in_time_zone } Mon, 03 Dec 2012 15:33:41 CET +01:00 This is fine with Time.now , but not with a Time.new ... (rdb:1) Time.use_zone("Europe/London"){ Time.new(2012, 12, 3, 9, 30, 0) } 2012-12-03 09:30:00 +0100 (rdb:1) Time.use_zone("Europe/Paris"){ Time.new(2012, 12, 3, 9, 30, 0) } 2012-12-03 09:30:00 +0100 I cannot believe that there is no way to do the same for Time.new .. ? Le lundi 3 décembre 2012 12:21:01 UTC+1, Norbert Melzer a écrit :> > Time. New uses the default system timezone when no one is given, so u say > that you want 9:30 of your systems timezone in GMT, which is probably 8:30 > GMT, depending on your local time zone. > > You have to add the corresponding parameter to Time. New. Take a look at > its documentation. > Am 03.12.2012 12:10 schrieb "Erwin" <yves_...-ee4meeAH724@public.gmane.org <javascript:>>: > >> I am storing a Time record w a timezone like : an event at 9:30 in >> Paris time >> >> (rdb:1) Time.zone = "Europe/Paris" >> "Europe/Paris" >> (rdb:1) Time.new(2012, 12, 3, 9, 30, 0).in_time_zone("Europe/Paris") >> Mon, 03 Dec 2012 09:30:00 CET +01:00 >> >> Now I want to store another event occurring also at 9:30 but in London >> time >> /London" >> (rdb:1) Time.new(2012, 12, 3, 9, 30, 0).in_time_zone("Europe/London") >> Mon, 03 Dec 2012 08:30:00 GMT +00:00 >> >> which is wrong .... I want this event at 9:30 GMT !! >> >> what''s wrong there ? >> thanks for feedback >> >> -- >> 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 rubyonra...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<javascript:> >> . >> To unsubscribe from this group, send email to >> rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/rubyonrails-talk/-/KbjGqEvgFW0J. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> >-- 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. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/tmPtyuzpZOkJ. For more options, visit https://groups.google.com/groups/opt_out.
sorry I pasted the wrong test , but the result is the same Time.use_zone("Europe/London"){ Time.new(2012, 12, 3, 9, 30, 0).in_time_zone } Mon, 03 Dec 2012 08:30:00 GMT +00:00 # => I want 9:30 GMT there (rdb:1) Time.use_zone("Europe/Paris"){ Time.new(2012, 12, 3, 9, 30, 0).in_time_zone } Mon, 03 Dec 2012 09:30:00 CET +01:00 Le lundi 3 décembre 2012 12:10:34 UTC+1, Erwin a écrit :> > I am storing a Time record w a timezone like : an event at 9:30 in > Paris time > > (rdb:1) Time.zone = "Europe/Paris" > "Europe/Paris" > (rdb:1) Time.new(2012, 12, 3, 9, 30, 0).in_time_zone("Europe/Paris") > Mon, 03 Dec 2012 09:30:00 CET +01:00 > > Now I want to store another event occurring also at 9:30 but in London time > /London" > (rdb:1) Time.new(2012, 12, 3, 9, 30, 0).in_time_zone("Europe/London") > Mon, 03 Dec 2012 08:30:00 GMT +00:00 > > which is wrong .... I want this event at 9:30 GMT !! > > what''s wrong there ? > thanks for feedback > >-- 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. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/f4lSVyEzEtcJ. For more options, visit https://groups.google.com/groups/opt_out.
[SOLVED] Time.zone.local(2012, 12, 3, 9, 30, 0) inside the TIme.use_zone did it ... 1.9.3p194 :011 > Time.use_zone("Europe/London"){ Time.zone.local(2012, 12, 3, 9, 30, 0) } => Mon, 03 Dec 2012 09:30:00 GMT +00:00 1.9.3p194 :012 > Time.use_zone("Europe/Paris"){ Time.zone.local(2012, 12, 3, 9, 30, 0) } => Mon, 03 Dec 2012 09:30:00 CET +01:00 1.9.3p194 :013 > Time.use_zone("Asia/Singapore"){ Time.zone.local(2012, 12, 3, 9, 30, 0) } => Mon, 03 Dec 2012 09:30:00 SGT +08:00 Le lundi 3 décembre 2012 15:39:04 UTC+1, Erwin a écrit :> > sorry I pasted the wrong test , but the result is the same > > Time.use_zone("Europe/London"){ Time.new(2012, 12, 3, 9, 30, > 0).in_time_zone } > Mon, 03 Dec 2012 08:30:00 GMT +00:00 # => I want 9:30 GMT there > > (rdb:1) Time.use_zone("Europe/Paris"){ Time.new(2012, 12, 3, 9, 30, > 0).in_time_zone } > Mon, 03 Dec 2012 09:30:00 CET +01:00 > > > Le lundi 3 décembre 2012 12:10:34 UTC+1, Erwin a écrit : >> >> I am storing a Time record w a timezone like : an event at 9:30 in >> Paris time >> >> (rdb:1) Time.zone = "Europe/Paris" >> "Europe/Paris" >> (rdb:1) Time.new(2012, 12, 3, 9, 30, 0).in_time_zone("Europe/Paris") >> Mon, 03 Dec 2012 09:30:00 CET +01:00 >> >> Now I want to store another event occurring also at 9:30 but in London >> time >> /London" >> (rdb:1) Time.new(2012, 12, 3, 9, 30, 0).in_time_zone("Europe/London") >> Mon, 03 Dec 2012 08:30:00 GMT +00:00 >> >> which is wrong .... I want this event at 9:30 GMT !! >> >> what''s wrong there ? >> thanks for feedback >> >>-- 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. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Pz3yXdxhnxMJ. For more options, visit https://groups.google.com/groups/opt_out.
Time.new has a parameter for the timezone offset, use it, it would make your code more clean… http://www.ruby-doc.org/core-1.9.3/Time.html 2012/12/3 Erwin <yves_dufour-ee4meeAH724@public.gmane.org>> [SOLVED] Time.zone.local(2012, 12, 3, 9, 30, 0) inside the > TIme.use_zone did it ... > > > > 1.9.3p194 :011 > Time.use_zone("Europe/London"){ Time.zone.local(2012, 12, > 3, 9, 30, 0) } > => Mon, 03 Dec 2012 09:30:00 GMT +00:00 >Time.new(2012, 12, 3, 9, 30, 0, "+00:00")> > > 1.9.3p194 :012 > Time.use_zone("Europe/Paris"){ Time.zone.local(2012, 12, > 3, 9, 30, 0) } > => Mon, 03 Dec 2012 09:30:00 CET +01:00 >Time.new(2012, 12, 3, 9, 30, 0, "+01:00")> > 1.9.3p194 :013 > Time.use_zone("Asia/Singapore"){ Time.zone.local(2012, > 12, 3, 9, 30, 0) } > => Mon, 03 Dec 2012 09:30:00 SGT +08:00 >Time.new(2012, 12, 3, 9, 30, 0, "+08:00") -- 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 https://groups.google.com/groups/opt_out.