Ruby on Rails Monday, December 3, 2012

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@mac.com>
[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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment