Last active
December 14, 2015 05:28
-
-
Save jwoertink/5035116 to your computer and use it in GitHub Desktop.
This file contains 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
# 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