Skip to content

Date difference to natural text

kappy edited this page Apr 9, 2012 · 2 revisions

Date Difference To Natural Text

This extensions can compare two dates in natural language based on the current locale on current thread CultureInfo. There are 2 API points for them:

  • fromDate.ToNaturalText(toTime, bool round = true)

  • fromDate.ToExactNaturalText(toTime)

The first will return the most valuable time component with value > 0. The round flag will try to round the most significant time component based on the next least significant. Also, the round flag will round minutes and seconds to quarters after the first one.