Apache Ignite C++ Client
Loading...
Searching...
No Matches
ignite_date_time.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
20#include "ignite_date.h"
21#include "ignite_time.h"
22
23#include <cstdint>
24
25namespace ignite {
26
33public:
37 constexpr ignite_date_time() noexcept = default;
38
48
52 [[nodiscard]] constexpr const ignite_date &date() const noexcept { return *this; }
53
57 [[nodiscard]] constexpr const ignite_time &time() const noexcept { return *this; }
58
65 [[nodiscard]] constexpr int compare(const ignite_date_time &other) const noexcept {
66 if (int cmp = date().compare(other.date())) {
67 return cmp;
68 }
69 return time().compare(other.time());
70 }
71};
72
80constexpr bool operator==(const ignite_date_time &lhs, const ignite_date_time &rhs) noexcept {
81 return lhs.compare(rhs) == 0;
82}
83
91constexpr bool operator!=(const ignite_date_time &lhs, const ignite_date_time &rhs) noexcept {
92 return lhs.compare(rhs) != 0;
93}
94
102constexpr bool operator<(const ignite_date_time &lhs, const ignite_date_time &rhs) noexcept {
103 return lhs.compare(rhs) < 0;
104}
105
113constexpr bool operator<=(const ignite_date_time &lhs, const ignite_date_time &rhs) noexcept {
114 return lhs.compare(rhs) <= 0;
115}
116
124constexpr bool operator>(const ignite_date_time &lhs, const ignite_date_time &rhs) noexcept {
125 return lhs.compare(rhs) > 0;
126}
127
135constexpr bool operator>=(const ignite_date_time &lhs, const ignite_date_time &rhs) noexcept {
136 return lhs.compare(rhs) >= 0;
137}
138
139} // namespace ignite
A date together with time of day with nanosecond precision.
Definition ignite_date_time.h:32
constexpr int compare(const ignite_date_time &other) const noexcept
Definition ignite_date_time.h:65
constexpr const ignite_date & date() const noexcept
Definition ignite_date_time.h:52
constexpr const ignite_time & time() const noexcept
Definition ignite_date_time.h:57
constexpr ignite_date_time() noexcept=default
constexpr ignite_date() noexcept=default
constexpr ignite_time() noexcept=default
constexpr int compare(const ignite_time &other) const noexcept
Definition ignite_time.h:79