public static bool IsStrDate(string strText) { bool result; if (strText.Length != 10) { result = false; } else { string text = strText.Substring(0, 2).Trim(); if (!StringEx.IsStrNumber(text)) { result = false; } else { int num = int.Parse(text); if (num == 0) { result = false; } else { string text2 = strText.Substring(3, 2).Trim(); if (!StringEx.IsStrNumber(text2)) { result = false; } else { int num2 = int.Parse(text2); if (num2 == 0) { result = false; } else { string text3 = strText.Substring(6, 4).Trim(); if (!StringEx.IsStrNumber(text3)) { result = false; } else { int num3 = int.Parse(text3); result = (num3 != 0 && StringEx.IsDate(num, num2, num3)); } } } } } } return(result); }
public static DateTime GetDate(string strText) { DateTime now = DateTime.Now; int length = strText.Length; DateTime result; if (length != 10) { result = now; } else { string text = strText.Substring(0, 2).Trim(); if (!StringEx.IsStrNumber(text)) { result = now; } else { int num = int.Parse(text); string text2 = strText.Substring(3, 2).Trim(); if (!StringEx.IsStrNumber(text2)) { result = now; } else { int num2 = int.Parse(text2); string text3 = strText.Substring(6, 4).Trim(); if (!StringEx.IsStrNumber(text3)) { result = now; } else { int num3 = int.Parse(text3); if (!StringEx.IsDate(num, num2, num3)) { result = now; } else { result = new DateTime(num3, num2, num); } } } } } return(result); }