public DateTimeMy(int _seconds, int _minutes, int _hours, int _days, int _months, int _years, PMorAM _postORanteMerediem) { seconds = _seconds; minutes = _minutes; hours = _hours; days = _days; months = _months; years = _years; postORanteMerediem = _postORanteMerediem; }
public static DateTimeMy GetDateTimeFromString(string stringToParse) { int _seconds = 0; int _minutes = 0; int _hours = 0; int _months = 0; int _days = 0; int _years = 0; PMorAM _postORanteMerediem = PMorAM.NULL; if (stringToParse.Split('.').Length == 0) { string date = stringToParse.Split(' ')[0]; string time = stringToParse.Split(' ')[1]; _seconds = Convert.ToInt32(time.Split(':')[2]); _minutes = Convert.ToInt32(time.Split(':')[1]); _hours = Convert.ToInt32(time.Split(':')[0]); _months = Convert.ToInt32(date.Split('/')[0]); _days = Convert.ToInt32(date.Split('/')[1]); _years = Convert.ToInt32(date.Split('/')[2]); if (stringToParse.Split(' ')[2] == "PM") { _postORanteMerediem = PMorAM.PM; } else { _postORanteMerediem = PMorAM.AM; } } else { _seconds = Convert.ToInt32(stringToParse.Split('.')[0].Split(':')[2]); _minutes = Convert.ToInt32(stringToParse.Split('.')[0].Split(':')[1]); _hours = Convert.ToInt32(stringToParse.Split('.')[0].Split(':')[0]); } return(new DateTimeMy(_seconds, _minutes, _hours, _days, _months, _years, _postORanteMerediem)); }