[REQ] nice timestamps
Closed this issue · 5 comments
So instead of 25 Oct 2019, 03:03
maybe we could have 1 month ago
On pinboard website there is a good model to follow:
- just now (within the last hour?)
- hours ago (up to 24 hours)
- yesterday (date is yesterday)
- days ago (up to ~30 days)
- weeks ago (up to 12 weeks)
- july 2019 (over 12 weeks)
private func readableIntervalSinceNow(dateAsString: String) -> String {
let formatter = ISO8601DateFormatter();
if let date = formatter.date(from: dateAsString) {
let timeInterval = date.timeIntervalSinceNow
if (timeInterval > -3600) { // less than 1 hour
return "just now."
} else if (timeInterval > -86400) { // less than a day
let hours = abs(timeInterval / 3600)
return "\(String(format: "%.0f", hours)) hours ago."
//String(format: "%.f", hours)
} else if (timeInterval > (-604800 * 4)) { // less than a months
let days = abs(timeInterval / 86400)
return "\(String(format: "%.0f", days)) days ago."
} else if (timeInterval > (-604800 * 4 * 3)) { // less than 3 months
let weeks = abs(timeInterval / 604800)
return "\(String(format: "%.0f", weeks)) weeks ago."
} else {
let dateFormatter = DateFormatter()
dateFormatter.setLocalizedDateFormatFromTemplate("MMMM YYYY")
return "\(dateFormatter.string(from: date))."
}
}
return dateAsString
}
How do you envisage the display
This page was last archived: a few days ago
For my understanding: how is the abstract better than the detailed timestamp? I am not opposed to do this, I am just trying to understand how we are improving the user experience by making it less detailed...
In short, relative timestamps are better when you need to quickly see "how recently" rather than "when exactly"
https://uxmovement.com/content/absolute-vs-relative-timestamps-when-to-use-which/
I'll make it an option - because I agree with the usefulness of the relative timestamp, but I personally do care about the exact one :) Sorry, but we have so many options already, that one more, won't hurt. I'll make the relative timestamp the default
Icons from me soon and then after that IMHO we are shippable.
Thanks Matt :)