Method: Parse::TimeZone#zone

Defined in:
lib/parse/model/time_zone.rb

#zoneActiveSupport::TimeZone

Returns an instance of ActiveSupport::TimeZone based on the IANA identifier. The setter may allow usign an IANA string identifier, a Parse::TimeZone or an ActiveSupport::TimeZone object.

Returns:

  • (ActiveSupport::TimeZone)

Raises:

  • ArgumentError

See Also:



100
101
102
103
104
105
106
107
108
# File 'lib/parse/model/time_zone.rb', line 100

def zone
  # lazy load the TimeZone object only when the user requests it, otherwise
  # just keep the name of the string around. Makes encoding/decoding faster.
  if @zone.nil? && @name.present?
    @zone = ::ActiveSupport::TimeZone.new(@name)
    @name = nil # clear out the cache
  end
  @zone
end