31#ifndef ETL_IN_CHRONO_H
32 #error DO NOT DIRECTLY INCLUDE THIS FILE. USE CHRONO.H
89 for (
int offset =
static_cast<int>(
static_cast<unsigned>(dy)) - 7; offset > 0; offset -= 7)
141 ETL_NODISCARD ETL_CONSTEXPR14
unsigned index() const ETL_NOEXCEPT
157 ETL_NODISCARD ETL_CONSTEXPR14
bool ok() const ETL_NOEXCEPT
159 return y.ok() && m.ok() && wdi.ok();
165 ETL_NODISCARD ETL_CONSTEXPR14
operator etl::chrono::sys_days() const ETL_NOEXCEPT
172 etl::chrono::sys_days sd = ymd;
175 unsigned int target_index = ymwd.
index();
179 unsigned int first_wd = first_weekday.
c_encoding();
180 unsigned int offset = (target_wd - first_wd + 7U) % 7U;
181 unsigned int day_of_month = offset + (target_index - 1U) * 7U;
185 return etl::chrono::sys_days(result);
189 return etl::chrono::sys_days();
196 ETL_NODISCARD ETL_CONSTEXPR14
operator etl::chrono::local_days() const ETL_NOEXCEPT
267 return (lhs.year() == rhs.year()) && (lhs.month() == rhs.month()) && (lhs.weekday() == rhs.weekday());
275 return !(lhs == rhs);
371 ETL_NODISCARD ETL_CONSTEXPR14
operator etl::chrono::sys_days() const ETL_NOEXCEPT
379 unsigned d =
static_cast<unsigned>(last_day);
384 etl::chrono::sys_days ymd_sys_days =
static_cast<etl::chrono::sys_days
>(ymd);
394 return etl::chrono::sys_days();
400 ETL_NODISCARD ETL_CONSTEXPR14
explicit operator etl::chrono::local_days() const ETL_NOEXCEPT
416 const etl::chrono::years& dy) ETL_NOEXCEPT
434 const etl::chrono::months& dm) ETL_NOEXCEPT
453 const etl::chrono::years& dy) ETL_NOEXCEPT
463 const etl::chrono::months& dm) ETL_NOEXCEPT
474 return (lhs.year() == rhs.year()) && (lhs.month() == rhs.month()) && (lhs.weekday() == rhs.weekday());
483 return !(lhs == rhs);
490#if ETL_USING_8BIT_TYPES
492 struct hash<
etl::chrono::year_month_weekday>
496 etl::chrono::year::rep y =
static_cast<etl::chrono::year::rep
>(
static_cast<int>(ymwd.
year()));
497 etl::chrono::month::rep m =
static_cast<etl::chrono::month::rep
>(
static_cast<unsigned>(ymwd.
month()));
500 uint8_t buffer[
sizeof(y) +
sizeof(m) +
sizeof(wd)];
502 memcpy(buffer, &y,
sizeof(y));
503 memcpy(buffer +
sizeof(y), &m,
sizeof(m));
504 memcpy(buffer +
sizeof(y) +
sizeof(m), &wd,
sizeof(wd));
506 return etl::private_hash::generic_hash<size_t>(buffer, buffer +
sizeof(y) +
sizeof(m) +
sizeof(wd));
514#if ETL_USING_8BIT_TYPES
518 size_t operator()(
const etl::chrono::year_month_weekday_last& ymwdl)
const
520 etl::chrono::year::rep y =
static_cast<etl::chrono::year::rep
>(
static_cast<int>(ymwdl.
year()));
521 etl::chrono::month::rep m =
static_cast<etl::chrono::month::rep
>(
static_cast<unsigned>(ymwdl.
month()));
524 uint8_t buffer[
sizeof(y) +
sizeof(m) +
sizeof(wd)];
526 memcpy(buffer, &y,
sizeof(y));
527 memcpy(buffer +
sizeof(y), &m,
sizeof(m));
528 memcpy(buffer +
sizeof(y) +
sizeof(m), &wd,
sizeof(wd));
530 return etl::private_hash::generic_hash<size_t>(buffer, buffer +
sizeof(y) +
sizeof(m) +
sizeof(wd));
Spaceship operator.
Definition month_day.h:202
month
Definition month.h:54
ETL_NODISCARD ETL_CONSTEXPR14 duration time_since_epoch() const ETL_NOEXCEPT
Definition time_point.h:100
weekday_indexed
Definition weekday.h:338
weekday_last
Definition weekday.h:409
weekday
Definition weekday.h:54
ETL_NODISCARD ETL_CONSTEXPR14 unsigned c_encoding() const ETL_NOEXCEPT
Get the C encoding of the weekday.
Definition weekday.h:210
ETL_CONSTEXPR weekday() ETL_NOEXCEPT
Default constructor.
Definition weekday.h:60
Spaceship operator.
Definition year_month_day.h:455
year_month_day
Definition year_month_day.h:45
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::month month() const ETL_NOEXCEPT
Returns the month.
Definition year_month_day.h:152
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::day day() const ETL_NOEXCEPT
Returns the day.
Definition year_month_day.h:160
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::year year() const ETL_NOEXCEPT
Returns the year.
Definition year_month_day.h:144
year_month_weekday_last
Definition year_month_weekday.h:282
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::weekday weekday() const ETL_NOEXCEPT
Returns the weekday.
Definition year_month_weekday.h:315
ETL_CONSTEXPR14 year_month_weekday_last(const etl::chrono::year &y_, const etl::chrono::month &m_, const etl::chrono::weekday_last &wdl_) ETL_NOEXCEPT
Construct from year, month, weekday_last.
Definition year_month_weekday.h:288
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::weekday_last weekday_last() const ETL_NOEXCEPT
Returns the weekday_last.
Definition year_month_weekday.h:323
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::sys_days() const ETL_NOEXCEPT
Converts to etl::chrono::sys_days.
Definition year_month_weekday.h:371
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::local_days() const ETL_NOEXCEPT
Converts to etl::chrono::local_days.
Definition year_month_weekday.h:400
ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last & operator+=(const etl::chrono::months &dm) ETL_NOEXCEPT
Adds etl::chrono::months.
Definition year_month_weekday.h:341
ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last & operator-=(const etl::chrono::years &dy) ETL_NOEXCEPT
Subtracts etl::chrono::years.
Definition year_month_weekday.h:351
ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last & operator-=(const etl::chrono::months &dm) ETL_NOEXCEPT
Subtracts etl::chrono::months.
Definition year_month_weekday.h:361
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::month month() const ETL_NOEXCEPT
Returns the month.
Definition year_month_weekday.h:307
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::year year() const ETL_NOEXCEPT
Returns the year.
Definition year_month_weekday.h:299
ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last & operator+=(const etl::chrono::years &dy) ETL_NOEXCEPT
Adds etl::chrono::years.
Definition year_month_weekday.h:331
year_month_weekday
Definition year_month_weekday.h:43
ETL_CONSTEXPR14 year_month_weekday(const etl::chrono::year &y_, const etl::chrono::month &m_, const etl::chrono::weekday_indexed &wdi_) ETL_NOEXCEPT
Construct from month, day, and weekday_indexed.
Definition year_month_weekday.h:59
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::weekday weekday() const ETL_NOEXCEPT
Returns the weekday.
Definition year_month_weekday.h:133
ETL_CONSTEXPR14 year_month_weekday(const etl::chrono::sys_days &sd) ETL_NOEXCEPT
Construct from sys_days.
Definition year_month_weekday.h:70
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::year year() const ETL_NOEXCEPT
Returns the year.
Definition year_month_weekday.h:117
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::sys_days() const ETL_NOEXCEPT
Converts to etl::chrono::sys_days.
Definition year_month_weekday.h:165
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::weekday_indexed weekday_indexed() const ETL_NOEXCEPT
Returns the weekday_indexed.
Definition year_month_weekday.h:149
ETL_CONSTEXPR14 year_month_weekday(const etl::chrono::local_days &ld) ETL_NOEXCEPT
Construct from local_days.
Definition year_month_weekday.h:102
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::local_days() const ETL_NOEXCEPT
Converts to etl::chrono::local_days.
Definition year_month_weekday.h:196
ETL_NODISCARD ETL_CONSTEXPR14 unsigned index() const ETL_NOEXCEPT
Returns the weekday index.
Definition year_month_weekday.h:141
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::month month() const ETL_NOEXCEPT
Returns the month.
Definition year_month_weekday.h:125
ETL_NODISCARD ETL_CONSTEXPR14 bool ok() const ETL_NOEXCEPT
Returns true if the year/month/day is valid.
Definition year_month_weekday.h:157
ETL_CONSTEXPR year_month_weekday()
Default constructor.
Definition year_month_weekday.h:49
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
Equality operator.
Definition day.h:166
ETL_CONSTEXPR14 bool operator!=(const etl::chrono::day &d1, const etl::chrono::day &d2) ETL_NOEXCEPT
Inequality operator.
Definition day.h:174
bitset_ext
Definition absolute.h:40