Created
March 21, 2016 14:50
-
-
Save michaelminter/b9176fe5790bf1f88d50 to your computer and use it in GitHub Desktop.
Assigns time zone to local time zone. Then sets back.
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
# Assigns time zone to local time zone. Then sets back. | |
# @param [String] tz_name | |
# @example | |
# with_time_zone 'UTC' { something() } | |
def with_time_zone(tz_name) | |
prev_tz = ENV['TZ'] | |
ENV['TZ'] = tz_name | |
yield | |
ensure | |
ENV['TZ'] = prev_tz | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment