【发布时间】:2012-02-08 05:56:58
【问题描述】:
我正在使用 Ruby。我想将 UTC 转换为各种时间转换。我点击链接here。
我的代码是:
class TimeFormat
def convert_zone(to_zone)
original_zone = ENV["TZ"]
utc_time = dup.gmtime
ENV["TZ"] = to_zone
to_zone_time = utc_time.localtime
ENV["TZ"] = original_zone
return to_zone_time
end
end
t = TimeFormat.new
t.convert_zone("US/Pacific")
但它显示:
undefined method `gmtime' for #<TimeFormat:0x9043388> (NoMethodError)
这里有什么问题?
【问题讨论】: