Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:5035116
1 2 3 4 5 6 7 8 9 10 11 12 13
# Need a method that takes a date and based on a given time zone gives me the correct offset
# with daylight savings time into consideration
Time.zone = "Pacific US and Canada"
 
Time.some_method_name("2013-03-09") #=> "PST -0800"
Time.some_method_name("2013-03-10") #=> "PDT -0700"
 
#############
 
ActiveSupport::TimeZone.all.sort_by(&:name).each_with_index do |timezone, index|
# Need this to be "-0700 Pcific Time (US & Canada) if a specified date is after DST
"#{timezone.formatted_offset(false)} #{timezone.name}" # => "-0800 Pacific Time (US & Canada)"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.