Skip to content

Instantly share code, notes, and snippets.

@voidlily
Last active October 10, 2015 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voidlily/3691733 to your computer and use it in GitHub Desktop.
Save voidlily/3691733 to your computer and use it in GitHub Desktop.
# incorrect
time = Time.zone.parse('2011-11-06T01:00:00')
=> Sun, 06 Nov 2011 01:00:00 PDT -07:00
time.advance(hours: 1).beginning_of_hour
=> Sun, 06 Nov 2011 01:00:00 PDT -07:00
# correct usage
time.utc.advance(hours: 1).change(min: 0).in_time_zone
=> Sun, 06 Nov 2011 01:00:00 PST -08:00
# correct
time = Time.parse('2011-11-06T01:00:00')
=> 2011-11-06 01:00:00 -0500
time.advance(hours: 1).beginning_of_hour
=> 2011-11-06 02:00:00 -0500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment