HasZone
Provides a way to convert from TZinfo time zone identifer to ActiveSupport TimeZone for your Rails application.
Installation
Add this line to your application's Gemfile:
gem 'has_zone'
And then execute:
$ bundle
Or install it yourself as:
$ gem install has_zone
Usage
Assuming you have an attribute time_zone in your User model:
class User < ActiveRecord::Base
include HasZone
has_zone with: :time_zone
end
Then you can use the time zone with:
user.time_zone = "America/Los_Angeles"
user.zone # returns ActiveSupport::TimeZone of "Pacific Time (US & Canada)"
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request