使用Rails TZInfo的国家时区

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用Rails TZInfo的国家时区相关的知识,希望对你有一定的参考价值。

  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

以上是关于使用Rails TZInfo的国家时区的主要内容,如果未能解决你的问题,请参考以下文章