Class: TwitterCldr::Timezones::Iso8601Location

Inherits:
Location
  • Object
show all
Defined in:
lib/twitter_cldr/timezones/iso8601_location.rb

Constant Summary collapse

UTC =
'Z'.freeze
FIELDS =
[
  [:hour].freeze,
  [:hour, :minute].freeze,
  [:hour, :minute, :second].freeze
].freeze
FORMATS =
[
  :iso_basic_short,
  :iso_basic_local_short,
  :iso_basic_fixed,
  :iso_basic_local_fixed,
  :iso_basic_full,
  :iso_basic_local_full,
  :iso_extended_fixed,
  :iso_extended_local_fixed,
  :iso_extended_full,
  :iso_extended_local_full
].freeze

Instance Attribute Summary

Attributes inherited from Location

#tz

Instance Method Summary collapse

Methods inherited from Location

#initialize, #resource, #tz_id

Constructor Details

This class inherits a constructor from TwitterCldr::Timezones::Location

Instance Method Details

#display_name_for(date, fmt, dst = TZInfo::Timezone.default_dst, &block) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/twitter_cldr/timezones/iso8601_location.rb', line 30

def display_name_for(date, fmt, dst = TZInfo::Timezone.default_dst, &block)
  offset = tz.period_for_local(date, dst, &block).offset
  offset_secs = offset.utc_offset + offset.std_offset

  case fmt
    when :iso_basic_short
      format_basic_offset(offset_secs, true, true, true)
    when :iso_basic_local_short
      format_basic_offset(offset_secs, false, true, true)
    when :iso_basic_fixed
      format_basic_offset(offset_secs, true, false, true)
    when :iso_basic_local_fixed
      format_basic_offset(offset_secs, false, false, true)
    when :iso_basic_full
      format_basic_offset(offset_secs, true, false, false)
    when :iso_basic_local_full
      format_basic_offset(offset_secs, false, false, false)
    when :iso_extended_fixed
      format_extended_offset(offset_secs, true, false, true)
    when :iso_extended_local_fixed
      format_extended_offset(offset_secs, false, false, true)
    when :iso_extended_full
      format_extended_offset(offset_secs, true, false, false)
    when :iso_extended_local_full
      format_extended_offset(offset_secs, false, false, false)
  end
end