mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-31 14:28:49 +01:00
Remove User#at_midnight
Replace it with a class called DateUtils with a method called `#midnight_for` that takes a preference instance and date to convert to midnight.
This commit is contained in:
parent
e7c6142684
commit
a1aaa283f1
6 changed files with 12 additions and 8 deletions
|
|
@ -22,6 +22,6 @@ class Preference < ActiveRecord::Base
|
|||
raise ArgumentError.new("Bad argument type:#{s.class}")
|
||||
end
|
||||
|
||||
user.at_midnight(date)
|
||||
DateUtils::midnight_for(self, date)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ class Todo < ActiveRecord::Base
|
|||
activate
|
||||
else
|
||||
# parse Date objects into the proper timezone
|
||||
date = user.at_midnight(date) if (date.is_a? Date)
|
||||
date = DateUtils.midnight_for(user.prefs, date) if (date.is_a? Date)
|
||||
|
||||
# show_from needs to be set before state_change because of "bug" in aasm.
|
||||
# If show_from is not set, the todo will not validate and thus aasm will not save
|
||||
|
|
|
|||
|
|
@ -167,10 +167,6 @@ class User < ActiveRecord::Base
|
|||
time.midnight
|
||||
end
|
||||
|
||||
def at_midnight(date)
|
||||
return ActiveSupport::TimeZone[prefs.time_zone].local(date.year, date.month, date.day, 0, 0, 0)
|
||||
end
|
||||
|
||||
def generate_token
|
||||
self.token = Digest::SHA1.hexdigest "#{Time.now.to_i}#{rand}"
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue