41 lines
1.4 KiB
C++
41 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "dtcore/inc/dtdefinitions.h"
|
|
#include "dtcore/inc/dtstream.h"
|
|
#include "dtcore/inc/dtstring.h"
|
|
#include "dtcore/inc/dtvector.h"
|
|
#include "dtcore/inc/dttime.h"
|
|
|
|
namespace dt
|
|
{
|
|
// This class works with UTC time
|
|
class TimeInterval : public Serializable
|
|
{
|
|
public:
|
|
DT_CORE_DLL_ENTRY TimeInterval() = default;
|
|
DT_CORE_DLL_ENTRY TimeInterval(const Time& start, const Time& end);
|
|
DT_CORE_DLL_ENTRY TimeInterval(const Time& start, const Time& end, const Vector<S8> availableDays);
|
|
|
|
DT_CORE_DLL_ENTRY const Time& GetStart() const { return m_Start; }
|
|
DT_CORE_DLL_ENTRY const Time& GetEnd() const { return m_End; }
|
|
DT_CORE_DLL_ENTRY const Vector<S8>& GetWeekDays() const { return m_WeekDays; };
|
|
|
|
DT_CORE_DLL_ENTRY bool IsValid() const;
|
|
DT_CORE_DLL_ENTRY bool IsInInterval(const Time& moment) const;
|
|
|
|
DT_CORE_DLL_ENTRY bool operator==(const TimeInterval& rhs) const;
|
|
DT_CORE_DLL_ENTRY bool operator!=(const TimeInterval& rhs) const;
|
|
|
|
DT_CORE_DLL_ENTRY virtual void Serialize(U8 version, Stream& stream) override;
|
|
DT_CORE_DLL_ENTRY virtual U8 GetSerializeVersion() const override { return 2; }
|
|
|
|
private:
|
|
Time m_Start;
|
|
Time m_End;
|
|
Vector<S8> m_WeekDays;
|
|
};
|
|
|
|
DT_CORE_DLL_ENTRY String& operator<<(String& out, const TimeInterval& interval);
|
|
|
|
typedef Vector<TimeInterval> TimeIntervals;
|
|
}
|