31#ifndef ETL_IN_CHRONO_H
32 #error DO NOT DIRECTLY INCLUDE THIS FILE. USE CHRONO.H
81 int days_since_epoch =
static_cast<int>(sd.time_since_epoch().count());
90 int days_in_year = current_year.
is_leap() ? 366 : 365;
92 if (days_since_epoch < days_in_year)
97 days_since_epoch -= days_in_year;
104 unsigned char days_in_month = etl::chrono::private_chrono::days_in_month[current_month];
105 if (current_month == etl::chrono::February && current_year.
is_leap())
110 if (days_since_epoch < days_in_month)
115 days_since_epoch -= days_in_month;
168 ETL_CONSTEXPR14
bool ok() const ETL_NOEXCEPT
174 d <= max_day_for_month();
210 ETL_CONSTEXPR14 etl::chrono::year_month_day& operator -=(
const etl::chrono::months& dm) ETL_NOEXCEPT
230 if (y < other.y)
return -1;
231 if (y > other.y)
return 1;
232 if (m < other.m)
return -1;
233 if (m > other.m)
return 1;
234 if (d < other.d)
return -1;
235 if (d > other.d)
return 1;
244 ETL_CONSTEXPR14
operator etl::chrono::sys_days() const ETL_NOEXCEPT
251 day_count += yr.is_leap() ? 366 : 365;
257 day_count += private_chrono::days_in_month[mth];
259 if (mth == etl::chrono::February && this->
year().is_leap())
266 day_count +=
static_cast<unsigned>(this->
day()) - 1;
268 return sys_days(etl::chrono::days(day_count));
275 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[m];
294 if (y.
is_leap() && (m == February))
304 etl::chrono::month m;
312 const etl::chrono::years& dy) ETL_NOEXCEPT
330 const etl::chrono::months& dm) ETL_NOEXCEPT
348 const etl::chrono::years& dy) ETL_NOEXCEPT
357 const etl::chrono::months& dm) ETL_NOEXCEPT
368 return (lhs.year() == rhs.year()) &&
369 (lhs.month() == rhs.month()) &&
370 (lhs.day() == rhs.day());
379 return !(lhs == rhs);
385 ETL_NODISCARD ETL_CONSTEXPR14
389 if (lhs.year() < rhs.year())
393 else if (lhs.year() == rhs.year())
395 if (lhs.month() < rhs.month())
399 else if (lhs.month() == rhs.month())
401 return (lhs.day() < rhs.day());
417 ETL_NODISCARD ETL_CONSTEXPR14
427 ETL_NODISCARD ETL_CONSTEXPR14
437 ETL_NODISCARD ETL_CONSTEXPR14
451 auto cmp = lhs.year() <=> rhs.year();
458 cmp = lhs.month() <=> rhs.month();
465 return lhs.day() <=> rhs.day();
472 class year_month_day_last
528 ETL_CONSTEXPR14
bool ok()
const ETL_NOEXCEPT
530 return y.ok() && m.ok();
582 ETL_CONSTEXPR14
int compare(
const year_month_day_last& other)
const ETL_NOEXCEPT
584 if (y < other.y)
return -1;
585 if (y > other.y)
return 1;
586 if (m < other.m)
return -1;
587 if (m > other.m)
return 1;
596 ETL_CONSTEXPR14
operator etl::chrono::sys_days() const ETL_NOEXCEPT
600 return etl::chrono::sys_days(ymd);
607 ETL_CONSTEXPR14
explicit operator etl::chrono::local_days() const ETL_NOEXCEPT
622 const etl::chrono::years& dy) ETL_NOEXCEPT
640 const etl::chrono::months& dm) ETL_NOEXCEPT
658 const etl::chrono::years& dy) ETL_NOEXCEPT
667 const etl::chrono::months& dm) ETL_NOEXCEPT
688 return (lhs.year() == rhs.year()) &&
689 (lhs.month() == rhs.month());
698 return !(lhs == rhs);
704 ETL_NODISCARD ETL_CONSTEXPR14
708 if (lhs.year() < rhs.year())
712 else if (lhs.year() == rhs.year())
714 return (lhs.month() < rhs.month());
725 ETL_NODISCARD ETL_CONSTEXPR14
735 ETL_NODISCARD ETL_CONSTEXPR14
745 ETL_NODISCARD ETL_CONSTEXPR14
759 auto cmp1 = lhs.year() <=> rhs.year();
767 auto cmp2 = lhs.month() <=> rhs.month();
775 return lhs.month() <=> rhs.month();
785#if ETL_USING_8BIT_TYPES
789 size_t operator()(
const etl::chrono::year_month_day& ymd)
const
791 etl::chrono::year::rep y =
static_cast<etl::chrono::year::rep
>(
static_cast<unsigned>(ymd.
year()));
792 etl::chrono::month::rep m =
static_cast<etl::chrono::month::rep
>(
static_cast<unsigned>(ymd.
month()));
793 etl::chrono::day::rep d =
static_cast<etl::chrono::day::rep
>(
static_cast<unsigned>(ymd.
day()));
795 uint8_t buffer[
sizeof(y) +
sizeof(m) +
sizeof(d)];
797 memcpy(buffer, &y,
sizeof(y));
798 memcpy(buffer +
sizeof(y), &m,
sizeof(m));
799 memcpy(buffer +
sizeof(y) +
sizeof(m), &d,
sizeof(d));
801 return etl::private_hash::generic_hash<size_t>(buffer, buffer +
sizeof(y) +
sizeof(m) +
sizeof(d));
809#if ETL_USING_8BIT_TYPES
813 size_t operator()(
const etl::chrono::year_month_day_last& ymdl)
const
815 etl::chrono::year::rep y =
static_cast<etl::chrono::year::rep
>(
static_cast<unsigned>(ymdl.year()));
816 etl::chrono::month::rep m =
static_cast<etl::chrono::month::rep
>(
static_cast<unsigned>(ymdl.month()));
817 etl::chrono::day::rep d =
static_cast<etl::chrono::day::rep
>(
static_cast<unsigned>(ymdl.day()));
819 uint8_t buffer[
sizeof(y) +
sizeof(m) +
sizeof(d)];
821 memcpy(buffer, &y,
sizeof(y));
822 memcpy(buffer +
sizeof(y), &m,
sizeof(m));
823 memcpy(buffer +
sizeof(y) +
sizeof(m), &d,
sizeof(d));
825 return etl::private_hash::generic_hash<size_t>(buffer, buffer +
sizeof(y) +
sizeof(m) +
sizeof(d));
Spaceship operator.
Definition month_day.h:215
ETL_CONSTEXPR14 etl::chrono::month month() const ETL_NOEXCEPT
Get the month.
Definition month_day.h:229
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 31 range.
Definition month.h:161
Spaceship operator.
Definition year_month_day.h:473
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::local_days() const ETL_NOEXCEPT
Converts to etl::chrono::local_days.
Definition year_month_day.h:607
ETL_NODISCARD ETL_CONSTEXPR14 int compare(const year_month_day_last &other) const ETL_NOEXCEPT
Definition year_month_day.h:582
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::sys_days() const ETL_NOEXCEPT
Converts to etl::chrono::sys_days.
Definition year_month_day.h:596
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:228
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::sys_days() const ETL_NOEXCEPT
Converts to etl::chrono::sys_days.
Definition year_month_day.h:244
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::month month() const ETL_NOEXCEPT
Returns the month.
Definition year_month_day.h:150
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:159
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:78
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:141
ETL_CONSTEXPR14 year_month_day(const etl::chrono::local_days &ld) ETL_NOEXCEPT
Construct from local_days.
Definition year_month_day.h:128
ETL_NODISCARD ETL_CONSTEXPR14 bool is_leap() const ETL_NOEXCEPT
Returns true if the year is a leap year.
Definition year.h:175
ETL_NODISCARD ETL_CONSTEXPR14 bool ok() const ETL_NOEXCEPT
Returns true if the year is within the valid -32767 to 32767 range.
Definition year.h:148
bitset_ext
Definition absolute.h:39