Hyper API for C++ 0.0.20746
Hyper client library for C++ applications
Loading...
Searching...
No Matches
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
13namespace hyperapi {
17class OffsetTimestamp final {
18 public:
22 struct raw_t {};
23
27 OffsetTimestamp() noexcept {}
28
36 OffsetTimestamp(Date date, Time time, std::chrono::minutes offset) noexcept;
37
43 explicit OffsetTimestamp(hyper_timestamp_t rawTimestamp, raw_t) noexcept;
44
50 const Date& getDate() const noexcept;
51
57 const Time& getTime() const noexcept;
58
64 std::chrono::minutes getOffset() const noexcept;
65
71 hyper_timestamp_t getRaw() const noexcept;
72
78 std::string toString() const;
79
83 friend bool operator==(const OffsetTimestamp& lhs, const OffsetTimestamp& rhs) noexcept;
87 friend bool operator>(const OffsetTimestamp& lhs, const OffsetTimestamp& rhs) noexcept;
91 friend bool operator!=(const OffsetTimestamp& a, const OffsetTimestamp& b) noexcept { return !(a == b); }
95 friend bool operator<(const OffsetTimestamp& a, const OffsetTimestamp& b) noexcept { return (b > a); }
99 friend bool operator<=(const OffsetTimestamp& a, const OffsetTimestamp& b) noexcept { return !(a > b); }
103 friend bool operator>=(const OffsetTimestamp& a, const OffsetTimestamp& b) noexcept { return !(a < b); }
104
106 friend std::ostream& operator<<(std::ostream& os, const OffsetTimestamp& obj) { return os << obj.toString(); }
107
108 private:
109 friend class Inserter;
110 friend class Value;
111 friend struct std::hash<hyperapi::OffsetTimestamp>;
112 friend struct internal::ValueInserter;
113
117 static constexpr uint64_t microseconds_per_minute = 60 * 1000 * 1000;
121 static constexpr uint64_t microseconds_per_day = 24ull * 60 * microseconds_per_minute;
122
126 hyper_timestamp_t representation_ = 0;
130 Date date_;
134 Time time_;
138 std::chrono::minutes offset_{0};
139};
140}
141
142#include <hyperapi/impl/OffsetTimestamp.impl.hpp>
143
144#endif
A date data value.
Definition Date.hpp:18
An inserter.
Definition Inserter.hpp:24
A timestamp data value with an offset to UTC.
std::chrono::minutes getOffset() const noexcept
Gets the offset to UTC of the timestamp in minutes.
friend std::ostream & operator<<(std::ostream &os, const OffsetTimestamp &obj)
Stream output operator.
OffsetTimestamp() noexcept
Default constructor.
friend bool operator<=(const OffsetTimestamp &a, const OffsetTimestamp &b) noexcept
Less than or equal operator.
std::string toString() const
Returns a string representation for debugging.
const Date & getDate() const noexcept
Gets the date component of the timestamp.
OffsetTimestamp(hyper_timestamp_t rawTimestamp, raw_t) noexcept
Creates a timestamp from a raw timestamp value encoded as microseconds since 1 January 4713 BC.
friend bool operator<(const OffsetTimestamp &a, const OffsetTimestamp &b) noexcept
Less than operator.
hyper_timestamp_t getRaw() const noexcept
Gets the raw timestamp value encoded as microseconds since 1 January 4713 BC.
friend bool operator>=(const OffsetTimestamp &a, const OffsetTimestamp &b) noexcept
Greater or equal operator.
OffsetTimestamp(Date date, Time time, std::chrono::minutes offset) noexcept
Creates a timestamp value with a date, time, and offset component.
const Time & getTime() const noexcept
Gets the time component of the timestamp.
Marker struct for the raw timestamp constructor.
A time data value.
Definition Time.hpp:18
A value inside a row.
Definition Result.hpp:44
The primary namespace of the Hyper API for C++.
Definition ByteSpan.hpp:15