Last active
December 15, 2015 20:09
-
-
Save fabrizioc1/5316290 to your computer and use it in GitHub Desktop.
List time zones with UTC and DST offsets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new File("/tmp/java_timezones.txt").withWriter { out -> | |
TimeZone.getAvailableIDs().each{ timezoneId -> | |
timezone = TimeZone.getTimeZone(timezoneId) | |
def items = [timezone.getID(), | |
(int)(timezone.getRawOffset()/1000), | |
(int)(timezone.getDSTSavings()/1000)] | |
out.print sprintf("%6d %32s %6d\n",items[1],items[0],items[2]) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/setup' | |
require 'active_support/time_with_zone' | |
File.open('/tmp/ruby_timezones.txt','w'){|out| | |
out.puts ActiveSupport::TimeZone.all.map{|t| t.tzinfo }.map{|tz| | |
sprintf("%6d %32s %6d",tz.current_period.utc_offset, tz.name, tz.current_period.std_offset) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
offsets = TZInfo::Timezone.all.map{|tz| [tz.current_period.utc_offset/3600.0,tz.name] }.sort_by{|o| o[0] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment