Datetime增加Between方法
This commit is contained in:
parent
5b7a438725
commit
4566a84d96
|
@ -137,6 +137,18 @@ namespace Falcon.SugarApi
|
|||
public static string ToDateTime(this DateTime date) => date.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 时间是否处于某个时间段内
|
||||
/// </summary>
|
||||
/// <param name="dt">要判断的时间</param>
|
||||
/// <param name="start">开始时间</param>
|
||||
/// <param name="end">结束时间</param>
|
||||
/// <returns>True是,False否</returns>
|
||||
public static bool Between(this DateTime? dt,DateTime start,DateTime? end = null) {
|
||||
end ??= DateTime.Now;
|
||||
return dt > start && dt <= end;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user