2024-05-30 14:49:54 +00:00
|
|
|
|
using System;
|
2024-05-31 12:37:15 +00:00
|
|
|
|
using ColdMint.scripts.debug;
|
2024-05-30 14:49:54 +00:00
|
|
|
|
|
|
|
|
|
namespace ColdMint.scripts.utils;
|
|
|
|
|
|
2024-06-05 13:38:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>Time Utils</para>
|
|
|
|
|
/// <para>时间工具</para>
|
|
|
|
|
/// </summary>
|
2024-05-30 14:49:54 +00:00
|
|
|
|
public static class TimeUtils
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>Determines whether the specified time is within the specified range</para>
|
|
|
|
|
/// <para>判断指定的时间是否在指定的范围</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dateTime">
|
|
|
|
|
/// <para>The value is a string in the format yyyy-MM-dd hh:mm:ss</para>
|
|
|
|
|
/// <para>指定时间,字符串类型,形如:yyyy-MM-dd hh:mm:ss</para>
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <param name="startTime">
|
|
|
|
|
///<para>The value is a string of characters in the format yyyy-MM-dd hh:mm:ss</para>
|
|
|
|
|
/// <para>开始时间,字符串类型,形如:yyyy-MM-dd hh:mm:ss</para>
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <param name="endTime">
|
|
|
|
|
/// <para>End time The value is a string in the format yyyy-MM-dd hh:mm:ss</para>
|
|
|
|
|
///<para>结束时间,字符串类型,形如:yyyy-MM-dd hh:mm:ss</para>
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static bool IsBetweenTimeSpan(DateTime dateTime, string startTime, string endTime)
|
|
|
|
|
{
|
|
|
|
|
var dtStartTime = Convert.ToDateTime(startTime);
|
|
|
|
|
var dtEndTime = Convert.ToDateTime(endTime);
|
|
|
|
|
var compNum1 = DateTime.Compare(dateTime, dtStartTime);
|
|
|
|
|
var compNum2 = DateTime.Compare(dateTime, dtEndTime);
|
2024-05-31 12:37:15 +00:00
|
|
|
|
var result = compNum1 >= 0 && compNum2 <= 0;
|
2024-10-11 09:59:47 +00:00
|
|
|
|
LogCat.LogWithFormat("time_range_debug", LogCat.LogLabel.Default, dateTime, dtStartTime, dtEndTime,
|
2024-07-02 15:16:04 +00:00
|
|
|
|
result);
|
2024-05-31 12:37:15 +00:00
|
|
|
|
return result;
|
2024-05-30 14:49:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|