Skip to content

Instantly share code, notes, and snippets.

@bunnymatic
Last active December 11, 2015 17:38
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 bunnymatic/4635846 to your computer and use it in GitHub Desktop.
Save bunnymatic/4635846 to your computer and use it in GitHub Desktop.
Timezone Playtime
puts "Server Timezone: %s" % Rails.configuration.time_zone
# try with ruby 1.8.7/1.9.2
# try with different rails apps timezones
springtime = '04/25/2013 1:30PM'
falltime = '11/12/2013 2:40PM'
# maybe print the app timezone here
times = [[ :now , Time.now ],
[:now_zoned , Time.zone.now],
[:spring_parsed , Time.parse(springtime)],
[:spring_parsed_zoned , Time.zone.parse(springtime)],
[:fall_parsed , Time.parse(falltime)],
[:fall_parsed_zoned , Time.zone.parse(falltime)]]
times.each{|k,v| puts "[%s] %s" % [ k.to_s.humanize.titleize, v ] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment