15 extern const int64_t kDaysSoFar[];
16 extern const int64_t kLeapDaysSoFar[];
23 Date() : year{0}, month{1}, day{1} {}
24 Date(int16_t y, int8_t m, int8_t d) : year{y}, month{m}, day{d} {}
26 explicit Date(uint64_t days);
38 void reset(int16_t y, int8_t m, int8_t d) {
44 bool operator==(
const Date& rhs)
const {
45 return year == rhs.year && month == rhs.month && day == rhs.day;
48 bool operator<(
const Date& rhs)
const {
49 if (!(year == rhs.year)) {
50 return year < rhs.year;
52 if (!(month == rhs.month)) {
53 return month < rhs.month;
55 if (!(day == rhs.day)) {
61 Date operator+(int64_t days)
const;
62 Date operator-(int64_t days)
const;
64 std::string toString()
const;
67 int64_t toInt()
const;
69 void fromInt(int64_t days);
72 inline std::ostream& operator<<(std::ostream& os,
const Date& d) {
83 Time() : hour{0}, minute{0}, sec{0}, microsec{0} {}
84 Time(int8_t h, int8_t min, int8_t s, int32_t us) : hour{h}, minute{min}, sec{s}, microsec{us} {}
97 bool operator==(
const Time& rhs)
const {
98 return hour == rhs.hour && minute == rhs.minute && sec == rhs.sec && microsec == rhs.microsec;
101 bool operator<(
const Time& rhs)
const {
102 if (!(hour == rhs.hour)) {
103 return hour < rhs.hour;
105 if (!(minute == rhs.minute)) {
106 return minute < rhs.minute;
108 if (!(sec == rhs.sec)) {
109 return sec < rhs.sec;
111 if (!(microsec == rhs.microsec)) {
112 return microsec < rhs.microsec;
117 std::string toString()
const;
120 inline std::ostream& operator<<(std::ostream& os,
const Time& d) {
126 #if defined(__GNUC__)
127 #pragma GCC diagnostic push
128 #pragma GCC diagnostic ignored "-Wpedantic"
138 uint64_t microsec : 22;
142 #if defined(__GNUC__)
143 #pragma GCC diagnostic pop
146 DateTime() : year{0}, month{1}, day{1}, hour{0}, minute{0}, sec{0}, microsec{0} {}
147 DateTime(int16_t y, int8_t m, int8_t d, int8_t h, int8_t min, int8_t s, int32_t us) {
180 bool operator==(
const DateTime& rhs)
const {
181 return year == rhs.year && month == rhs.month && day == rhs.day && hour == rhs.hour &&
182 minute == rhs.minute && sec == rhs.sec && microsec == rhs.microsec;
184 bool operator<(
const DateTime& rhs)
const {
185 if (!(year == rhs.year)) {
186 return year < rhs.year;
188 if (!(month == rhs.month)) {
189 return month < rhs.month;
191 if (!(day == rhs.day)) {
192 return day < rhs.day;
194 if (!(hour == rhs.hour)) {
195 return hour < rhs.hour;
197 if (!(minute == rhs.minute)) {
198 return minute < rhs.minute;
200 if (!(sec == rhs.sec)) {
201 return sec < rhs.sec;
203 if (!(microsec == rhs.microsec)) {
204 return microsec < rhs.microsec;
209 std::string toString()
const;
212 inline std::ostream& operator<<(std::ostream& os,
const DateTime& d) {
223 struct hash<nebula::Date> {
224 std::size_t operator()(
const nebula::Date& h)
const noexcept;
228 struct hash<nebula::Time> {
229 std::size_t operator()(
const nebula::Time& h)
const noexcept;
233 struct hash<nebula::DateTime> {