private static DateTime SecondsMidNight2DateTime(int SecondsMidNight, int year, int month, int day) { int hour, minutes, seconds; ModelUtil.SecondsMidNight2Time(SecondsMidNight, out hour, out minutes, out seconds); DateTime dateTime = new DateTime(year, month, day, hour, minutes, seconds); return(dateTime); }
//从filenpath中获取,这就要求文件夹必须一天一个 public static DateTime ProcessSecondMidNight(String filepath, int secondsMidNight) { if (!Regex.IsMatch(filepath, @"\d{4}(\-|\/|.)\d{1,2}\1\d{1,2}")) { throw new Exception("filepath don't have date"); } var match = Regex.Match(filepath, @"\d{4}(\-|\/|.)\d{1,2}\1\d{1,2}"); DateTime d = DateTime.ParseExact(match.Value, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture); int hour, minutes, seconds; ModelUtil.SecondsMidNight2Time(secondsMidNight, out hour, out minutes, out seconds); DateTime dateTime = new DateTime(d.Year, d.Month, d.Day, hour, minutes, seconds); return(dateTime); }