Is there an elegant way to be permissive in date input in C# to accommodate user input like ‘2009-09-31’ (e.g. September 31, which doesn’t exist and causes DateTime.Parse to choke)? Ideally I would like to parse this as October 1 (e.g. latest possible date plus overflow).
Share
I don’t believe this is handled directly for you. What you could do is parse the date yourself, as three separate integers:
dt = dt.AddMonths(8)to get September 1stdt.AddDays(30)This will handle things like 2009/13/01 to mean 1st January 2010. It won’t do what you want with February 31st though, I suspect…