-1

I was making an instant messenger app, so i need a way to tell the user how long ago a message was received. My method takes in a DateTime.Now that was captured and checks it against the current DateTime.Now to see elapsed time, it then calculates it and returns things like "6 seconds ago", "1 minute ago" , " 1 month ago".

I posted my code here: http://pastebin.com/7N1kqLQ6

I dont believe my code is right. Does anyone else see a problem in my code logic?

Mohsen Heydari
  • 7,256
  • 4
  • 31
  • 46
user1775297
  • 87
  • 11

1 Answers1

3

TimeSpan.Minutes is always going to be < 60, because it's only the "minutes component" not the "time represented in minutes."

You should probably be using the corresponding Total methods, such as TimeSpan.TotalMinutes.

cwharris
  • 17,835
  • 4
  • 44
  • 64