sonic-pi
https://github.com/sonic-pi-net/sonic-pi
C++
Code. Music. Live.
ActiveSupport::Testing::TimeHelpers#travel_to
Changes current time to the given time by stubbing +Time.now+ and
+Date.today+ to return the time or date passed into this method.
Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
travel_to Time.new(2004, 11, 24, 01, 04, 44)
Time.current # => Wed, 24 Nov 2004 01:04:44 EST -05:00
Date.current # => Wed, 24 Nov 2004
Dates are taken as their timestamp at the beginning of the day in the
application time zone. <tt>Time.current</tt> returns said timestamp,
and <tt>Time.now</tt> its equivalent in the system time zone. Similarly,
<tt>Date.current</tt> returns a date equal to the argument, and
<tt>Date.today</tt> the date according to <tt>Time.now</tt>, which may
be different. (Note that you rarely want to deal with <tt>Time.now</tt>,
or <tt>Date.today</tt>, in order to honor the application time zone
please always use <tt>Time.current</tt> and <tt>Date.current</tt>.)
This method also accepts a block, which will return the current time back to its original
state at the end of the block:
Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
travel_to Time.new(2004, 11, 24, 01, 04, 44) do
Time.current # => Wed, 24 Nov 2004 01:04:44 EST -05:00
end
Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00Edit
git clone [email protected]:sonic-pi-net/sonic-pi.git
cd sonic-pi
open app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/testing/time_helpers.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-ActiveSupport--Testing--TimeHelpers-travel_to-for-pr
# Commit to gitgit add app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/testing/time_helpers.rbgit commit -m "better docs for ActiveSupport::Testing::TimeHelpers#travel_to"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-ActiveSupport--Testing--TimeHelpers-travel_to-for-pr
hub pull-request
# Celebrate!