public DateTime GetFirstTransactionDate(DateTime current, DateLevel level) { switch (level) { case DateLevel.Month: var startOfMonth = new DateTime(current.Year, current.Month, 1); return(GetStockTransactionDate(startOfMonth, startOfMonth.AddDays(10)).Min()); case DateLevel.Year: var startOfYear = new DateTime(current.Year, 1, 1); return(GetStockTransactionDate(startOfYear, startOfYear.AddDays(10)).Min()); default: throw new Exception("参数错误!"); } }
public DateTime GetLastTransactionDate(DateTime current, DateLevel level) { switch (level) { case DateLevel.Month: var lastDayOfMonth = new DateTime(current.Year, current.Month + 1, 1).AddDays(-1); return(GetStockTransactionDate(lastDayOfMonth.AddDays(-10), lastDayOfMonth).Max()); case DateLevel.Year: var lastDayOfYear = new DateTime(current.Year + 1, 1, 1).AddDays(-1); return(GetStockTransactionDate(lastDayOfYear.AddDays(-10), lastDayOfYear).Max()); default: throw new Exception("参数错误!"); } }