Module: UserTimeZones::User
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/user_time_zones/user.rb
Instance Method Summary collapse
- #time_zone_offset ⇒ Object
-
#time_zone_offset=(time_zone_offset) ⇒ Object
Take time zone expressed as an offset.
Instance Method Details
#time_zone_offset ⇒ Object
20 21 22 23 24 |
# File 'lib/user_time_zones/user.rb', line 20 def time_zone_offset return nil if time_zone.nil? tz ||= Time.find_zone! time_zone tz.utc_offset / 3600 unless (tz.nil? || tz.utc_offset.nil?) end |
#time_zone_offset=(time_zone_offset) ⇒ Object
Take time zone expressed as an offset. Only really used
15 16 17 18 |
# File 'lib/user_time_zones/user.rb', line 15 def time_zone_offset=(time_zone_offset) offset = "#{time_zone_offset}".to_i self.time_zone = ActiveSupport::TimeZone[offset].name end |