src/html.cpp

changeset 13
e714005f3e9d
parent 11
127fb6a8f706
child 15
ef0f2497843e
--- a/src/html.cpp	Sat Feb 01 14:11:46 2025 +0100
+++ b/src/html.cpp	Sat Feb 01 14:19:36 2025 +0100
@@ -26,8 +26,7 @@
 
 #include <cstdio>
 
-namespace chrono = std::chrono;
-using chrono::operator ""d;
+using namespace std::chrono;
 
 namespace html {
     static constexpr const char* weekdays[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
@@ -135,22 +134,22 @@
     printf("<h2>%s</h2>\n", encode(heading).c_str());
 }
 
-void html::table_begin(int year) {
+void html::table_begin(year y) {
     static constexpr const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
     // compute the column spans, first
     unsigned colspans[12] = {};
     {
         unsigned total_cols = 0;
-        chrono::sys_days day{chrono::year_month_day{chrono::year{year}, chrono::January, 1d}};
-        if (chrono::weekday{day}.iso_encoding() != 1) {
+        sys_days day{year_month_day{y, January, 1d}};
+        if (weekday{day}.iso_encoding() != 1) {
             colspans[0] = 1;
             total_cols = 1;
         }
         for (unsigned col = 0; col < 12; ++col) {
-            while (total_cols < html::columns && chrono::year_month_day{day}.month() <= chrono::month{col + 1}) {
+            while (total_cols < html::columns && year_month_day{day}.month() <= month{col + 1}) {
                 ++total_cols;
                 ++colspans[col];
-                day += chrono::days{7};
+                day += days{7};
             }
         }
     }
@@ -193,7 +192,7 @@
     puts("<td class=\"out-of-range\"></td>");
 }
 
-void html::cell(std::chrono::year_month_day ymd, unsigned commits) {
+void html::cell(year_month_day ymd, unsigned commits) {
     const char *color_class;
     if (commits == 0) {
         color_class = "zero-commits";
@@ -211,7 +210,7 @@
     indent();
     printf("<td class=\"%s\" title=\"%s, %d-%u-%u: %u commits\"></td>\n",
         color_class,
-        weekdays[chrono::weekday(ymd).iso_encoding() - 1],
+        weekdays[weekday(ymd).iso_encoding() - 1],
         static_cast<int>(ymd.year()),
         static_cast<unsigned>(ymd.month()),
         static_cast<unsigned>(ymd.day()),

mercurial