Method: Time#formatted_offset

Defined in:
activesupport/lib/active_support/core_ext/time/conversions.rb

#formatted_offset(colon = true, alternate_utc_string = nil) ⇒ Object

Returns a formatted string of the offset from UTC, or an alternative string if the time zone is already UTC.

Time.local(2000).formatted_offset        # => "-06:00"
Time.local(2000).formatted_offset(false) # => "-0600"


67
68
69
# File 'activesupport/lib/active_support/core_ext/time/conversions.rb', line 67

def formatted_offset(colon = true, alternate_utc_string = nil)
  utc? && alternate_utc_string || ActiveSupport::TimeZone.seconds_to_utc_offset(utc_offset, colon)
end