(Stuck in Ruby 1.8.6 land)
Until recently I was using Time to parse UTC dates and print them in a local timezone
dt = Time.parse("20111225080000Z")
puts dt.localtime
Sun Dec 25 21:00:00 +1300 2011
puts dt.zone
"New Zealand Daylight Time"
Unfortunately the limits 1901 and 2034 finally got in the way and so I tried to use DateTime
dt = DateTime.parse(date)
But I cant find an equivalent to .localtime
dt.timezone is of course +00:00
DateTime.now().zone is +13:00
I went to use that but realized if the date being converted was NOT in Daylight Time the answer would be wrong. Note the Time
class gets it correct, and converts the time to the localtime
(not a specific timezone or offset) - midwinter => Standard time.
dt = Time.parse("20110725080000Z")
puts dt.localtime
Sun Jul 25 21:00:00 +1200 2011
puts dt.zone
"New Zealand Standard Time"
For DateTime
class, where is the equivalent of asking for my local time without specifying an exact (and possibly incorrect timezone)?