看來Time.zone.local
確實是你想象的Time.zone.new
會做的。雖然,Time.zone.new
不存在。爲什麼這個獨特的命名偏離了標準?爲什麼叫'Time.zone.local'而不是'Time.zone.new'?
更新: 問題是關於理解Rails爲什麼會偏離使用.new
來實例化某個特定類型的新對象時的慣例。通過使用例如Time.zone.local(2013,10,1)
而不是即Time.zone.new(2013,10,1)
來獲得TimeWithZone
對象。
你指的是['now'](http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html#method-i-now)而不是'new'嗎? – schmijos
@ndn不是'ActiveSupport :: TimeZone',而是'Time',對嗎? – schmijos
我投票結束這個問題作爲題外話,因爲它與編程無關。 – kabanus