Mantid
Loading...
Searching...
No Matches
DateAndTime.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "MantidKernel/DllConfig.h"
10#include "MantidTypes/Core/DateAndTime.h"
11
12#include <cstdint>
13#include <ctime>
14#include <iosfwd>
15#include <string>
16#include <vector>
17
18namespace Mantid {
19namespace Kernel {
25class MANTID_KERNEL_DLL TimeInterval {
26public:
28 TimeInterval() : m_begin(), m_end() {}
30 TimeInterval(const Types::Core::DateAndTime &from, const Types::Core::DateAndTime &to);
32 Types::Core::DateAndTime begin() const { return m_begin; }
34 Types::Core::DateAndTime end() const { return m_end; }
36 bool isValid() const { return m_end > m_begin; }
37
39 Types::Core::time_duration length() const { return m_end - m_begin; }
40
42 bool contains(const Types::Core::DateAndTime &t) const { return t >= begin() && t < end(); }
44 TimeInterval intersection(const TimeInterval &ti) const;
46 bool operator<(const TimeInterval &ti) const { return end() < ti.begin(); }
48 std::string begin_str() const;
50 std::string end_str() const;
51
53 friend MANTID_KERNEL_DLL std::ostream &operator<<(std::ostream &s, const Mantid::Kernel::TimeInterval &t);
54
55private:
57 Types::Core::DateAndTime m_begin;
59 Types::Core::DateAndTime m_end;
60};
61
62} // namespace Kernel
63} // namespace Mantid
std::ostream & operator<<(std::ostream &out, const MantidQt::MantidWidgets::IndexType< i > &index)
Definition: IndexTypes.h:103
Represents a time interval.
Definition: DateAndTime.h:25
TimeInterval()
Default constructor.
Definition: DateAndTime.h:28
Types::Core::DateAndTime m_end
end
Definition: DateAndTime.h:59
Types::Core::DateAndTime begin() const
Beginning of the interval.
Definition: DateAndTime.h:32
bool isValid() const
True if the interval is not empty.
Definition: DateAndTime.h:36
Types::Core::DateAndTime end() const
End of the interval.
Definition: DateAndTime.h:34
Types::Core::DateAndTime m_begin
begin
Definition: DateAndTime.h:57
bool operator<(const TimeInterval &ti) const
Returns true if this interval ends before ti starts.
Definition: DateAndTime.h:46
Types::Core::time_duration length() const
Interval length (in seconds?)
Definition: DateAndTime.h:39
bool contains(const Types::Core::DateAndTime &t) const
True if the interval contains t.
Definition: DateAndTime.h:42
bool MANTID_GEOMETRY_DLL intersection(const ConvexPolygon &P, const ConvexPolygon &Q, ConvexPolygon &out)
Compute the instersection of two convex polygons.
Helper class which provides the Collimation Length for SANS instruments.