Hyper API for C++  0.0.15888
Hyper client library for C++ applications
OffsetTimestamp.hpp
Go to the documentation of this file.
1 
5 #ifndef TABLEAU_HYPER_OFFSET_TIMESTAMP_HPP
6 #define TABLEAU_HYPER_OFFSET_TIMESTAMP_HPP
7 
8 #include <chrono>
9 #include <hyperapi/Date.hpp>
10 #include <hyperapi/Time.hpp>
11 #include <string>
12 
13 namespace hyperapi {
17 class OffsetTimestamp final {
18  public:
22  OffsetTimestamp() noexcept {}
23 
31  OffsetTimestamp(Date date, Time time, std::chrono::minutes offset) noexcept;
32 
38  const Date& getDate() const noexcept;
39 
45  const Time& getTime() const noexcept;
46 
52  std::chrono::minutes getOffset() const noexcept;
53 
59  hyper_timestamp_t getRaw() const noexcept;
60 
66  std::string toString() const;
67 
71  friend bool operator==(const OffsetTimestamp& lhs, const OffsetTimestamp& rhs) noexcept;
75  friend bool operator>(const OffsetTimestamp& lhs, const OffsetTimestamp& rhs) noexcept;
79  friend bool operator!=(const OffsetTimestamp& a, const OffsetTimestamp& b) noexcept { return !(a == b); }
83  friend bool operator<(const OffsetTimestamp& a, const OffsetTimestamp& b) noexcept { return (b > a); }
87  friend bool operator<=(const OffsetTimestamp& a, const OffsetTimestamp& b) noexcept { return !(a > b); }
91  friend bool operator>=(const OffsetTimestamp& a, const OffsetTimestamp& b) noexcept { return !(a < b); }
92 
94  friend std::ostream& operator<<(std::ostream& os, const OffsetTimestamp& obj) { return os << obj.toString(); }
95 
96  private:
97  friend class Inserter;
98  friend class Value;
99  friend struct std::hash<hyperapi::OffsetTimestamp>;
100  friend struct internal::ValueInserter;
101 
102  struct raw_t {};
103 
107  static constexpr uint64_t microseconds_per_minute = 60 * 1000 * 1000;
111  static constexpr uint64_t microseconds_per_day = 24ull * 60 * microseconds_per_minute;
112 
118  explicit OffsetTimestamp(hyper_timestamp_t rawTimestamp, raw_t) noexcept;
119 
123  hyper_timestamp_t m_representation = 0;
127  Date m_date;
131  Time m_time;
135  std::chrono::minutes m_offset{0};
136 };
137 }
138 
139 #include <hyperapi/impl/OffsetTimestamp.impl.hpp>
140 
141 #endif
hyperapi::Inserter
An inserter.
Definition: Inserter.hpp:24
hyperapi::OffsetTimestamp::operator>=
friend bool operator>=(const OffsetTimestamp &a, const OffsetTimestamp &b) noexcept
Greater or equal operator.
Definition: OffsetTimestamp.hpp:91
hyperapi::OffsetTimestamp::getTime
const Time & getTime() const noexcept
Gets the time component of the timestamp.
hyperapi::OffsetTimestamp::OffsetTimestamp
OffsetTimestamp() noexcept
Default constructor.
Definition: OffsetTimestamp.hpp:22
Date.hpp
hyperapi::OffsetTimestamp
A timestamp data value with an offset to UTC.
Definition: OffsetTimestamp.hpp:17
hyperapi::OffsetTimestamp::getRaw
hyper_timestamp_t getRaw() const noexcept
Gets the raw timestamp value encoded as microseconds since 1 January 4713 BC.
hyperapi::OffsetTimestamp::getDate
const Date & getDate() const noexcept
Gets the date component of the timestamp.
hyperapi::OffsetTimestamp::operator<=
friend bool operator<=(const OffsetTimestamp &a, const OffsetTimestamp &b) noexcept
Less than or equal operator.
Definition: OffsetTimestamp.hpp:87
hyperapi::Value
A value inside a row.
Definition: Result.hpp:44
hyperapi::OffsetTimestamp::getOffset
std::chrono::minutes getOffset() const noexcept
Gets the offset to UTC of the timestamp in minutes.
hyperapi::Time
A time data value.
Definition: Time.hpp:18
hyperapi::OffsetTimestamp::toString
std::string toString() const
Returns a string representation for debugging.
Time.hpp
hyperapi::OffsetTimestamp::operator<<
friend std::ostream & operator<<(std::ostream &os, const OffsetTimestamp &obj)
Stream output operator.
Definition: OffsetTimestamp.hpp:94
hyperapi
The primary namespace of the Hyper API for C++.
Definition: ByteSpan.hpp:15
hyperapi::Date
A date data value.
Definition: Date.hpp:18
hyperapi::OffsetTimestamp::operator<
friend bool operator<(const OffsetTimestamp &a, const OffsetTimestamp &b) noexcept
Less than operator.
Definition: OffsetTimestamp.hpp:83