tracks/lib/user_time.rb
2019-12-18 09:49:57 -06:00

23 lines
375 B
Ruby

# typed: true
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