private static IEnumerable <TimePointBuilder> GetTimePointBuilders(List <string> dayLines) { string dateLine = dayLines[0]; string[] dateText = dateLine.Split('-')[0].Trim().Split('/'); int month = Convert.ToInt32(dateText[0]); int day = Convert.ToInt32(dateText[1]); int year = Convert.ToInt32(dateText[2]); string[] moneyLines = dayLines.Where(ContainsSleepOrAwake).ToArray(); bool firstEntry = true; foreach (string line in moneyLines) { Debug.Log(line); ConciousnessState state = line.ToLower().Contains("sleep") ? ConciousnessState.Asleep : ConciousnessState.Awake; string timePortion = line.Split(']')[1].Trim(); string endPortion = timePortion.Substring(timePortion.Length - 2, 2).ToLower(); string numberPotion = timePortion.Substring(0, timePortion.Length - 2); string hoursString = numberPotion.Split(':')[0]; int hours = Convert.ToInt32(hoursString) % 12; string minutesString = numberPotion.Split(':')[1]; int minutes = Convert.ToInt32(minutesString); int actualDay = day; if ((endPortion == "pm" && hours != 12) || (endPortion == "am" && hours == 12)) { hours += 12; } DateTime time = new DateTime(year, month, actualDay, hours, minutes, 0); if (!firstEntry && endPortion != "pm") { time = time.AddDays(1); } firstEntry = false; TimePointBuilder point = new TimePointBuilder(state, time, endPortion == "am"); yield return(point); } }
public TimePointBuilder(ConciousnessState state, DateTime time, bool am) { State = state; Time = time; Am = am; }
public TimePoint(ConciousnessState state, DateTime time) { _state = state; _time = time; }