MatthewYork / DateTools

Dates and times made easy in iOS
MIT License
7.22k stars 950 forks source link

"1 year ago" ≠ "Last year" #194

Open futuretap opened 7 years ago

futuretap commented 7 years ago
[[NSDate dateWithString:@"2015-08-15 22:00:00 +0000"] timeAgoSinceNow]

returns Last year. I think it should return 1 year ago. IMO, "last year" means every date in 2016 whereas "1 year ago" means every date between 1 year and 2 years ago.

webmaster128 commented 7 years ago

👍 Having "One year ago", "One month ago", "One week ago", "Yesterday" instead of "Last year", "Last month", "Last week", "Yesterday" would be less ambiguous.

@futuretap If having a "1 year ago" written as digit is okay for you, you can use myDateVariable.timeAgo(since: Date(), numericDates: true, numericTimes: false) or the Objective-C equivalent.

futuretap commented 7 years ago

Thanks for the useful tip. That's at least a workaround until this is fixed.

webmaster128 commented 7 years ago

I then replaced the out string of myDateVariable.timeAgo(since: Date(), numericDates: true, numericTimes: false) from

NSLocalizedString("1 year ago", tableName: "DateTools", bundle: Bundle.dateToolsBundle(), value: "", comment: "")
NSLocalizedString("1 month ago", tableName: "DateTools", bundle: Bundle.dateToolsBundle(), value: "", comment: "")
NSLocalizedString("1 week ago", tableName: "DateTools", bundle: Bundle.dateToolsBundle(), value: "", comment: "")
NSLocalizedString("1 day ago", tableName: "DateTools", bundle: Bundle.dateToolsBundle(), value: "", comment: "")

to my own strings

olivier-carbon commented 6 years ago

We've been running into issues with this, where the results make sense for 'blocks of days/weeks/months ago' but don't match up to what a human would expect (about 5/10% of cases). Excuse the format, but here are what we see using DateToolsSwift: