sonic-pi
https://github.com/sonic-pi-net/sonic-pi
C++
Code. Music. Live.
Time.zone=
Sets <tt>Time.zone</tt> to a TimeZone object for the current request/thread.
This method accepts any of the following:
* A Rails TimeZone object.
* An identifier for a Rails TimeZone object (e.g., "Eastern Time (US & Canada)", <tt>-5.hours</tt>).
* A TZInfo::Timezone object.
* An identifier for a TZInfo::Timezone object (e.g., "America/New_York").
Here's an example of how you might set <tt>Time.zone</tt> on a per request basis and reset it when the request is done.
<tt>current_user.time_zone</tt> just needs to return a string identifying the user's preferred time zone:
class ApplicationController < ActionController::Base
around_filter :set_time_zone
def set_time_zone
if logged_in?
Time.use_zone(current_user.time_zone) { yield }
else
yield
end
end
endEdit
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/core_ext/time/zones.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Time-zone--for-pr
# Commit to gitgit add app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/core_ext/time/zones.rbgit commit -m "better docs for Time.zone="
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Time-zone--for-pr
hub pull-request
# Celebrate!