I am working on a Rails application that needs to handle dates and times in users' time zones. We have recently migrated it to Rails 2.1 and added time zone support, but there are numerous situations in which we use Time#utc and then compare against that time. Wouldn't that be the same as comparing against the original Time object?
When is it appropriate to use Time#utc in Rails 2.1? When is it inappropriate?
Simply put, time-ins are inclusionary timeouts. The parent or caregiver removes a child from a situation to stop their misbehaviour. In contrast to timeouts, during time-in discipline, the parent stays with the child until he or she is calm. Because this resonates with me, I did my best to be there for my little guy.
Wait until your child is at least 3 years old to introduce time-outs. Before that age, he'll feel he's being punished but won't understand why, since he can't yet connect his actions with your reactions.
Parenting experts have criticized the timeout technique in recent years, saying that it might neglect a child's emotional needs. Most experts agree that punishment is harmful to a child's emotional development and that isolation — the defining quality of the timeout technique — is a form of punishment.
If you've set:
config.time_zone = 'UTC'
In your environment.rb (it's there by default), then times will automagically get converted into UTC when ActiveRecord stores them.
Then if you set Time.zone (in a before_filter on application.rb is the usual place) to the user's Time Zone, all the times will be automagically converted into the user's timezone from the utc storage.
Just be careful with Time.now.
Also see:
http://mad.ly/2008/04/09/rails-21-time-zone-support-an-overview/
http://errtheblog.com/posts/49-a-zoned-defense - you can use the JS here to detect zones
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With