提交 4788d7fd 编写于 作者: R Rafael Mendonça França

Merge pull request #21281 from ronakjangir47/added_docs

Added docs for TimeWithZone [ci skip]
......@@ -246,6 +246,7 @@ def future?
utc.future?
end
# Returns +true+ if +other+ is equal to current object.
def eql?(other)
other.eql?(utc)
end
......@@ -329,6 +330,11 @@ def #{method_name} # def month
EOV
end
# Returns Array of parts of Time in sequence of
# [seconds, minutes, hours, day, month, year, weekday, yearday, dst?, zone].
#
# now = Time.zone.now # => Tue, 18 Aug 2015 02:29:27 UTC +00:00
# now.to_a # => [27, 29, 2, 18, 8, 2015, 2, 230, false, "UTC"]
def to_a
[time.sec, time.min, time.hour, time.day, time.mon, time.year, time.wday, time.yday, dst?, zone]
end
......@@ -358,11 +364,14 @@ def to_r
utc.to_r
end
# Return an instance of Time in the system timezone.
# Returns an instance of Time in the system timezone.
def to_time
utc.to_time
end
# Returns an instance of DateTime in the UTC timezone.
#
# Time.zone.now.to_datetime # => Tue, 18 Aug 2015 02:32:20 +0000
def to_datetime
utc.to_datetime.new_offset(Rational(utc_offset, 86_400))
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册