I have dstring as saved in UTC. While I have user\'s timezone\'s offset standard_offset
What I want to show that date in user\'s timezone after con
require 'tzinfo'
class Time
def in_timezone(tzstring)
tz = TZInfo::Timezone.get(tzstring)
p = tz.period_for_utc(self.utc)
# puts "#{tzstring} -> utc_offset=#{p.utc_offset},utc_total_offset=#{p.utc_total_offset},p.offset=#{p.offset}"
e = self.utc + p.utc_total_offset
"#{e.strftime('%Y-%d-%m %H:%M:%S')} #{p.zone_identifier}"
end
end
[Time.parse("2013-10-20T21:19:00Z"), Time.parse("2013-11-20T21:19:00Z")].each do |t|
puts '=======================================================> ' + t.to_s
puts "\t" + t.in_timezone('GMT')
puts "\t" + "------------------"
puts "\t" + t.in_timezone('Europe/London')
puts "\t" + t.in_timezone('Europe/Prague')
puts "\t" + t.in_timezone('Asia/Jerusalem')
end