Converting Days into Human Readable Duration Text

Given an amount of days, say 25, convert it into a duration text such as “3 Weeks, 4 Days”

C# and F# solutions would both be great if the F# variation offers any improvement over C#.

Edit: The solution should expand past weeks to include months and years. Bonus points for including centuries and so on. Extra bonus if it is somewhat configurable, meaning you can tell the method to exclude the normalization of weeks.

Asked on April 7, 2016 in C#.
Add Comment
1 Answer(s)
String.Format("{0} Weeks, {1} days", days / 7, days % 7);
Answered on April 7, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.