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_start(), m_stop() {}
30 TimeInterval(const Types::Core::DateAndTime &from, const Types::Core::DateAndTime &to);
31 TimeInterval(const std::string &from, const std::string &to);
32
34 const Types::Core::DateAndTime &start() const { return m_start; }
36 const Types::Core::DateAndTime &stop() const { return m_stop; }
38 bool isValid() const { return m_stop > m_start; }
39
41 Types::Core::time_duration length() const;
43 double duration() const;
44
46 bool contains(const Types::Core::DateAndTime &t) const { return t >= start() && t < stop(); }
48 bool overlaps(const TimeInterval *other) const;
50 bool overlaps(const TimeInterval &other) const;
51
53 TimeInterval intersection(const TimeInterval &ti) const;
55 bool operator<(const TimeInterval &ti) const;
56 bool operator>(const TimeInterval &ti) const;
57 bool operator==(const TimeInterval &ti) const;
59 std::string begin_str() const;
61 std::string end_str() const;
62
64 friend MANTID_KERNEL_DLL std::ostream &operator<<(std::ostream &s, const Mantid::Kernel::TimeInterval &t);
65
66private:
68 Types::Core::DateAndTime m_start;
70 Types::Core::DateAndTime m_stop;
71};
72
73} // namespace Kernel
74} // namespace Mantid
Represents a time interval.
Definition DateAndTime.h:25
TimeInterval()
Default constructor.
Definition DateAndTime.h:28
const Types::Core::DateAndTime & start() const
Beginning of the interval.
Definition DateAndTime.h:34
bool isValid() const
True if the interval is not empty.
Definition DateAndTime.h:38
Types::Core::DateAndTime m_stop
end
Definition DateAndTime.h:70
const Types::Core::DateAndTime & stop() const
End of the interval.
Definition DateAndTime.h:36
Types::Core::DateAndTime m_start
begin
Definition DateAndTime.h:68
bool contains(const Types::Core::DateAndTime &t) const
True if the interval contains t.
Definition DateAndTime.h:46
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.
constexpr bool operator==(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator>(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator<(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr wide_integer< Bits, Signed > operator<<(const wide_integer< Bits, Signed > &lhs, T2 n) noexcept