From: Ken Bloom Date: 2007-08-16T23:39:58+09:00 Subject: Re: Any Muslims around? On Thu, 16 Aug 2007 17:07:43 +0900, Ronald Fischer wrote: >> Some awesome suggestions here, but I think it's a bit more complex >> considering how times vary from location to location. > > But you have the timezone for each location, right? If you use the > DateTime class for calculating times, you can convert between time > zones using the new_offset method, if you know the offset of the > respective time zone to UTC. > > If you only know the *name* of the time zone, there is a hack on how to > do it using the Time class, described in the "Ruby Cookbook" (which I > would recommend buying anyway). This hack works if your operating system > honours the TZ environment variable. You switch temporarily to this zone > (by changing TZ), get the local time there, and switch back to your own > zone. You then have the time diff to your zone, and you can always get > the time UTC time by calling Time#gmtime. > > Ronald I prefer the tzfile gem for dealing with timezones. --Ken -- Ken Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/