mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 06:51:27 +08:00
1st attempt to support i18n in dates and times
This commit is contained in:
@ -3,18 +3,7 @@ module AgeWords
|
||||
def self.age_words(secs)
|
||||
return "—" if secs.blank?
|
||||
|
||||
mins = (secs / 60.0)
|
||||
hours = (mins / 60.0)
|
||||
days = (hours / 24.0)
|
||||
months = (days / 30.0)
|
||||
years = (months / 12.0)
|
||||
|
||||
return "#{years.floor}y" if years > 1
|
||||
return "#{months.floor}mo" if months > 1
|
||||
return "#{days.floor}d" if days > 1
|
||||
return "#{hours.floor}h" if hours > 1
|
||||
return "< 1m" if mins < 1
|
||||
return "#{mins.floor}m"
|
||||
return FreedomPatches::Rails4.distance_of_time_in_words(Time.now, Time.now + secs)
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user