C# library to parse human readable time spans
c#, date, parsing
Solution
I took a crack at this sometime back, I was playing with parsers as I knew nothing about them so don't expect quality. But you can get the code here: http://timestamper.codeplex.com/
I havent looked at it for a while, but im pretty sure it can do all the things that you mentioned above.
Edit:
Just noted that you wanted a timespan object returned and not a date time. The code I provided will return a DateTime reletive to today i.e.
"2 days" will be: DateTime.Now.AddDays(2);
At least I think this is what is did, can quite be sure. If this is the case, you should just be able to get the timespan between the two DateTimes.
Problem
Is there a library that exists that will parse human readable timespans into a .NET TimeSpan? I need something that will parse strings like: ``` 30 days 1 week 5 hours ``` Does such a thing exist? Its probably not too hard to write myself, but if something is out there, it would be so much easier! I currently don't need functionality like "30 days, 3 hours, 5 minutes", just the one value, but it couldn't hurt!