diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-08-25 16:12:51 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-08-25 16:12:51 -0300 |
commit | 4788d7fd172e4bac76e1614aa48c58c8d4a09155 (patch) | |
tree | 4755ace2c2c889b9405375f9c415a9bb9a587275 /activesupport | |
parent | e6629257f4aecfa53fd1a1a2eae34aa33f637d79 (diff) | |
parent | ef9caad63e9d86c3bfe7efb4ff7b917d3327bc8c (diff) | |
download | rails-4788d7fd172e4bac76e1614aa48c58c8d4a09155.tar.gz rails-4788d7fd172e4bac76e1614aa48c58c8d4a09155.tar.bz2 rails-4788d7fd172e4bac76e1614aa48c58c8d4a09155.zip |
Merge pull request #21281 from ronakjangir47/added_docs
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 |