Possible Duplicate:
How do I calculate relative time?
Given a DateTime object, what's the most elegant way you've found of converting it to a human friendly string. Something like this:
(Future)开发者_如何学C
"Tomorrow" "[1|2|3|4|5|6] days from now." "Next week" "Next month"(Past)
"[1|2|3|4|5|6] days ago." "Last week" "Last month"Thanks.
It's not necessarily the most elegant solution, but this blog article, as well as the the first comment, solve the problem as it pertains to dates in the past. (Copying and pasting the first comment requires replacing the fancy double quotes with plain-old double quotes.)
Stack Overflow just uses cascading if-thens I believe. Can't find the post right now (it's either here or on meta).
EDIT: Jason found it. Link in the comments on the question.
精彩评论