Tuesday, February 01, 2005

TimeSpan.Parse() and the Delay shape

When using configurable delays (defined in the .config), I began by assuming that we would always implement delays in days, as we were working with 6 week schedules. I was then asked if we could compress 6 weeks of schedule into a single day, for testing, meaning that I now had to specify the delay in hours. I then spent some time coming up with a clever way to parse config strings to provide maximum flexibility (e.g. to allow delays of days, or seconds, and everything in between.)

It then twigged that the TimeSpan class probably already has a Parse() method (as DateTime does.) It does, and it accepts all manner of useful input.

Details of the input string format here.

No comments: