Hyper API for C++ 0.0.18825
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 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 representation_ = 0;
127 Date date_;
131 Time time_;
135 std::chrono::minutes offset_{0};
136};
137}
138
139#include <hyperapi/impl/OffsetTimestamp.impl.hpp>
140
141#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.
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.
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