Skip to content

Instantly share code, notes, and snippets.

@DouweM
Created July 14, 2013 12:22
Show Gist options
  • Save DouweM/5994113 to your computer and use it in GitHub Desktop.
Save DouweM/5994113 to your computer and use it in GitHub Desktop.
datetime = DateTime.parse('2013-07-14T09:00')
tz = datetime.in_time_zone # => Sun, 14 Jul 2013 09:00:00 UTC +00:00
tz.instance_variable_set(:@time_zone, ::Time.find_zone!("CET"))
tz.instance_variable_set(:@period, tz.send(:get_period_and_ensure_valid_local_time))
tz # => Sun, 14 Jul 2013 09:00:00 CEST +02:00
# :-)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment