Skip to content

Instantly share code, notes, and snippets.

@davbeck
Created October 2, 2014 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davbeck/ab6eeacadc14f71b331c to your computer and use it in GitHub Desktop.
Save davbeck/ab6eeacadc14f71b331c to your computer and use it in GitHub Desktop.
Generate Time Zone Mapping
#!/usr/bin/env ruby
#encoding: utf-8
require 'active_support/all'
timezones = ActiveSupport::TimeZone::MAPPING.map { |rails_name, name|
zone = ActiveSupport::TimeZone.new(name)
{
rails_name => {
offset: zone.utc_offset,
abbreviation: Time.now.in_time_zone(zone).strftime('%Z'),
name: name,
}
}
}.reduce(:merge)
File.open("#{File.dirname(__FILE__)}/AndroidTimeZone+TCRails.json", 'w') { |file| file.write(timezones.to_json) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment