1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add documentation for TimeWithZone methods

This commit is contained in:
Matthew Stopa 2012-12-31 22:52:47 -07:00
parent 6d5385a135
commit f42c089311

View file

@ -83,19 +83,27 @@ module ActiveSupport
# Returns true if the the current time is within Daylight Savings Time for the # Returns true if the the current time is within Daylight Savings Time for the
# specified time zone. # specified time zone.
# #
# Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)'
# Time.zone.parse("2012-5-30").dst? # => true # Time.zone.parse("2012-5-30").dst? # => true
# Time.zone.parse("2012-11-30").dst? # => false # Time.zone.parse("2012-11-30").dst? # => false
def dst? def dst?
period.dst? period.dst?
end end
alias_method :isdst, :dst? 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? def utc?
time_zone.name == 'UTC' time_zone.name == 'UTC'
end end
alias_method :gmt?, :utc? alias_method :gmt?, :utc?
# Returns a +Fixnum+ of the offset from current time zone to UTC time
# in seconds.
def utc_offset def utc_offset
period.utc_total_offset period.utc_total_offset
end end
@ -153,10 +161,18 @@ module ActiveSupport
end end
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 def httpdate
utc.httpdate utc.httpdate
end 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 def rfc2822
to_s(:rfc822) to_s(:rfc822)
end end