diff --git a/Tusker/Extensions/Date+TimeAgo.swift b/Tusker/Extensions/Date+TimeAgo.swift index bca179dd..bce334e2 100644 --- a/Tusker/Extensions/Date+TimeAgo.swift +++ b/Tusker/Extensions/Date+TimeAgo.swift @@ -10,11 +10,11 @@ import Foundation extension Date { + private static let unitFlags = Set([.second, .minute, .hour, .day, .weekOfYear, .month, .year]) + func timeAgo() -> (Int, Calendar.Component) { let calendar = NSCalendar.current - let unitFlags = Set([.second, .minute, .hour, .day, .weekOfYear, .month, .year]) - - let components = calendar.dateComponents(unitFlags, from: self, to: Date()) + let components = calendar.dateComponents(Date.unitFlags, from: self, to: Date()) if components.year! >= 1 { return (components.year!, .year)