Represents time in segments (hour, minute, etc.).
More...
#include <time.hpp>
Represents time in segments (hour, minute, etc.).
Definition at line 45 of file calendars/mtcore_calendars/time.hpp.
◆ operator DayFraction()
mtcore::calendars::Segments::operator DayFraction |
( |
| ) |
const |
|
explicitnodiscardconstexpr |
◆ operator NanoSeconds()
mtcore::calendars::Segments::operator NanoSeconds |
( |
| ) |
const |
|
explicitnodiscardconstexpr |
Definition at line 180 of file calendars/mtcore_calendars/time.hpp.
180 {
182 const auto hours =
static_cast<u64>(this->
hour);
183 const auto minutes = 60 * hours +
static_cast<u64>(this->
minute);
184 const auto seconds = 60 * minutes +
static_cast<u64>(this->
second);
186 const auto res = NanoSeconds{.nano =
nano};
187 ensure(res.try_validate().is_success());
188 return res;
189 }
constexpr i32 NANOS_PER_SECOND
Number of nanoseconds per second.
#define ensure(check,...)
Ensures that a check holds true, aborts the program if not true Will print error if the condition is ...
uint64_t u64
Alias for 64-bit unsigned ints.
constexpr Result< void, TimeValidationError > try_validate() const
Tries to validate.
◆ operator!=()
bool mtcore::calendars::Segments::operator!= |
( |
const Segments & | o | ) |
const |
|
inlinenodiscard |
◆ operator<()
bool mtcore::calendars::Segments::operator< |
( |
const Segments & | o | ) |
const |
|
inlinenodiscard |
◆ operator<=()
bool mtcore::calendars::Segments::operator<= |
( |
const Segments & | o | ) |
const |
|
inlinenodiscard |
Definition at line 95 of file calendars/mtcore_calendars/time.hpp.
95 {
96 const auto cmp = (*this <=> o);
97 return cmp == std::strong_ordering::equal || cmp == std::strong_ordering::less;
98 }
◆ operator<=>()
auto mtcore::calendars::Segments::operator<=> |
( |
const Segments & | o | ) |
const |
|
inlinenodiscardconstexpr |
◆ operator==()
bool mtcore::calendars::Segments::operator== |
( |
const Segments & | o | ) |
const |
|
inlinenodiscard |
◆ operator>()
bool mtcore::calendars::Segments::operator> |
( |
const Segments & | o | ) |
const |
|
inlinenodiscard |
◆ operator>=()
bool mtcore::calendars::Segments::operator>= |
( |
const Segments & | o | ) |
const |
|
inlinenodiscard |
Definition at line 99 of file calendars/mtcore_calendars/time.hpp.
99 {
100 const auto cmp = (*this <=> o);
101 return cmp == std::strong_ordering::equal || cmp == std::strong_ordering::greater;
102 }
◆ to_fraction_unchecked()
f64 mtcore::calendars::Segments::to_fraction_unchecked |
( |
| ) |
const |
|
nodiscardconstexpr |
Converts to a day fraction without checking if it's valid.
Prefer casting to a DayFraction. Used with internal conversion methods.
Definition at line 195 of file calendars/mtcore_calendars/time.hpp.
195 {
196 const auto hours =
static_cast<u64>(this->
hour);
197 const auto minutes = 60 * hours +
static_cast<u64>(this->
minute);
198 const auto seconds = 60 * minutes +
static_cast<u64>(this->
second);
200 const auto nanoFloat =
static_cast<f80>(
nano);
202 return static_cast<f64>(frac);
203 }
constexpr i64 NANOS_PER_DAY
Number of nanoseconds per day.
double f64
Alias for 64-bit floats.
long double f80
Alias for 80-bit floats.
◆ try_validate()
Tries to validate.
Will return validation error describing what's wrong if invalid.
Definition at line 52 of file calendars/mtcore_calendars/time.hpp.
52 {
55 }
56
59 }
60
63 }
64
67 }
68
70 }
Success< void > success()
Creates a successful void Result object.
Error< Underlying > error(Underlying err)
Creates an error.
◆ hour
u8 mtcore::calendars::Segments::hour = 0 |
◆ minute
u8 mtcore::calendars::Segments::minute = 0 |
◆ nano
u32 mtcore::calendars::Segments::nano = 0 |
◆ second
u8 mtcore::calendars::Segments::second = 0 |
The documentation for this struct was generated from the following file: