31#ifndef ETL_IN_CHRONO_H
32 #error DO NOT DIRECTLY INCLUDE THIS FILE. USE CHRONO.H
87 for (
int offset =
static_cast<int>(dy) - 7; offset > 0; offset -= 7)
140 ETL_CONSTEXPR14
unsigned index() const ETL_NOEXCEPT
158 ETL_CONSTEXPR14
bool ok() const ETL_NOEXCEPT
160 return y.ok() && m.ok() && wdi.ok();
167 ETL_CONSTEXPR14
operator etl::chrono::sys_days() const ETL_NOEXCEPT
174 etl::chrono::sys_days sd = ymd;
177 unsigned int target_index = ymwd.
index();
182 int offset = (target_wd - first_wd + 7) % 7;
183 int day_of_month = offset +
static_cast<int>(target_index - 1) * 7;
187 return etl::chrono::sys_days(result);
191 return etl::chrono::sys_days();
199 ETL_CONSTEXPR14
operator etl::chrono::local_days() const ETL_NOEXCEPT
215 const etl::chrono::years& dy) ETL_NOEXCEPT
233 const etl::chrono::months& dm) ETL_NOEXCEPT
251 const etl::chrono::years& dy) ETL_NOEXCEPT
260 const etl::chrono::months& dm) ETL_NOEXCEPT
271 return (lhs.year() == rhs.year()) &&
272 (lhs.month() == rhs.month()) &&
273 (lhs.weekday() == rhs.weekday());
282 return !(lhs == rhs);
384 ETL_CONSTEXPR14
operator etl::chrono::sys_days() const ETL_NOEXCEPT
391 unsigned d =
static_cast<unsigned>(last_day);
396 etl::chrono::sys_days ymd_sys_days =
static_cast<etl::chrono::sys_days
>(ymd);
406 return etl::chrono::sys_days();
413 ETL_CONSTEXPR14
explicit operator etl::chrono::local_days() const ETL_NOEXCEPT
429 const etl::chrono::years& dy) ETL_NOEXCEPT
447 const etl::chrono::months& dm) ETL_NOEXCEPT
465 const etl::chrono::years& dy) ETL_NOEXCEPT
474 const etl::chrono::months& dm) ETL_NOEXCEPT
485 return (lhs.year() == rhs.year()) &&
486 (lhs.month() == rhs.month()) &&
487 (lhs.weekday() == rhs.weekday());
496 return !(lhs == rhs);
503#if ETL_USING_8BIT_TYPES
505 struct hash<
etl::chrono::year_month_weekday>
509 etl::chrono::year::rep y =
static_cast<etl::chrono::year::rep
>(
static_cast<unsigned>(ymwd.
year()));
510 etl::chrono::month::rep m =
static_cast<etl::chrono::month::rep
>(
static_cast<unsigned>(ymwd.
month()));
513 uint8_t buffer[
sizeof(y) +
sizeof(m) +
sizeof(wd)];
515 memcpy(buffer, &y,
sizeof(y));
516 memcpy(buffer +
sizeof(y), &m,
sizeof(m));
517 memcpy(buffer +
sizeof(y) +
sizeof(m), &wd,
sizeof(wd));
519 return etl::private_hash::generic_hash<size_t>(buffer, buffer +
sizeof(y) +
sizeof(m) +
sizeof(wd));
527#if ETL_USING_8BIT_TYPES
531 size_t operator()(
const etl::chrono::year_month_weekday_last& ymwdl)
const
533 etl::chrono::year::rep y =
static_cast<etl::chrono::year::rep
>(
static_cast<unsigned>(ymwdl.
year()));
534 etl::chrono::month::rep m =
static_cast<etl::chrono::month::rep
>(
static_cast<unsigned>(ymwdl.
month()));
537 uint8_t buffer[
sizeof(y) +
sizeof(m) +
sizeof(wd)];
539 memcpy(buffer, &y,
sizeof(y));
540 memcpy(buffer +
sizeof(y), &m,
sizeof(m));
541 memcpy(buffer +
sizeof(y) +
sizeof(m), &wd,
sizeof(wd));
543 return etl::private_hash::generic_hash<size_t>(buffer, buffer +
sizeof(y) +
sizeof(m) +
sizeof(wd));
Spaceship operator.
Definition month_day.h:215
month
Definition month.h:54
ETL_NODISCARD ETL_CONSTEXPR14 duration time_since_epoch() const ETL_NOEXCEPT
Returns a duration representing the amount of time between this and the clock's epoch.
Definition time_point.h:100
weekday_indexed
Definition weekday.h:344
weekday_last
Definition weekday.h:439
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:212
ETL_CONSTEXPR weekday() ETL_NOEXCEPT
Default constructor.
Definition weekday.h:60
Spaceship operator.
Definition year_month_day.h:473
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:150
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::day day() const ETL_NOEXCEPT
Returns the day.
Definition year_month_day.h:159
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::year year() const ETL_NOEXCEPT
Returns the year.
Definition year_month_day.h:141
year_month_weekday_last
Definition year_month_weekday.h:289
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::weekday weekday() const ETL_NOEXCEPT
Returns the weekday.
Definition year_month_weekday.h:326
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:295
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::weekday_last weekday_last() const ETL_NOEXCEPT
Returns the weekday_last.
Definition year_month_weekday.h:335
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::sys_days() const ETL_NOEXCEPT
Converts to etl::chrono::sys_days.
Definition year_month_weekday.h:384
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::local_days() const ETL_NOEXCEPT
Converts to etl::chrono::local_days.
Definition year_month_weekday.h:413
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:363
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::month month() const ETL_NOEXCEPT
Returns the month.
Definition year_month_weekday.h:317
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::year year() const ETL_NOEXCEPT
Returns the year.
Definition year_month_weekday.h:308
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:343
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:131
ETL_CONSTEXPR14 year_month_weekday(const etl::chrono::sys_days &sd) ETL_NOEXCEPT
Construct from sys_days.
Definition year_month_weekday.h:71
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::year year() const ETL_NOEXCEPT
Returns the year.
Definition year_month_weekday.h:113
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::sys_days() const ETL_NOEXCEPT
Converts to etl::chrono::sys_days.
Definition year_month_weekday.h:167
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:100
ETL_NODISCARD ETL_CONSTEXPR14 operator etl::chrono::local_days() const ETL_NOEXCEPT
Converts to etl::chrono::local_days.
Definition year_month_weekday.h:199
ETL_NODISCARD ETL_CONSTEXPR14 unsigned index() const ETL_NOEXCEPT
Returns the weekday index.
Definition year_month_weekday.h:140
ETL_NODISCARD ETL_CONSTEXPR14 etl::chrono::month month() const ETL_NOEXCEPT
Returns the month.
Definition year_month_weekday.h:122
ETL_NODISCARD ETL_CONSTEXPR14 bool ok() const ETL_NOEXCEPT
Returns true if the year/month/day is valid.
Definition year_month_weekday.h:158
ETL_CONSTEXPR year_month_weekday()
Default constructor.
Definition year_month_weekday.h:49
bitset_ext
Definition absolute.h:39