diff options
author | Matthew Stopa <matthew.p.stopa@gmail.com> | 2012-12-31 22:52:47 -0700 |
---|---|---|
committer | Matthew Stopa <matthew.p.stopa@gmail.com> | 2012-12-31 22:52:47 -0700 |
commit | f42c0893112e4411f9f1469c019e41968bcbe0e5 (patch) | |
tree | 81d8767535742b3f7b2be84b2f2a3255a809ea5c /activesupport/lib/active_support | |
parent | 6d5385a1354a8bec2ac522693c1173e547ffd61e (diff) | |
download | rails-f42c0893112e4411f9f1469c019e41968bcbe0e5.tar.gz rails-f42c0893112e4411f9f1469c019e41968bcbe0e5.tar.bz2 rails-f42c0893112e4411f9f1469c019e41968bcbe0e5.zip |
Add documentation for TimeWithZone methods
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/time_with_zone.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 89f37114fd..ec16f52f30 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -83,19 +83,27 @@ module ActiveSupport # Returns true if the the current time is within Daylight Savings Time for the # specified time zone. # - # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' - # Time.zone.parse("2012-5-30").dst? # => true - # Time.zone.parse("2012-11-30").dst? # => false + # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' + # Time.zone.parse("2012-5-30").dst? # => true + # Time.zone.parse("2012-11-30").dst? # => false def dst? period.dst? end alias_method :isdst, :dst? + # Returns true if the the current time zone is set to UTC. + # + # Time.zone = 'UTC' # => 'UTC' + # Time.zone.now.utc? # => true + # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' + # Time.zone.now.utc? # => false def utc? time_zone.name == 'UTC' end alias_method :gmt?, :utc? + # Returns a +Fixnum+ of the offset from current time zone to UTC time + # in seconds. def utc_offset period.utc_total_offset end @@ -153,10 +161,18 @@ module ActiveSupport end end + # Returns a string of the object's date and time in the format used by + # HTTP requests. + # + # Time.zone.now.httpdate # => "Tue, 01 Jan 2013 04:39:43 GMT" def httpdate utc.httpdate end + # Returns a string of the object's date and time in the RFC 2822 standard + # format. + # + # Time.zone.now.rfc2822 # => "Tue, 01 Jan 2013 04:51:39 +0000" def rfc2822 to_s(:rfc822) end |