diff -r d869ff924c19 -r e714005f3e9d src/main.cpp --- a/src/main.cpp Sat Feb 01 14:11:46 2025 +0100 +++ b/src/main.cpp Sat Feb 01 14:19:36 2025 +0100 @@ -34,8 +34,7 @@ #include #include -namespace chrono = std::chrono; -using chrono::operator ""d; +using namespace std::chrono; static void print_help() { fputs( @@ -179,14 +178,13 @@ } // determine our reporting range - int year; - if (settings.year == fm::settings_current_year) { - year = static_cast(chrono::year_month_day{chrono::floor(chrono::system_clock::now())}.year()); - } else { - year = settings.year; - } - chrono::year_month_day report_begin{chrono::year{year}, chrono::January, 1d}; - chrono::year_month_day report_end{chrono::year{year}, chrono::December, 31d}; + year report_year{ + settings.year == fm::settings_current_year + ? year_month_day{floor(system_clock::now())}.year() + : year{settings.year} + }; + year_month_day report_begin{report_year, January, 1d}; + year_month_day report_end{report_year, December, 31d}; // read the commit logs fm::heatmap heatmap; @@ -198,7 +196,7 @@ if (repo.type == fm::HG) { proc.setbin(settings.hg); if (proc.exec_log({"log", - "--date", std::format("{0}-01-01 to {0}-12-31", year), + "--date", std::format("{0}-01-01 to {0}-12-31", report_year), "--template", "{author}#{date|shortdate}\n"})) { fprintf(stderr, "Reading commit log for repo '%s' failed!\n", repo.path.c_str()); return EXIT_FAILURE; @@ -207,8 +205,8 @@ } else { proc.setbin(settings.git); if (proc.exec_log({"log", - "--since", std::format("{0}-01-01", year), - "--until", std::format("{0}-12-31", year), + "--since", std::format("{0}-01-01", report_year), + "--until", std::format("{0}-12-31", report_year), "--format=tformat:%an <%ae>#%cs"})) { fprintf(stderr, "Reading commit log for repo '%s' failed!\n", repo.path.c_str()); return EXIT_FAILURE; @@ -222,13 +220,13 @@ html::h1(repo); for (const auto &[author, entries] : authors) { html::h2(author); - html::table_begin(year); + html::table_begin(report_year); // initialize counters unsigned column = 0, row = 0; // initialize first day (which must be a Monday, possibly the year before) - chrono::sys_days day_to_check = chrono::January / chrono::Monday[1] / chrono::year{year}; + sys_days day_to_check = January / Monday[1] / report_year; // remember the starting point auto start = day_to_check; @@ -240,7 +238,7 @@ // check if we need to add blank cells while (day_to_check < report_begin) { html::cell_out_of_range(); - day_to_check += chrono::days{7}; + day_to_check += days{7}; column++; } @@ -253,7 +251,7 @@ html::cell(day_to_check, find_result->second); } // advance seven days and one column - day_to_check += chrono::days{7}; + day_to_check += days{7}; column++; } // fill remaining columns with blank cells @@ -268,7 +266,7 @@ if (++row == 7) break; // otherwise, advance the starting point by one day, reset, and begin a new row - start += chrono::days{1}; + start += days{1}; day_to_check = start; column =0; }