mirror of
https://github.com/discourse/discourse.git
synced 2025-03-24 19:45:37 +08:00
reused value of Time.now in a method
`Time.now` was being used to fetch the current time, twice in the same line. This commit stores the time value in a variable and reuses it instead of generating/fetching it for the second time. Additionally, a guard clause in the same method is substituted by an `if/else/end` block for clarity.
This commit is contained in:
parent
c8de38c553
commit
d0955e02d6
@ -1,8 +1,12 @@
|
|||||||
module AgeWords
|
module AgeWords
|
||||||
|
|
||||||
def self.age_words(secs)
|
def self.age_words(secs)
|
||||||
return "—" if secs.blank?
|
if secs.blank?
|
||||||
return FreedomPatches::Rails4.distance_of_time_in_words(Time.now, Time.now + secs)
|
"—"
|
||||||
|
else
|
||||||
|
now = Time.now
|
||||||
|
FreedomPatches::Rails4.distance_of_time_in_words(now, now + secs)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user