Last active
December 23, 2015 05:49
-
-
Save ejamesc/6589096 to your computer and use it in GitHub Desktop.
Setting timezones locally in Ruby
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
| def with_time_zone(tz_name) | |
| prev_tz = ENV['TZ'] | |
| ENV['TZ'] = tz_name | |
| yield | |
| ensure | |
| ENV['TZ'] = prev_tz | |
| end | |
| with_time_zone('Asia/Singapore') { Chronic.parse("this week Monday 21:00") } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment