public TimeViewItem(DateTime time, AMPMS ampm) { var factory = new TimeFactory(); var sdatefmt = new DateTimeFormatter("shortdate"); Date = sdatefmt.Format(time); Time = $"{MiruConverter.ConvertNumber(MiruConverter.ConvertHour(time.Hour))}:{MiruConverter.ConvertNumber(time.Minute)}"; AMPM = TimeConverter.ConvertString(ampm); }
public static Dictionary <string, string> ConvertBaseDateTime(DateTime time) { int hour = time.Hour; int min = time.Minute; var baseList = new List <int>() { 2, 5, 8, 11, 14, 17, 20, 23 }; int baseResult = 0; if (hour == baseList[7] || hour < baseList[0]) { baseResult = baseList[7]; if (hour == baseList[7]) { if (min < 11) { baseResult = baseList[6]; } } } else if (hour >= baseList[0] && hour < baseList[1]) { baseResult = baseList[0]; if (hour == baseList[0]) { if (min < 11) { baseResult = baseList[7]; } } } else { for (int i = 1; i < baseList.Count; i++) { if (hour >= baseList[i] && hour < baseList[i + 1]) { baseResult = baseList[i]; if (hour == baseList[i]) { if (min < 11) { baseResult = baseList[i - 1]; } } } } } if (hour < baseList[0]) { time = time.Subtract(TimeSpan.FromDays(1)); } var baseDate = $"{time.Year}{MiruConverter.ConvertNumber(time.Month)}{MiruConverter.ConvertNumber(time.Day)}"; var baseTime = MiruConverter.ConvertNumber(baseResult) + "00"; return(new Dictionary <string, string> { ["baseDate"] = baseDate, ["baseTime"] = baseTime }); }