Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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