tracks/lib/user_time.rb

23 lines
361 B
Ruby
Raw Permalink Normal View History

2013-07-29 21:51:15 -05:00
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
2013-07-30 16:18:06 -05:00
def time
timezone.now
end
def date
time.to_date
end
2013-07-29 21:51:15 -05:00
end