diff options
author | Ronak Jangir <ronakjangir47@gmail.com> | 2015-08-18 08:17:54 +0530 |
---|---|---|
committer | Ronak Jangir <ronakjangir47@gmail.com> | 2015-08-18 12:08:04 +0530 |
commit | ef9caad63e9d86c3bfe7efb4ff7b917d3327bc8c (patch) | |
tree | f13e156d9a76dcc2de5e4d26cd069a3403d21f67 /activesupport | |
parent | 352da06503e96a2aa6ef40342060deb1f07ed683 (diff) | |
download | rails-ef9caad63e9d86c3bfe7efb4ff7b917d3327bc8c.tar.gz rails-ef9caad63e9d86c3bfe7efb4ff7b917d3327bc8c.tar.bz2 rails-ef9caad63e9d86c3bfe7efb4ff7b917d3327bc8c.zip |
Added docs for TimeWithZone [ci skip]
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/time_with_zone.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index f8f1b9ac2c..5dd9c423e3 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -246,6 +246,7 @@ module ActiveSupport utc.future? end + # Returns +true+ if +other+ is equal to current object. def eql?(other) other.eql?(utc) end @@ -329,6 +330,11 @@ module ActiveSupport 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 @@ module ActiveSupport 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 |