-
Notifications
You must be signed in to change notification settings - Fork 322
Use of the term "Yesterday" is incorrect #15
Comments
This is not an oversight but intentional. The intent is to express approximately how far in the past something happened, not the exact interval. A comment written a two years ago is antique in internet terms. It doesn't matter if it is really 20 months old or 28 months old. This is acceptable in the context of approximations. Many users are even accustomed to this particular behavior, for better or worse. As another example of issues we ignore, when it is 2AM and something occurred at 11PM the previous day, is it more accurate to say it happened 3 hours ago, or that it happened yesterday? You could improve accuracy in a superficial way by grossly complicating the code. Such a project, if done thoroughly, might be interesting. If I remember correctly when I originally looked at it, it is unavoidably ambiguous. You cannot arrive at meaningful consensus. Regardless, if it was done well enough I would be open to merging it. |
I agree that for anything longer than weeks approximation can be enough, but between "yesterday" and "the day before yesterday" people care about some precision. In your example, both "3 hours ago" and "yesterday" are correct: the second is less precise but nevertheless correct. I wouldn't mind seeing one instead of the other one as long as it's correct. In my example, "yesterday" wasn't correct at all: it was actually the day before yesterday. The code won't be more complex by checking calendar days instead of plain 24 hours, I'll do the change on a fork later to show you how it can be done in a simple manner using tools given by the iOS sdk just for that: NSDateComponents and NSDayCalendarUnit. |
OK, I like this so far. Anything that makes a precise decision about an ambiguous window should be grouped and clearly exposed. |
I've added @chrisben as a collaborator on the repo. |
Thanks. I will have a look at that this week end - I hope. |
As I dig into this, I see now that the problem is deeper than just "yesterday". There's a real difference between saying "one day ago" and "yesterday", as it is to say "one year ago" and "last year". For instance on the 2nd of January "last year" means "any time between 2 days ago and 367 days ago". When you say "one year ago" you're saying "any time between 365 days ago and 365*2 days ago". This is a huge difference and can lead to misunderstandings. For that reason, I will create two new methods:
timeAgo will be kept as it is now for compatibility reasons when people upgrade this library. I'll commit something today (i.e less than 12 hours from now ;) ) to my fork for you to check. |
As discussed in issue kevinlawler#15, added two new methods that can be used as drop-in replacement to timeAgo: dateTimeAgo and dateTimeUntilNow. See header file for more details about those methods. Also refactored some code in timeAgo to simplify it.
Looking at the code, I see that the library returns the string "yesterday" if the difference in time between the given date and now is more than 24 hours ago but less than 2*24 hours ago.
Saying "yesterday" is wrong because the given date could be actually the day before yesterday.
For instance:
I suggest using "calendar days" instead of just plain days (=24 hours) to calculate the difference. Yesterday will have its true meaning then.
For an example on how to do this, see the second answer: http://stackoverflow.com/questions/4739483/number-of-days-between-two-nsdates
By the way, same problem with "last month" / "last year" => months are not always 31 days long, and years are not 365.25 days long.
The text was updated successfully, but these errors were encountered: