I have to load some articles from different sources and give how much time elapsed from the article and now :
Hre is my method :
TimeSpan diff = DateTime.Now - articleDate;
if(diff.Seconds < 60)
{
article.date = diff.Seconds + "Sec";
}
else if (diff.Minutes < 60)
{
article.date = diff.Minutes + "Min";
}
else if (diff.Hours < 24)
{
article.date = diff.Hours + "Hrs";
}
else
{
article.date = diff.Days + "Days";
}
This method appears to be quite redundant , what is the best method to give the time that elapsed, and if it is seconds add "Sec" like I did after ?