31#ifndef ETL_IN_CHRONO_H
32 #error DO NOT DIRECTLY INCLUDE THIS FILE. USE CHRONO.H
82 int days_since_epoch =
static_cast<int>(sd.time_since_epoch().count());
91 int days_in_year = current_year.
is_leap() ? 366 : 365;
93 if (days_since_epoch < days_in_year)
98 days_since_epoch -= days_in_year;
105 unsigned char days_in_month = etl::chrono::private_chrono::days_in_month[
static_cast<unsigned>(current_month)];
106 if (current_month == etl::chrono::February && current_year.
is_leap())
111 if (days_since_epoch < days_in_month)
116 days_since_epoch -= days_in_month;
168 ETL_NODISCARD ETL_CONSTEXPR14
bool ok() const ETL_NOEXCEPT
171 return y.ok() && m.ok() && d.ok() && d <= max_day_for_month();
207 ETL_CONSTEXPR14 etl::chrono::year_month_day& operator-=(
const etl::chrono::months& dm) ETL_NOEXCEPT
245 ETL_NODISCARD ETL_CONSTEXPR14
operator etl::chrono::sys_days() const ETL_NOEXCEPT
252 day_count += yr.is_leap() ? 366 : 365;
258 day_count += private_chrono::days_in_month[
static_cast<unsigned>(mth)];
260 if (mth == etl::chrono::February && this->
year().is_leap())
267 day_count +=
static_cast<int>(
static_cast<unsigned>(this->
day()) - 1);
269 return sys_days(etl::chrono::days(day_count));
275 ETL_NODISCARD ETL_CONSTEXPR14
explicit operator etl::chrono::local_days() const ETL_NOEXCEPT
288 unsigned char count = 0;
290 if (y.
ok() && m.
ok())
292 count = private_chrono::days_in_month[
static_cast<unsigned>(m)];
294 if (y.
is_leap() && (m == February))
304 etl::chrono::month m;
361 return (lhs.year() == rhs.year()) && (lhs.month() == rhs.month()) && (lhs.day() == rhs.day());
369 return !(lhs == rhs);
377 if (lhs.year() < rhs.year())
381 else if (lhs.year() == rhs.year())
383 if (lhs.month() < rhs.month())
387 else if (lhs.month() == rhs.month())
389 return (lhs.day() < rhs.day());
433 auto cmp = lhs.year() <=> rhs.year();
440 cmp = lhs.month() <=> rhs.month();
447 return lhs.day() <=> rhs.day();
454 class year_month_day_last
504 ETL_NODISCARD ETL_CONSTEXPR14
bool ok()
const ETL_NOEXCEPT
506 return y.ok() && m.ok();
557 ETL_NODISCARD ETL_CONSTEXPR14
int compare(
const year_month_day_last& other)
const ETL_NOEXCEPT
574 ETL_NODISCARD ETL_CONSTEXPR14
operator etl::chrono::sys_days() const ETL_NOEXCEPT
578 return etl::chrono::sys_days(ymd);
584 ETL_NODISCARD ETL_CONSTEXPR14
explicit operator etl::chrono::local_days() const ETL_NOEXCEPT
664 return (lhs.year() == rhs.year()) && (lhs.month() == rhs.month());
672 return !(lhs == rhs);
681 if (lhs.year() < rhs.year())
685 else if (lhs.year() == rhs.year())
687 return (lhs.month() < rhs.month());
729 auto cmp1 = lhs.year() <=> rhs.year();
737 auto cmp2 = lhs.month() <=> rhs.month();
745 return lhs.month() <=> rhs.month();
755#if ETL_USING_8BIT_TYPES
759 size_t operator()(
const etl::chrono::year_month_day& ymd)
const
761 etl::chrono::year::rep y =
static_cast<etl::chrono::year::rep
>(
static_cast<int>(ymd.
year()));
762 etl::chrono::month::rep m =
static_cast<etl::chrono::month::rep
>(
static_cast<unsigned>(ymd.
month()));
763 etl::chrono::day::rep d =
static_cast<etl::chrono::day::rep
>(
static_cast<unsigned>(ymd.
day()));
765 uint8_t buffer[
sizeof(y) +
sizeof(m) +
sizeof(d)];
767 memcpy(buffer, &y,
sizeof(y));
768 memcpy(buffer +
sizeof(y), &m,
sizeof(m));
769 memcpy(buffer +
sizeof(y) +
sizeof(m), &d,
sizeof(d));
771 return etl::private_hash::generic_hash<size_t>(buffer, buffer +
sizeof(y) +
sizeof(m) +
sizeof(d));
779#if ETL_USING_8BIT_TYPES
783 size_t operator()(
const etl::chrono::year_month_day_last& ymdl)
const
785 etl::chrono::year::rep y =
static_cast<etl::chrono::year::rep
>(
static_cast<int>(ymdl.year()));
786 etl::chrono::month::rep m =
static_cast<etl::chrono::month::rep
>(
static_cast<unsigned>(ymdl.month()));
787 etl::chrono::day::rep d =
static_cast<etl::chrono::day::rep
>(
static_cast<unsigned>(ymdl.day()));
789 uint8_t buffer[
sizeof(y) +
sizeof(m) +
sizeof(d)];
791 memcpy(buffer, &y,
sizeof(y));
792 memcpy(buffer +
sizeof(y), &m,
sizeof(m));
793 memcpy(buffer +
sizeof(y) +
sizeof(m), &d,
sizeof(d));
795 return etl::private_hash::generic_hash<size_t>(buffer, buffer +
sizeof(y) +
sizeof(m) +
sizeof(d));
Spaceship operator.
Definition month_day.h:202
ETL_CONSTEXPR14 etl::chrono::month month() const ETL_NOEXCEPT
Get the month.
Definition month_day.h:216
month
Definition month.h:54
ETL_NODISCARD ETL_CONSTEXPR14 bool ok() const ETL_NOEXCEPT
Returns true if the month is within the valid 1 to 12 range.
Definition month.h:142
Spaceship operator.
Definition year_month_day.h:455
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::local_days() const ETL_NOEXCEPT
Converts to etl::chrono::local_days.
Definition year_month_day.h:584
ETL_NODISCARD ETL_CONSTEXPR14 int compare(const year_month_day_last &other) const ETL_NOEXCEPT
Definition year_month_day.h:557
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::sys_days() const ETL_NOEXCEPT
Converts to etl::chrono::sys_days.
Definition year_month_day.h:574
year_month_day
Definition year_month_day.h:45
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::local_days() const ETL_NOEXCEPT
Converts to etl::chrono::local_days.
Definition year_month_day.h:275
ETL_NODISCARD ETL_CONSTEXPR14 int compare(const year_month_day &other) const ETL_NOEXCEPT
Definition year_month_day.h:224
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::sys_days() const ETL_NOEXCEPT
Converts to etl::chrono::sys_days.
Definition year_month_day.h:245
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::month month() const ETL_NOEXCEPT
Returns the month.
Definition year_month_day.h:152
ETL_CONSTEXPR year_month_day()
Default constructor.
Definition year_month_day.h:51
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::day day() const ETL_NOEXCEPT
Returns the day.
Definition year_month_day.h:160
ETL_CONSTEXPR14 year_month_day(const etl::chrono::year &y_, const etl::chrono::month &m_, const etl::chrono::day &d_) ETL_NOEXCEPT
Construct from month and day.
Definition year_month_day.h:61
ETL_CONSTEXPR14 year_month_day(const etl::chrono::sys_days &sd) ETL_NOEXCEPT
Construct from sys_days.
Definition year_month_day.h:76
ETL_NODISCARD ETL_CONSTEXPR14 bool ok() const ETL_NOEXCEPT
Returns true if the year/month/day is valid.
Definition year_month_day.h:168
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::year year() const ETL_NOEXCEPT
Returns the year.
Definition year_month_day.h:144
ETL_CONSTEXPR14 year_month_day(const etl::chrono::local_days &ld) ETL_NOEXCEPT
Construct from local_days.
Definition year_month_day.h:129
ETL_NODISCARD ETL_CONSTEXPR14 bool is_leap() const ETL_NOEXCEPT
Returns true if the year is a leap year.
Definition year.h:156
ETL_NODISCARD ETL_CONSTEXPR14 bool ok() const ETL_NOEXCEPT
Definition year.h:130
ETL_CONSTEXPR14 etl::chrono::day operator+(const etl::chrono::day &d, const etl::chrono::days &ds) ETL_NOEXCEPT
Spaceship operator.
Definition day.h:226
ETL_CONSTEXPR14 etl::chrono::day operator-(const etl::chrono::day &d, const etl::chrono::days &ds) ETL_NOEXCEPT
Definition day.h:252
ETL_CONSTEXPR14 bool operator<(const etl::chrono::day &d1, const etl::chrono::day &d2) ETL_NOEXCEPT
Less-than operator.
Definition day.h:182
ETL_CONSTEXPR14 bool operator>=(const etl::chrono::day &d1, const etl::chrono::day &d2) ETL_NOEXCEPT
Greater-than-or-equal operator.
Definition day.h:206
ETL_CONSTEXPR14 bool operator==(const etl::chrono::day &d1, const etl::chrono::day &d2) ETL_NOEXCEPT
Equality operator.
Definition day.h:166
ETL_CONSTEXPR14 bool operator<=(const etl::chrono::day &d1, const etl::chrono::day &d2) ETL_NOEXCEPT
Less-than-or-equal operator.
Definition day.h:190
ETL_CONSTEXPR14 bool operator!=(const etl::chrono::day &d1, const etl::chrono::day &d2) ETL_NOEXCEPT
Inequality operator.
Definition day.h:174
ETL_CONSTEXPR14 bool operator>(const etl::chrono::day &d1, const etl::chrono::day &d2) ETL_NOEXCEPT
Greater-than operator.
Definition day.h:198
bitset_ext
Definition absolute.h:40