mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
Replace User#time with UserTime#time
This commit is contained in:
parent
8512e8db3b
commit
96777c2e3a
13 changed files with 44 additions and 27 deletions
|
|
@ -4,12 +4,12 @@ class Staleness
|
|||
SECONDS_PER_DAY = 86400
|
||||
def self.days_stale(item, current_user)
|
||||
return 0 if cannot_be_stale(item, current_user)
|
||||
(current_user.time - item.created_at).to_i / SECONDS_PER_DAY
|
||||
(UserTime.new(current_user).time - item.created_at).to_i / SECONDS_PER_DAY
|
||||
end
|
||||
|
||||
def self.cannot_be_stale(item, current_user)
|
||||
return true if item.due || item.completed?
|
||||
return true if item.created_at > current_user.time
|
||||
return true if item.created_at > UserTime.new(current_user).time
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,4 +11,12 @@ class UserTime
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue