From: Mike Shock Date: 2007-02-10T16:52:08+09:00 Subject: Re: Getting Time in specified timezone/offset Good time-of-the-day! ;-) Probably you need a DateTime object, which can be constructed (as 'ri DateTime' says) like this: date_time = DateTime.new(year, month, day, hour, min, sec, offset) where offset is given in fractions of day: e.g. 5/24.0 for an offset of +5 hours from UTC or GMT. Here's a sample: require 'date' t1 = DateTime.new(2007, 2, 10, 12, 38, 10, 5/24.0) printf "%s %s %s\n", t1, t1.offset.to_s, t1.zone # 2007-02-10T12:38:10+0500 0.208 +0500 Cheers - Mike Shock hemant wrote: > I have got following method in my code: > > > def to_time > if time? then > Time.mktime(year,month,day_of_month,hour,minute,second,usec) > else > Time.mktime(year,month,day_of_month) > end > end > > In my class, I also have timezone/utc offset as an attribute and above > method basically returns a Time object based on those attributes. > > But as you can see, Time.mktime is going to convert that time to local > zone and return that value. So, is there anyway to get a Time object > by passing above said attributes and timezone/offset in timezone > specified. That is, no automatic conversion to utc or local zone. > > >