RailsCasts Pro episodes are now free!

Learn more or hide this

Shaun's Profile

GitHub User: shwing

Site: shaunrussell.com

Comments by Shaun

Avatar

figured it out:

tz_names = ActiveSupport::TimeZone.zones_map.values.collect{|z| z.name if z.utc_offset == offset}.compact!
Avatar

I am trying to query all of the Users that share a common time zone offset (so I can send them an email at a particular time everyday), and can not figure it out!

User.where(:time_zone => ['list','of time','zone names'])

How do I get a list of the time zone names for a particular offset? I've been tinkering with TzInfo and ActiveSupport::TimeZone.zones_map with limited success.

Am I taking the wrong approach here? I was thinking I could store the GMT offset on the user instead, and query that way?

My google-fu has let me down on this one.