Skip to content

Commit

Permalink
Update README timezone FAQ for Rails gh-230 gh-233
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Jan 28, 2017
1 parent dc9e9df commit 7998184
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CREDITS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

== Feedback

- Alexander Deeb - https://github.com/adeeb1 - gh-230
- Sofia Bravo - http://stackoverflow.com/users/1123850/sofia-bravo - gh-231
- zzjin - https://githu.com/zzjin - 3.3.x vs CST abbreviated timezone - gh-228
- lovingyu - https://github.com/lovingyu - fallback to ENV['TZ'] - gh-222
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,20 @@ scheduler.every '2s' do
end
```

On Rails you might want to try with:
```ruby
ENV['TZ'] = Time.zone.name # Rails only
scheduler = Rufus::Scheduler.new
scheduler.every '2s' do
puts "#{Time.now} Hello #{ENV['TZ']}!"
end
```
(Hat tip to Alexander in [gh-230](https://github.com/jmettraux/rufus-scheduler/issues/230))

Rails set its timezone under `config/application.rb`.

Rufus-Scheduler 3.3.3 detects the presence of Rails and uses its timezone setting (tested with Rails 4), so setting `ENV['TZ']` should not be necessary.

The value can be determined thanks to [https://en.wikipedia.org/wiki/List_of_tz_database_time_zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).

Use a "continent/city" identifier (for example "Asia/Shanghai"). Do not use an abbreviation (not "CST") and do not use a local time zone name (not "中国标准时间").
Expand Down

0 comments on commit 7998184

Please sign in to comment.