public static InexactDate GetInexactDate(string dateTime) { // *** Get inexact date from string formatted as MM/dd/yyyy *** // *** Handles zeros in each part and creates inexact *** InexactDate returnVal; int month = -1; int day = -1; int year = -1; try { // *** Split by slash *** string[] temp = Util.Split(dateTime, "/"); // *** Check if have result *** if (temp != null) { // *** Try parse each value *** if (temp.Length > 0) { int.TryParse(temp[0], out month); } if (temp.Length > 1) { int.TryParse(temp[1], out day); } if (temp.Length > 2) { int.TryParse(temp[2], out year); } } } catch { } returnVal = new InexactDate(year, month, day); return(returnVal); }
public static InexactDate GetInexactDateFromFM(string fileManDateTime) { // *** Get inexact date from fileman date *** InexactDate returnVal; int[] dateVals = new int[3] { -1, -1, -1 }; try { // *** Get string values of date parts *** string year = fileManDateTime.Substring(0, 3); string month = fileManDateTime.Substring(3, 2); string day = fileManDateTime.Substring(5, 2); // *** Try to get integer values for each part *** if (int.TryParse(year, out dateVals[0])) { dateVals[0] += 1700; if (int.TryParse(month, out dateVals[1])) { int.TryParse(day, out dateVals[2]); } } } catch { } // *** Create inexact date based on found values *** returnVal = new InexactDate(dateVals[0], dateVals[1], dateVals[2]); return(returnVal); }