Time Zones By Country Using Rails TZInfo


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. countries = Country.find(:all)
  2. for country in countries
  3. begin
  4. tzc = TZInfo::Country.get(country.code.upcase)
  5. rescue
  6. puts "can't find TZInfo for #{country.code.upcase}"
  7. next
  8. end
  9. puts tzc.name
  10. for zone in tzc.zone_names
  11. puts country.code.upcase
  12. puts zone
  13. CountryTimeZone.create(:parent_id => country.id, :name => zone)
  14. end
  15. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.