Skip to content

Instantly share code, notes, and snippets.

@Envek
Last active August 19, 2023 19:40
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Envek/cda8a367764dc2cacbc0 to your computer and use it in GitHub Desktop.
Save Envek/cda8a367764dc2cacbc0 to your computer and use it in GitHub Desktop.
Full list of russian time zones for Ruby on Rails
# Full list of Russian Federation time zones with helper to get this list.
# Place this file in config/initializers/timezones.ru.rb
class ActiveSupport::TimeZone
@country_zones = ThreadSafe::Cache.new
def self.country_zones(country_code)
code = country_code.to_s.upcase
@country_zones[code] ||=
TZInfo::Country.get(code).zone_identifiers.select do |tz_id|
MAPPING.key(tz_id)
end.map do |tz_id|
self[MAPPING.key(tz_id)]
end
end
def self.ru_zones
@ru_zones ||= country_zones('RU')
end
end
ActiveSupport::TimeZone::MAPPING['Kaliningrad'] = 'Europe/Kaliningrad'
ActiveSupport::TimeZone::MAPPING['Simferopol'] = 'Europe/Simferopol'
ActiveSupport::TimeZone::MAPPING['Volgograd'] = 'Europe/Volgograd'
ActiveSupport::TimeZone::MAPPING['Samara'] = 'Europe/Samara'
ActiveSupport::TimeZone::MAPPING['Astrakhan'] = 'Europe/Astrakhan'
ActiveSupport::TimeZone::MAPPING['Ulyanovsk'] = 'Europe/Ulyanovsk'
ActiveSupport::TimeZone::MAPPING['Omsk'] = 'Asia/Omsk'
ActiveSupport::TimeZone::MAPPING['Barnaul'] = 'Asia/Barnaul'
ActiveSupport::TimeZone::MAPPING['Novokuznetsk'] = 'Asia/Novokuznetsk'
ActiveSupport::TimeZone::MAPPING['Chita'] = 'Asia/Chita'
ActiveSupport::TimeZone::MAPPING['Khandyga'] = 'Asia/Khandyga'
ActiveSupport::TimeZone::MAPPING['Sakhalin'] = 'Asia/Sakhalin'
ActiveSupport::TimeZone::MAPPING['Ust-Nera'] = 'Asia/Ust-Nera'
ActiveSupport::TimeZone::MAPPING['Srednekolymsk'] = 'Asia/Srednekolymsk'
ActiveSupport::TimeZone::MAPPING['Anadyr'] = 'Asia/Anadyr'
# Translations for timezones added in config/initializers/timezones.ru.rb for use with i18n-timezones gem
# Place this file in config/locales/timezones.ru.yml
ru:
timezones:
Kaliningrad: Калининград
Simferopol: Республика Крым и Севастополь
Volgograd: Волгоград
Astrakhan: Астрахань
Ulyanovsk: Ульяновск
Samara: Самара
Omsk: Омск
Barnaul: Барнаул
Novokuznetsk: Новокузнецк
Chita: Чита
Khandyga: Хандыга
Sakhalin: Сахалин
Ust-Nera: Усть-Нера
Srednekolymsk: Среднеколымск и Северные Курилы
Anadyr: Анадырь
@shkrt
Copy link

shkrt commented Sep 9, 2017

Following are missing from this list:

Asia/Novosibirsk 
Asia/Krasnoyarsk
Asia/Irkutsk
Asia/Vladivostok
Asia/Magadan
Asia/Kamchatka

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment