summaryrefslogtreecommitdiff
path: root/Hutch/Extensions/Date+Relative.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Hutch/Extensions/Date+Relative.swift')
-rw-r--r--Hutch/Extensions/Date+Relative.swift10
1 files changed, 10 insertions, 0 deletions
diff --git a/Hutch/Extensions/Date+Relative.swift b/Hutch/Extensions/Date+Relative.swift
new file mode 100644
index 0000000..f06ba59
--- /dev/null
+++ b/Hutch/Extensions/Date+Relative.swift
@@ -0,0 +1,10 @@
+import Foundation
+
+extension Date {
+ /// A short relative description like "2h ago", "3d ago", or "Jan 5, 2025".
+ var relativeDescription: String {
+ let formatter = RelativeDateTimeFormatter()
+ formatter.unitsStyle = .abbreviated
+ return formatter.localizedString(for: self, relativeTo: .now)
+ }
+}