tracks/lib/user_time.rb
2013-07-30 16:21:04 -05:00

22 lines
361 B
Ruby

require 'active_support/values/time_zone'
class UserTime
attr_reader :user, :timezone
def initialize(user)
@user = user
@timezone = ActiveSupport::TimeZone[user.prefs.time_zone]
end
def midnight(date)
timezone.local(date.year, date.month, date.day, 0, 0, 0)
end
def time
timezone.now
end
def date
time.to_date
end
end