1

イベントを Agenda のようなテーブルに管理する WebApplication があります。イベントごとにStartDateEndDateがあります。

アプリケーションでは、イベントをグラフにエクスポートし、イベントが必要な日付の範囲を通過するかどうかを確認したいと考えています。

例: イベント 1: StartDate (9 月 9 日) EndDate (9 月 14 日)

合格したか確認したい(9月10日~9月16日)

これは、イベントの例のグラフの写真です。 ここに画像の説明を入力

これは、1 つの日付のみをチェックするコードです。

public static bool Within(this DateTime current, DateTime startTime, DateTime endTime)
    {
        return startTime < currentTime < endTime;
    }

編集: さらに明確にするために、イベントが2つの日付範囲を通過した場合、関数がtrueを返すようにしたい.

範囲を超えない場合にのみ false を返します。

4

3 に答える 3

1
public static bool Within(DateTime one, DateTime two,
                          DateTime lowBound, DateTime highBound)
{
    return one >= lowBound && two <= highBound;
}
于 2013-11-03T16:18:32.320 に答える
0
public static bool Within(this DateTime current, DateTime startTime, DateTime endTime)
    {
        return startTime < currentTime && currentTime < endTime;
    }

そして、それを2回呼び出します

lowDate.Within(eventStart, eventEnd) && heDate.Within(eventStart, eventEnd)
于 2013-11-03T16:15:12.083 に答える