diff --git a/CHANGELOG.md b/CHANGELOG.md index 18dd2f2..263b4bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Change Log -- calendar ==================================================================================================== +# v2.0.0 (2024-02-05) + +### Change + - Made the annual calendar print row major. That is, months go left-to-right, then top-to-bottom. + + +---------------------------------------------------------------------------------------------------- # v1.2.0 (2023-12-01) ### Fix diff --git a/README.md b/README.md index 8296f77..a50eda2 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Usage The `--startSun` option sets first day of the week as Sunday. By default, Monday is considered the first day of the week. - calendar 1.2.0 | 2023-12-01 | https://github.com/hollasch/calendar + calendar 2.0.0 | 2024-02-05 | https://github.com/hollasch/calendar Building diff --git a/calendar.cpp b/calendar.cpp index 6886376..f3e5842 100644 --- a/calendar.cpp +++ b/calendar.cpp @@ -18,7 +18,7 @@ using std::cout, std::cerr; -const char* version = "calendar 1.2.0 | 2023-12-01 | https://github.com/hollasch/calendar"; +const char* version = "calendar 2.0.0 | 2024-02-05 | https://github.com/hollasch/calendar"; //-------------------------------------------------------------------------------------------------- @@ -190,7 +190,12 @@ void printYear (const ProgramParameters& params) { // Print four rows of three month columns. - for (int leftMonth=0; leftMonth < 4; ++leftMonth) { + const bool rowMajor = true; // Months go (true=left-to-right, false=top-to-bottom) first. + const int lastRowStart = rowMajor ? 9 : 3; + const int rowStep = rowMajor ? 3 : 1; + const int colStep = rowMajor ? 1 : 4; + + for (int leftMonth=0; leftMonth <= lastRowStart; leftMonth += rowStep) { cout << "\n " << params.dowHeader // Print day-of-week headers << " " << params.dowHeader @@ -204,7 +209,7 @@ void printYear (const ProgramParameters& params) { // Initialize start and last days for each month column. for (int column = 0; column < 3; ++column) { - int month = leftMonth + 4*column; + int month = leftMonth + colStep*column; day[column] = monthWeekStartDay(params.startSun, monthDayOneDOW(params.year, month)), lastDay[column] = monthNumDays(params.year, month); } @@ -214,7 +219,7 @@ void printYear (const ProgramParameters& params) { while (day[0] <= lastDay[0] || day[1] <= lastDay[1] || day[2] <= lastDay[2]) { cout << '\n'; for (int column = 0; column < 3; ++column) { - int month = leftMonth + 4*column; + int month = leftMonth + colStep*column; if (0 < column) cout << " ";