From: ara.t.howard@... Date: 2006-08-09T06:20:15+09:00 Subject: Re: solar local time On Wed, 9 Aug 2006, Tim Pease wrote: > ZONES = class << Time; ZoneOffset.keys.map {|x| x.length == 1 ? x : > nil}.compact.sort; end > ZONES.unshift ZONES.pop > > def move_to_zone( utc, longitude ) > zone = ZONES[Integer(longitude) / Integer(DEG_PER_HR)] > utc - Time.zone_offset(zone) > end > > This does not take into account daylight savings, etc. But give it a > shot and see if it's what you need. it's close, but check this out: harp:~ > cat a.rb require 'time' class Time ZONES = class << self (_ = ZoneOffset.keys.select{|z| z.size == 1}.sort).unshift(_.pop) end def translated longitude zone = ZONES[Integer(longitude) / 15] utc - Time.zone_offset(zone) end end t = Time.parse('1999-12-31T23:59:59Z') or 'party like it is' require 'yaml' [0, 15, 16, 30, 31].each do |degrees| y degrees => t.translated(degrees).iso8601 y -degrees => t.translated(-degrees).iso8601 end harp:~ > ruby a.rb 0: "1999-12-31T23:59:59Z" 0: "1999-12-31T23:59:59Z" 15: "1999-12-31T22:59:59Z" -15: "2000-01-01T11:59:59Z" 16: "1999-12-31T22:59:59Z" -16: "2000-01-01T10:59:59Z" 30: "1999-12-31T21:59:59Z" -30: "2000-01-01T10:59:59Z" 31: "1999-12-31T21:59:59Z" -31: "2000-01-01T09:59:59Z" take one example 15: "1999-12-31T22:59:59Z" the time is correct but the zone is not. consider, 15 degrees to the east of 0 longitude at '1999-12-31T23:59:59Z' the solar local time is '1999-12-31T22:59:59+01:00' make sense? -a -- to foster inner awareness, introspection, and reasoning is more efficient than meditation and prayer. - h.h. the 14th dali lama