module UserTimeZones::User

Public Instance Methods

time_zone_offset() click to toggle source
# 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) click to toggle source

Take time zone expressed as an offset. Only really used

# 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