提交 881def43 编写于 作者: K Ken Mayer 提交者: Chris Osborn and Ken Mayer

Add (more) documentation to to_time

There's a difference in the results between `Date#to_time(:local)` and
`Date#in_time_zone` but it is subtle and can confuse users (like me :-).
上级 32a1c30f
......@@ -79,6 +79,9 @@ def readable_inspect
# date.to_time(:local) # => 2007-11-10 00:00:00 0800
#
# date.to_time(:utc) # => 2007-11-10 00:00:00 UTC
#
# NOTE: The :local timezone is Ruby's *process* timezone, i.e. ENV['TZ']
# If the *application's* timezone is needed, then use +in_time_zone+ instead
def to_time(form = :local)
raise ArgumentError, "Expected :local or :utc, got #{form.inspect}." unless [:local, :utc].include?(form)
::Time.send(form, year, month, day)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册