# This file was automatically generated by running:
#
#   scripts/generate_windows_zone_names.cr
#
# DO NOT EDIT

module Crystal::System::Time
  # These mappings from IANA to Windows time zone names and tzdata abbreviations
  # are based on
  # <%= WINDOWS_ZONE_NAMES_SOURCE %>
  private class_getter iana_to_windows : Hash(String, {String, String, String}) do
    data = Hash(String, {String, String, String}).new(initial_capacity: <%= iana_to_windows_items.size %>)
    <%- iana_to_windows_items.each do |tzdata_name, windows_name, zone1, zone2| -%>
      put(data, <%= tzdata_name.inspect %>, <%= windows_name.inspect %>, <%= zone1.inspect %>, <%= zone2.inspect %>)
    <%- end -%>
    data
  end

  # These canonical mappings from Windows to IANA time zone names, used for the
  # local time zone, are based on
  # <%= WINDOWS_ZONE_NAMES_SOURCE %>
  private class_getter windows_to_iana : Hash(String, String) do
    data = Hash(String, String).new(initial_capacity: <%= windows_to_iana_items.size %>)
    <%- windows_to_iana_items.each do |windows_name, tzdata_name| -%>
      put(data, <%= windows_name.inspect %>, <%= tzdata_name.inspect %>)
    <%- end -%>
    data
  end

  # TODO: this is needed to avoid generating lots of allocas
  # in LLVM, which makes LLVM really slow. The compiler should
  # try to avoid/reuse temporary allocas.
  # Explanation: https://github.com/crystal-lang/crystal/issues/4516#issuecomment-306226171
  private def self.put(hash : Hash, key, value) : Nil
    hash[key] = value
  end

  private def self.put(hash : Hash, key, *values) : Nil
    hash[key] = values
  end
end
