Skip to content

Instantly share code, notes, and snippets.

@kdiogenes
Last active February 23, 2016 11:50
Show Gist options
  • Select an option

  • Save kdiogenes/262d4630c2a1605fe4d1 to your computer and use it in GitHub Desktop.

Select an option

Save kdiogenes/262d4630c2a1605fe4d1 to your computer and use it in GitHub Desktop.
rails: add brazilian time zones to ActiveSupport::TimeZone
ActiveSupport::TimeZone::MAPPING['Fernando de Noronha'] = 'America/Noronha'
ActiveSupport::TimeZone::MAPPING['Amazônia'] = 'America/Manaus'
ActiveSupport::TimeZone::MAPPING['Acre'] = 'America/Rio_Branco'
ActiveSupport::TimeZone.instance_variable_set('@zones', nil)
ActiveSupport::TimeZone.instance_variable_set('@zones_map', nil)
module ActiveSupport
class TimeZone
def self.br_zones
@br_zones ||= all.find_all { |z| z.name =~ /Brasilia|Noronha|Amazônia|Acre/ }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment