Hyper API for C++ 0.0.18825
Hyper client library for C++ applications
Loading...
Searching...
No Matches
Timestamp.hpp
Go to the documentation of this file.
1
5#ifndef TABLEAU_HYPER_TIMESTAMP_HPP
6#define TABLEAU_HYPER_TIMESTAMP_HPP
7
8#include <hyperapi/Date.hpp>
9#include <hyperapi/Time.hpp>
10#include <string>
11
12namespace hyperapi {
16class Timestamp final {
17 public:
21 Timestamp() noexcept {}
22
29 Timestamp(Date date, Time time) noexcept;
30
36 const Date& getDate() const noexcept;
37
43 const Time& getTime() const noexcept;
44
50 hyper_timestamp_t getRaw() const noexcept;
51
57 std::string toString() const;
58
62 friend bool operator==(const Timestamp& lhs, const Timestamp& rhs) noexcept;
66 friend bool operator>(const Timestamp& lhs, const Timestamp& rhs) noexcept;
70 friend bool operator!=(const Timestamp& a, const Timestamp& b) noexcept { return !(a == b); }
74 friend bool operator<(const Timestamp& a, const Timestamp& b) noexcept { return (b > a); }
78 friend bool operator<=(const Timestamp& a, const Timestamp& b) noexcept { return !(a > b); }
82 friend bool operator>=(const Timestamp& a, const Timestamp& b) noexcept { return !(a < b); }
83
85 friend std::ostream& operator<<(std::ostream& os, const Timestamp& obj) { return os << obj.toString(); }
86
87 private:
88 friend class Inserter;
89 friend class Value;
90 friend struct std::hash<hyperapi::Timestamp>;
91 friend struct internal::ValueInserter;
92
93 struct raw_t {};
94
98 static constexpr uint64_t microseconds_per_day = 24ull * 60 * 60 * 1000 * 1000;
99
105 explicit Timestamp(hyper_timestamp_t rawTimestamp, raw_t) noexcept;
106
110 hyper_timestamp_t representation_ = 0;
114 Date date_;
118 Time time_;
119};
120}
121
122#include <hyperapi/impl/Timestamp.impl.hpp>
123
124#endif
A date data value.
Definition Date.hpp:18
An inserter.
Definition Inserter.hpp:24
A time data value.
Definition Time.hpp:18
A timestamp data value.
Definition Timestamp.hpp:16
hyper_timestamp_t getRaw() const noexcept
Gets the raw timestamp value encoded as microseconds since 1 January 4713 BC.
Timestamp(Date date, Time time) noexcept
Creates a timestamp value with a date and a time component.
Timestamp() noexcept
Default constructor.
Definition Timestamp.hpp:21
friend std::ostream & operator<<(std::ostream &os, const Timestamp &obj)
Stream output operator.
Definition Timestamp.hpp:85
friend bool operator<(const Timestamp &a, const Timestamp &b) noexcept
Less than operator.
Definition Timestamp.hpp:74
const Time & getTime() const noexcept
Gets the time component of the timestamp.
friend bool operator<=(const Timestamp &a, const Timestamp &b) noexcept
Less than or equal operator.
Definition Timestamp.hpp:78
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 Timestamp &a, const Timestamp &b) noexcept
Greater or equal operator.
Definition Timestamp.hpp:82
A value inside a row.
Definition Result.hpp:44
The primary namespace of the Hyper API for C++.
Definition ByteSpan.hpp:15