41. Day of the week

Solving this problem is again relatively straightforward if you use the date library. However, this time, you have to use the following types:

  • date::year_month_day, a structure that represents a day with fields for year, month (1 to 12), and day (1 to 31).
  • date::iso_week::year_weeknum_weekday, from the iso_week.h header, is a structure that has fields for year, number of weeks in a year, and number of days in a week (1 to 7). This class is implicitly convertible to and from date::sys_days, which makes it explicitly convertible to any other calendar system that is implicitly convertible to and from date::sys_days, such as date::year_month_day.

With that being said, the problem resolves to creating a year_month_day object ...

Get The Modern C++ Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.