// A month has five full weekends when it has 31 days,
// and the 1st day of the month is a Friday.
#include <iostream>
#include <chrono>
#include <string>
#include <array>
using namespace std::chrono;
// ------------------------------------------------------------
// Month names as a single reusable constant
// ------------------------------------------------------------
namespace CalendarData {
constexpr std::array<std::string_view, 12> monthNames = {
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
};
}
// ------------------------------------------------------------
// Function: returns true if a month has 5 full weekends
// ------------------------------------------------------------
bool hasFiveFullWeekends(year y, unsigned m) {
year_month_day firstDay = y / month{m} / day{1};
sys_days firstSysDay{firstDay};
weekday wd{firstSysDay};
year_month ym = y / month{m};
year_month_day lastDay = ym / last;
unsigned daysInMonth = static_cast<unsigned>(lastDay.day());
return (daysInMonth == 31 && wd == Friday);
}
// ------------------------------------------------------------
// Main program
// ------------------------------------------------------------
int main() {
int startYear = 2026;
int endYear = 2030;
using CalendarData::monthNames;
for (int y = startYear; y <= endYear; y++) {
std::cout << y << " ";
for (int m = 1; m <= 12; m++) {
if (hasFiveFullWeekends(year{y}, static_cast<unsigned>(m))) {
std::cout << "\n" << monthNames[m - 1] << " " << y
<< " has five full weekends.";
}
}
std::cout << "\n";
}
}
/*
run:
2026
May 2026 has five full weekends.
2027
January 2027 has five full weekends.
October 2027 has five full weekends.
2028
December 2028 has five full weekends.
2029
2030
March 2030 has five full weekends.
*/